- Timestamp:
- 04/17/14 05:42:28 (10 years ago)
- Branches:
- 4.11, 5, master
- Children:
- 774edf2c
- Parents:
- d98eea0
- git-author:
- Sebastian Huber <sebastian.huber@…> (04/17/14 05:42:28)
- git-committer:
- Sebastian Huber <sebastian.huber@…> (04/22/14 06:34:45)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/user/smp.t
rd98eea0 rfab2f188 202 202 @subsection Setting Affinity to a Single Processor 203 203 204 In many embedded applications targeting SMP systems, it is common to lock individual tasks to specific cores. In this way, one can designate a core for I/O tasks, another for computation, etc.. The following illustrates the code sequence necessary to assign a task an affinity for processor zero (0). 205 206 @example 207 rtems_status_code sc; 208 cpu_set_t set; 209 210 CPU_EMPTY( &set ); 211 CPU_SET( 0, &set ); 212 213 sc = rtems_task_set_affinity(rtems_task_self(), sizeof(set), &set); 214 assert(sc == RTEMS_SUCCESSFUL); 215 @end example 216 217 It is important to note that the @code{cpu_set_t} is not validated until the 204 On some embedded applications targeting SMP systems, it may be beneficial to 205 lock individual tasks to specific processors. In this way, one can designate a 206 processor for I/O tasks, another for computation, etc.. The following 207 illustrates the code sequence necessary to assign a task an affinity for 208 processor with index @code{processor_index}. 209 210 @example 211 @group 212 #include <rtems.h> 213 #include <assert.h> 214 215 void pin_to_processor(rtems_id task_id, int processor_index) 216 @{ 217 rtems_status_code sc; 218 cpu_set_t cpuset; 219 220 CPU_ZERO(&cpuset); 221 CPU_SET(processor_index, &cpuset); 222 223 sc = rtems_task_set_affinity(task_id, sizeof(cpuset), &cpuset); 224 assert(sc == RTEMS_SUCCESSFUL); 225 @} 226 @end group 227 @end example 228 229 It is important to note that the @code{cpuset} is not validated until the 218 230 @code{@value{DIRPREFIX}task_set_affinity} call is made. At that point, 219 231 it is validated against the current system configuration.
Note: See TracChangeset
for help on using the changeset viewer.