diff options
author | Tom Rondeau <trondeau@vt.edu> | 2013-03-01 13:19:00 -0500 |
---|---|---|
committer | Tom Rondeau <trondeau@vt.edu> | 2013-03-01 13:19:00 -0500 |
commit | ce211603ff8821b50f7c9ebc3931498c6f2bd374 (patch) | |
tree | dd8b92841ef4cd0728aa1156b105e7173286627b /docs/doxygen/other/thread_affinity.dox | |
parent | 6121d0b12bcb308586b5888b6c7e82832f692e5c (diff) | |
parent | 4c164f4cbb7fc9284bec147809b078d0a8ed9f88 (diff) |
Merge branch 'master' into gr_log
Conflicts:
cmake/Modules/GrMiscUtils.cmake
docs/doxygen/other/main_page.dox
gnuradio-core/gnuradio-core.conf.in
gnuradio-core/src/lib/swig/CMakeLists.txt
gr-digital/lib/CMakeLists.txt
gr-howto-write-a-block/CMakeLists.txt
gr-qtgui/lib/CMakeLists.txt
gr-video-sdl/src/CMakeLists.txt
Diffstat (limited to 'docs/doxygen/other/thread_affinity.dox')
-rw-r--r-- | docs/doxygen/other/thread_affinity.dox | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/docs/doxygen/other/thread_affinity.dox b/docs/doxygen/other/thread_affinity.dox new file mode 100644 index 0000000000..fbbc449a4a --- /dev/null +++ b/docs/doxygen/other/thread_affinity.dox @@ -0,0 +1,65 @@ +/*! \page page_affinity Block Thread Affinity + +\section intro Introduction + +In the thread-per-block scheduler, you can set the block's core +affinity. Each block can be pinned to a group cores or be set back +to use the standard kernel scheduler. + +The implementation is done by adding new functions to the GRUEL +library: + +\code + gr_thread_t get_current_thread_id(); + void thread_bind_to_processor(unsigned int n); + void thread_bind_to_processor(const std::vector<unsigned int> &mask); + void thread_bind_to_processor(gr_thread_t thread, unsigned int n); + void thread_bind_to_processor(gr_thread_t thread, const std::vector<unsigned int> &mask); + void thread_unbind(); + void thread_unbind(gr_thread_t thread); +\endcode + +The ability to set a thread's affinity to a core or groups of cores is +not implemented in the Boost thread library, and so we have made our +own portability library. In particular, the gruel::gr_thread_t type is +defined as the thread type for the given system. The other functions +are designed to be portable as well by calling the specific +implementation for the thread affinity for a particular platform. + +There are functions to set a thread to a group of cores. If the thread +is not given, the current thread is used. If a single number is +passed, only that core is set (this is equivalent to a core mask with +just a single value). + +Similarly, there are functions to unset the affinity. This practically +implements the setting of the thread's affinity to all possible +cores. Again, the function that does not take a thread argument unsets +the affinity for the current thread. + + +\section api GNU Radio Block API + +Each block has two new data members: + +- threaded: a boolean value that is true if the block is attached to a + thread. +- thread: a gruel::gr_thread_t handle to the block's thread. + +A block can set and unset it's affinity at any time using the +following member functions: + +- gr_block::set_processor_affinity(const std::vector<unsigned int> &mask) +- gr_block::unset_processor_affinity() + +Where \p mask is a vector of core numbers to set the thread's affinity +to. + +The current core affinity can be retrieved using the member function: + +- gr_block::processor_affinity() + +When set before the flowgraph is started, the scheduler will set the +thread's affinity when it is started. When already running, the +block's affinity will be immediately set. + +*/ |