RTEMS
taskgetaffinity.c
Go to the documentation of this file.
1 
9 /*
10  * COPYRIGHT (c) 2014.
11  * On-Line Applications Research Corporation (OAR).
12  *
13  * The license and distribution terms for this file may be
14  * found in the file LICENSE in this distribution or at
15  * http://www.rtems.org/license/LICENSE.
16  */
17 
18 #ifdef HAVE_CONFIG_H
19 #include "config.h"
20 #endif
21 
22 #include <rtems/rtems/tasks.h>
23 #include <rtems/score/threadimpl.h>
25 
27  rtems_id id,
28  size_t cpusetsize,
29  cpu_set_t *cpuset
30 )
31 {
32  Thread_Control *the_thread;
33  ISR_lock_Context lock_context;
34  Per_CPU_Control *cpu_self;
35  bool ok;
36 
37  if ( cpuset == NULL ) {
38  return RTEMS_INVALID_ADDRESS;
39  }
40 
41  the_thread = _Thread_Get( id, &lock_context );
42 
43  if ( the_thread == NULL ) {
44 #if defined(RTEMS_MULTIPROCESSING)
45  if ( _Thread_MP_Is_remote( id ) ) {
47  }
48 #endif
49 
50  return RTEMS_INVALID_ID;
51  }
52 
53  cpu_self = _Thread_Dispatch_disable_critical( &lock_context );
54  _Thread_State_acquire_critical( the_thread, &lock_context );
55 
57  the_thread,
58  cpusetsize,
59  cpuset
60  );
61 
62  _Thread_State_release( the_thread, &lock_context );
63  _Thread_Dispatch_enable( cpu_self );
65 }
rtems_status_code rtems_task_get_affinity(rtems_id id, size_t cpusetsize, cpu_set_t *cpuset)
%
static __inline__ void _Thread_State_acquire_critical(Thread_Control *the_thread, ISR_lock_Context *lock_context)
Acquires the lock context in a critical section.
Definition: threadimpl.h:528
Inlined Routines Associated with the Manipulation of the Scheduler.
This status code indicates that a specified number was invalid.
Definition: status.h:138
Thread_Control * _Thread_Get(Objects_Id id, ISR_lock_Context *lock_context)
Gets a thread by its identifier.
Definition: threadget.c:24
static __inline__ void _Thread_State_release(Thread_Control *the_thread, ISR_lock_Context *lock_context)
Releases the lock context and enables interrupts.
Definition: threadimpl.h:592
This status code indicates successful completion.
Definition: status.h:86
static __inline__ Per_CPU_Control * _Thread_Dispatch_disable_critical(const ISR_lock_Context *lock_context)
Disables thread dispatching inside a critical section (interrupts disabled).
rtems_status_code
This enumeration provides status codes for directives of the Classic API.
Definition: status.h:82
Per CPU Core Structure.
Definition: percpu.h:347
This header file defines the main parts of the Tasks Manager API.
void _Thread_Dispatch_enable(Per_CPU_Control *cpu_self)
Enables thread dispatching.
bool _Scheduler_Get_affinity(Thread_Control *the_thread, size_t cpusetsize, cpu_set_t *cpuset)
Copies the thread&#39;s scheduler&#39;s affinity to the given cpuset.
This status code indicates that a specified address was invalid.
Definition: status.h:133
This status code indicates that an object identifier was invalid.
Definition: status.h:106
Objects_Id rtems_id
Values of this type identify an RTEMS object.
Definition: types.h:99
This status code indicates that the operation was illegal on a remote object.
Definition: status.h:177
Inlined Routines from the Thread Handler.
Local ISR lock context for acquire and release pairs.
Definition: isrlock.h:65