]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | |
2 | // Copyright Oliver Kowalke 2009. | |
3 | // Distributed under the Boost Software License, Version 1.0. | |
4 | // (See accompanying file LICENSE_1_0.txt or copy at | |
5 | // http://www.boost.org/LICENSE_1_0.txt) | |
6 | ||
7 | #include "bind_processor.hpp" | |
8 | ||
9 | extern "C" | |
10 | { | |
11 | #include <sys/param.h> | |
12 | #include <sys/cpuset.h> | |
13 | } | |
14 | ||
15 | #include <stdexcept> | |
16 | ||
17 | #include <boost/config/abi_prefix.hpp> | |
18 | ||
19 | void bind_to_processor( unsigned int n) | |
20 | { | |
21 | cpuset_t cpuset; | |
22 | CPU_ZERO( & cpuset); | |
23 | CPU_SET( n, & cpuset); | |
24 | ||
25 | if ( ::cpuset_setaffinity( CPU_LEVEL_WHICH, CPU_WHICH_TID, -1, sizeof( cpuset), & cpuset) == -1) | |
26 | throw std::runtime_error("::cpuset_setaffinity() failed"); | |
27 | } | |
28 | ||
29 | #include <boost/config/abi_suffix.hpp> |