bind_processor_hpux.cpp 741 B

12345678910111213141516171819202122232425262728293031
  1. // Copyright Oliver Kowalke 2014.
  2. // Distributed under the Boost Software License, Version 1.0.
  3. // (See accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. #include "bind_processor.hpp"
  6. extern "C"
  7. {
  8. #include <sys/pthread.h>
  9. }
  10. #include <stdexcept>
  11. #include <boost/config/abi_prefix.hpp>
  12. void bind_to_processor( unsigned int n)
  13. {
  14. ::pthread_spu_t spu;
  15. int errno_(
  16. ::pthread_processor_bind_np(
  17. PTHREAD_BIND_FORCED_NP,
  18. & spu,
  19. static_cast< pthread_spu_t >( n),
  20. PTHREAD_SELFTID_NP) );
  21. if ( errno_ != 0)
  22. throw std::runtime_error("::pthread_processor_bind_np() failed");
  23. }
  24. #include <boost/config/abi_suffix.hpp>