Changeset fab2f188 in rtems


Ignore:
Timestamp:
Apr 17, 2014, 5:42:28 AM (6 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, 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)
Message:

doc: Setting Affinity to a Single Processor

File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/user/smp.t

    rd98eea0 rfab2f188  
    202202@subsection Setting Affinity to a Single Processor
    203203
    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
     204On some embedded applications targeting SMP systems, it may be beneficial to
     205lock individual tasks to specific processors.  In this way, one can designate a
     206processor for I/O tasks, another for computation, etc..  The following
     207illustrates the code sequence necessary to assign a task an affinity for
     208processor with index @code{processor_index}.
     209
     210@example
     211@group
     212#include <rtems.h>
     213#include <assert.h>
     214
     215void 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
     229It is important to note that the @code{cpuset} is not validated until the
    218230@code{@value{DIRPREFIX}task_set_affinity} call is made. At that point,
    219231it is validated against the current system configuration.
Note: See TracChangeset for help on using the changeset viewer.