1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief POSIX Is Priority Valid |
---|
5 | * @ingroup POSIX_PRIORITY |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-2008. |
---|
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/posix/priorityimpl.h> |
---|
22 | #include <rtems/score/schedulerimpl.h> |
---|
23 | |
---|
24 | int _POSIX_Priority_Get_maximum( const Scheduler_Control *scheduler ) |
---|
25 | { |
---|
26 | if ( scheduler->maximum_priority < INT_MAX ) { |
---|
27 | return (int) scheduler->maximum_priority - 1; |
---|
28 | } else { |
---|
29 | return INT_MAX; |
---|
30 | } |
---|
31 | } |
---|
32 | |
---|
33 | Priority_Control _POSIX_Priority_To_core( |
---|
34 | const Scheduler_Control *scheduler, |
---|
35 | int posix_priority, |
---|
36 | bool *valid |
---|
37 | ) |
---|
38 | { |
---|
39 | Priority_Control core_posix_priority; |
---|
40 | Priority_Control core_priority; |
---|
41 | |
---|
42 | core_posix_priority = (Priority_Control) posix_priority; |
---|
43 | core_priority = scheduler->maximum_priority - core_posix_priority; |
---|
44 | |
---|
45 | *valid = ( posix_priority >= POSIX_SCHEDULER_MINIMUM_PRIORITY |
---|
46 | && core_posix_priority < scheduler->maximum_priority ); |
---|
47 | |
---|
48 | return _Scheduler_Map_priority( scheduler, core_priority ); |
---|
49 | } |
---|
50 | |
---|
51 | int _POSIX_Priority_From_core( |
---|
52 | const Scheduler_Control *scheduler, |
---|
53 | Priority_Control core_priority |
---|
54 | ) |
---|
55 | { |
---|
56 | core_priority = _Scheduler_Unmap_priority( scheduler, core_priority ); |
---|
57 | |
---|
58 | return (int) ( scheduler->maximum_priority - core_priority ); |
---|
59 | } |
---|