1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Gets Scheduling Policy and Parameters of Individual Threads |
---|
5 | * @ingroup POSIXAPI |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * 13.5.2 Dynamic Thread Scheduling Parameters Access, |
---|
10 | * P1003.1c/Draft 10, p. 124 |
---|
11 | * |
---|
12 | * COPYRIGHT (c) 1989-2014. |
---|
13 | * On-Line Applications Research Corporation (OAR). |
---|
14 | * |
---|
15 | * The license and distribution terms for this file may be |
---|
16 | * found in the file LICENSE in this distribution or at |
---|
17 | * http://www.rtems.org/license/LICENSE. |
---|
18 | */ |
---|
19 | |
---|
20 | #if HAVE_CONFIG_H |
---|
21 | #include "config.h" |
---|
22 | #endif |
---|
23 | |
---|
24 | #include <pthread.h> |
---|
25 | #include <errno.h> |
---|
26 | |
---|
27 | #include <rtems/posix/pthreadimpl.h> |
---|
28 | #include <rtems/posix/priorityimpl.h> |
---|
29 | #include <rtems/score/threadimpl.h> |
---|
30 | |
---|
31 | int pthread_getschedparam( |
---|
32 | pthread_t thread, |
---|
33 | int *policy, |
---|
34 | struct sched_param *param |
---|
35 | ) |
---|
36 | { |
---|
37 | Thread_Control *the_thread; |
---|
38 | ISR_lock_Context lock_context; |
---|
39 | POSIX_API_Control *api; |
---|
40 | |
---|
41 | if ( policy == NULL || param == NULL ) { |
---|
42 | return EINVAL; |
---|
43 | } |
---|
44 | |
---|
45 | the_thread = _Thread_Get_interrupt_disable( thread, &lock_context ); |
---|
46 | |
---|
47 | if ( the_thread == NULL ) { |
---|
48 | return ESRCH; |
---|
49 | } |
---|
50 | |
---|
51 | _Thread_State_acquire_critical( the_thread, &lock_context ); |
---|
52 | |
---|
53 | api = the_thread->API_Extensions[ THREAD_API_POSIX ]; |
---|
54 | *policy = api->schedpolicy; |
---|
55 | *param = api->schedparam; |
---|
56 | param->sched_priority = _POSIX_Priority_From_core( |
---|
57 | the_thread->current_priority |
---|
58 | ); |
---|
59 | |
---|
60 | _Thread_State_release( the_thread, &lock_context ); |
---|
61 | return 0; |
---|
62 | } |
---|