5
Last change
on this file since 127c20eb was
e266d13,
checked in by Sebastian Huber <sebastian.huber@…>, on 05/20/16 at 13:10:27
|
Replace *_Get_interrupt_disable() with *_Get()
Uniformly use *_Get() to get an object by identifier with a lock
context.
|
-
Property mode set to
100644
|
File size:
1.3 KB
|
Line | |
---|
1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Pthread Get Affinity |
---|
5 | * @ingroup POSIXAPI |
---|
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 | |
---|
18 | #if HAVE_CONFIG_H |
---|
19 | #include "config.h" |
---|
20 | #endif |
---|
21 | |
---|
22 | #if HAVE_DECL_PTHREAD_GETAFFINITY_NP |
---|
23 | |
---|
24 | #define _GNU_SOURCE |
---|
25 | #include <pthread.h> |
---|
26 | #include <errno.h> |
---|
27 | |
---|
28 | #include <rtems/posix/pthreadimpl.h> |
---|
29 | #include <rtems/posix/priorityimpl.h> |
---|
30 | #include <rtems/score/threadimpl.h> |
---|
31 | #include <rtems/score/schedulerimpl.h> |
---|
32 | |
---|
33 | int pthread_getaffinity_np( |
---|
34 | pthread_t thread, |
---|
35 | size_t cpusetsize, |
---|
36 | cpu_set_t *cpuset |
---|
37 | ) |
---|
38 | { |
---|
39 | Thread_Control *the_thread; |
---|
40 | ISR_lock_Context lock_context; |
---|
41 | Per_CPU_Control *cpu_self; |
---|
42 | bool ok; |
---|
43 | |
---|
44 | if ( cpuset == NULL ) { |
---|
45 | return EFAULT; |
---|
46 | } |
---|
47 | |
---|
48 | the_thread = _Thread_Get( thread, &lock_context ); |
---|
49 | |
---|
50 | if ( the_thread == NULL ) { |
---|
51 | return ESRCH; |
---|
52 | } |
---|
53 | |
---|
54 | cpu_self = _Thread_Dispatch_disable_critical( &lock_context ); |
---|
55 | _Thread_State_acquire_critical( the_thread, &lock_context ); |
---|
56 | |
---|
57 | ok = _Scheduler_Get_affinity( |
---|
58 | the_thread, |
---|
59 | cpusetsize, |
---|
60 | cpuset |
---|
61 | ); |
---|
62 | |
---|
63 | _Thread_State_release( the_thread, &lock_context ); |
---|
64 | _Thread_Dispatch_enable( cpu_self ); |
---|
65 | return ok ? 0 : EINVAL; |
---|
66 | } |
---|
67 | |
---|
68 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.