source: rtems/cpukit/rtems/src/tasksetaffinity.c @ 66cb142

Last change on this file since 66cb142 was b2dbb634, checked in by Sebastian Huber <sebastian.huber@…>, on Oct 10, 2017 at 9:36:23 AM

score: Remove CPU_set_Control

Use Processor_mask instead.

Update #2514.

  • Property mode set to 100644
File size: 1.4 KB
Line 
1/**
2 * @file
3 *
4 * @brief  RTEMS Task Set Affinity
5 * @ingroup ClassicTasks Tasks
6 */
7
8/*
9 *  COPYRIGHT (c) 2014.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.org/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/rtems/tasks.h>
22#include <rtems/score/threadimpl.h>
23#include <rtems/score/schedulerimpl.h>
24
25rtems_status_code rtems_task_set_affinity(
26  rtems_id         id,
27  size_t           cpusetsize,
28  const cpu_set_t *cpuset
29)
30{
31  Thread_Control   *the_thread;
32  ISR_lock_Context  lock_context;
33  Per_CPU_Control  *cpu_self;
34  bool              ok;
35
36  if ( cpuset == NULL ) {
37    return RTEMS_INVALID_ADDRESS;
38  }
39
40  the_thread = _Thread_Get( id, &lock_context );
41
42  if ( the_thread == NULL ) {
43#if defined(RTEMS_MULTIPROCESSING)
44    if ( _Thread_MP_Is_remote( id ) ) {
45      return RTEMS_ILLEGAL_ON_REMOTE_OBJECT;
46    }
47#endif
48
49    return RTEMS_INVALID_ID;
50  }
51
52  cpu_self = _Thread_Dispatch_disable_critical( &lock_context );
53  _Thread_State_acquire_critical( the_thread, &lock_context );
54
55  ok = _Scheduler_Set_affinity(
56    the_thread,
57    cpusetsize,
58    cpuset
59  );
60
61  _Thread_State_release( the_thread, &lock_context );
62  _Thread_Dispatch_enable( cpu_self );
63  return ok ? RTEMS_SUCCESSFUL : RTEMS_INVALID_NUMBER;
64}
Note: See TracBrowser for help on using the repository browser.