Changeset 5a32c48 in rtems
- Timestamp:
- 06/14/16 13:57:54 (7 years ago)
- Branches:
- 5, master
- Children:
- 1a4eac50
- Parents:
- eec08ef
- git-author:
- Sebastian Huber <sebastian.huber@…> (06/14/16 13:57:54)
- git-committer:
- Sebastian Huber <sebastian.huber@…> (06/22/16 12:00:28)
- Location:
- cpukit/posix
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
cpukit/posix/include/rtems/posix/priorityimpl.h
reec08ef r5a32c48 31 31 * @ingroup POSIXAPI 32 32 * 33 * @brief Interface to the POSIX Priority Implementation 34 * 33 * @brief Interface to the POSIX Priority Implementation. 34 * 35 * @{ 35 36 */ 36 /**@{**/37 38 /**39 * 1003.1b-1993,2.2.2.80 definition of priority, p. 1940 *41 * "Numerically higher values represent higher priorities."42 *43 * Thus, RTEMS Core has priorities run in the opposite sense of the POSIX API.44 *45 * There are only 254 posix priority levels since a task at priority level46 * 255 would never run because of the RTEMS idle task. This is necessary47 * because GNAT maps the lowest Ada task priority to the lowest thread48 * priority. The lowest priority Ada task should get to run, so there is49 * a fundamental conflict with having 255 priorities.50 *51 * But since RTEMS can be configured with fewer than 256 priorities,52 * we use the internal constant.53 */54 #define POSIX_SCHEDULER_MAXIMUM_PRIORITY (PRIORITY_MAXIMUM - 1)55 56 37 57 38 /** … … 73 54 * @brief Check if POSIX priority is valid. 74 55 * 75 * 1003.1b-1993,2.2.2.80 definition of priority, p. 19 56 * According to POSIX, numerically higher values represent higher priorities. 57 * Thus, SuperCore has priorities run in the opposite sense of the POSIX API. 76 58 * 77 * "Numerically higher values represent higher priorities." 59 * Let N be the maximum priority of this scheduler instance. The SuperCore 60 * priority zero is system reserved (PRIORITY_PSEUDO_ISR). There are only 61 * N - 1 POSIX API priority levels since a thread at SuperCore priority N would 62 * never run because of the idle threads. This is necessary because GNAT maps 63 * the lowest Ada task priority to the lowest thread priority. The lowest 64 * priority Ada task should get to run, so there is a fundamental conflict with 65 * having N priorities. 78 66 * 79 * Thus, RTEMS Core has priorities run in the opposite sense of the POSIX API. 67 * @param[in] scheduler The scheduler instance. 68 * @param[in] priority The POSIX API priority to test. 80 69 * 81 * @param[in] priority is the priority to test 82 * 83 * @retval TRUE The priority is valid. 84 * @retval FALSE The priority is invalid. 70 * @retval true The priority is valid. 71 * @retval false Otherwise. 85 72 */ 86 73 bool _POSIX_Priority_Is_valid( 87 int priority 74 const Scheduler_Control *scheduler, 75 int priority 88 76 ); 89 77 90 78 /** 91 * @brief Convert POSIX priority to SuperCore priority. 79 * @brief Converts the SuperCore priority to the corresponding POSIX API 80 * priority. 92 81 * 93 * This method converts a POSIX API priority into onto the corresponding94 * SuperCore value.82 * @param[in] scheduler The scheduler instance. 83 * @param[in] priority The SuperCore priority to convert. 95 84 * 96 * @param[in] priority is the POSIX API priority. 97 * 98 * @return This method returns the corresponding SuperCore priority. 85 * @return The corresponding POSIX API priority. 99 86 */ 100 RTEMS_INLINE_ROUTINE Priority_Control _POSIX_Priority_To_core( 101 int priority 87 RTEMS_INLINE_ROUTINE int _POSIX_Priority_From_core( 88 const Scheduler_Control *scheduler, 89 Priority_Control priority 102 90 ) 103 91 { 104 return (Priority_Control) (POSIX_SCHEDULER_MAXIMUM_PRIORITY - priority + 1); 105 } 106 107 /** 108 * @brief Convert SuperCore priority To POSIX priority. 109 * 110 * This method converts a SuperCore priority into onto the corresponding 111 * POSIX API value. 112 * 113 * @param[in] priority is the POSIX API priority. 114 * 115 * @return This method returns the corresponding POSIX priority. 116 */ 117 RTEMS_INLINE_ROUTINE int _POSIX_Priority_From_core( 118 Priority_Control priority 119 ) 120 { 121 return (POSIX_SCHEDULER_MAXIMUM_PRIORITY - priority + 1); 92 return (int) ( scheduler->maximum_priority - priority ); 122 93 } 123 94 -
cpukit/posix/src/mutexgetprioceiling.c
reec08ef r5a32c48 47 47 48 48 *prioceiling = _POSIX_Priority_From_core( 49 &_Scheduler_Table[ 0 ], 49 50 the_mutex->Mutex.priority_ceiling 50 51 ); -
cpukit/posix/src/mutexinit.c
reec08ef r5a32c48 21 21 #include <rtems/posix/muteximpl.h> 22 22 #include <rtems/posix/priorityimpl.h> 23 #include <rtems/score/schedulerimpl.h> 23 24 24 25 /** … … 116 117 } 117 118 118 if ( !_POSIX_Priority_Is_valid( prio_ceiling ) ) {119 if ( !_POSIX_Priority_Is_valid( scheduler, prio_ceiling ) ) { 119 120 return EINVAL; 120 121 } 121 122 122 priority = _POSIX_Priority_To_core( prio_ceiling );123 priority = _POSIX_Priority_To_core( scheduler, prio_ceiling ); 123 124 } 124 125 -
cpukit/posix/src/mutexsetprioceiling.c
reec08ef r5a32c48 32 32 ) 33 33 { 34 register POSIX_Mutex_Control *the_mutex; 35 Priority_Control the_priority; 36 int error; 34 POSIX_Mutex_Control *the_mutex; 35 const Scheduler_Control *scheduler; 36 int error; 37 int unlock_error; 37 38 38 39 if ( !old_ceiling ) 39 40 return EINVAL; 40 41 if ( !_POSIX_Priority_Is_valid( prioceiling ) )42 return EINVAL;43 44 the_priority = _POSIX_Priority_To_core( prioceiling );45 41 46 42 /* … … 57 53 _Assert( the_mutex != NULL ); 58 54 55 scheduler = &_Scheduler_Table[ 0 ]; 56 59 57 *old_ceiling = _POSIX_Priority_From_core( 58 scheduler, 60 59 the_mutex->Mutex.priority_ceiling 61 60 ); 62 the_mutex->Mutex.priority_ceiling = the_priority;63 61 64 error = pthread_mutex_unlock( mutex ); 65 _Assert( error == 0 ); 66 (void) error; 67 return 0; 62 if ( _POSIX_Priority_Is_valid( scheduler, prioceiling ) ) { 63 Priority_Control priority; 64 65 priority = _POSIX_Priority_To_core( scheduler, prioceiling ); 66 the_mutex->Mutex.priority_ceiling = priority; 67 68 error = 0; 69 } else { 70 error = EINVAL; 71 } 72 73 unlock_error = pthread_mutex_unlock( mutex ); 74 _Assert( unlock_error == 0 ); 75 (void) unlock_error; 76 return error; 68 77 } -
cpukit/posix/src/psxpriorityisvalid.c
reec08ef r5a32c48 31 31 32 32 bool _POSIX_Priority_Is_valid( 33 int priority 33 const Scheduler_Control *scheduler, 34 int priority 34 35 ) 35 36 { 36 return ((priority >= POSIX_SCHEDULER_MINIMUM_PRIORITY) && 37 (priority <= POSIX_SCHEDULER_MAXIMUM_PRIORITY)); 38 37 return priority >= POSIX_SCHEDULER_MINIMUM_PRIORITY 38 && (Priority_Control) priority < scheduler->maximum_priority; 39 39 } 40 40 -
cpukit/posix/src/pthread.c
reec08ef r5a32c48 38 38 #include <rtems/posix/config.h> 39 39 #include <rtems/posix/keyimpl.h> 40 #include <rtems/score/assert.h> 40 41 #include <rtems/score/cpusetimpl.h> 41 #include <rtems/score/ assert.h>42 #include <rtems/score/schedulerimpl.h> 42 43 43 44 Thread_Information _POSIX_Threads_Information; … … 183 184 _POSIX_Threads_Initialize_attributes( &api->Attributes ); 184 185 api->Attributes.schedparam.sched_priority = _POSIX_Priority_From_core( 186 _Scheduler_Get_own( created ), 185 187 created->current_priority 186 188 ); -
cpukit/posix/src/pthreadcreate.c
reec08ef r5a32c48 71 71 Thread_Control *the_thread; 72 72 Thread_Control *executing; 73 const Scheduler_Control *scheduler; 73 74 POSIX_API_Control *api; 74 75 int schedpolicy = SCHED_RR; … … 152 153 } 153 154 154 if ( !_POSIX_Priority_Is_valid( low_prio ) ) { 155 return EINVAL; 156 } 157 158 if ( !_POSIX_Priority_Is_valid( high_prio ) ) { 159 return EINVAL; 160 } 161 162 core_low_prio = _POSIX_Priority_To_core( low_prio ); 163 core_high_prio = _POSIX_Priority_To_core( high_prio ); 155 scheduler = _Scheduler_Get_own( executing ); 156 157 if ( !_POSIX_Priority_Is_valid( scheduler, low_prio ) ) { 158 return EINVAL; 159 } 160 161 if ( !_POSIX_Priority_Is_valid( scheduler, high_prio ) ) { 162 return EINVAL; 163 } 164 165 core_low_prio = _POSIX_Priority_To_core( scheduler, low_prio ); 166 core_high_prio = _POSIX_Priority_To_core( scheduler, high_prio ); 164 167 165 168 #if defined(RTEMS_SMP) -
cpukit/posix/src/pthreadgetschedparam.c
reec08ef r5a32c48 27 27 #include <rtems/posix/pthreadimpl.h> 28 28 #include <rtems/posix/priorityimpl.h> 29 #include <rtems/score/schedulerimpl.h> 29 30 #include <rtems/score/threadimpl.h> 30 31 … … 35 36 ) 36 37 { 37 Thread_Control *the_thread; 38 ISR_lock_Context lock_context; 39 POSIX_API_Control *api; 38 Thread_Control *the_thread; 39 ISR_lock_Context lock_context; 40 POSIX_API_Control *api; 41 const Scheduler_Control *scheduler; 42 Priority_Control priority; 40 43 41 44 if ( policy == NULL || param == NULL ) { … … 55 58 *policy = api->Attributes.schedpolicy; 56 59 *param = api->Attributes.schedparam; 57 param->sched_priority = _POSIX_Priority_From_core( 58 the_thread->real_priority59 );60 61 scheduler = _Scheduler_Get_own( the_thread ); 62 priority = the_thread->real_priority; 60 63 61 64 _Thread_Lock_release_default( the_thread, &lock_context ); 65 66 param->sched_priority = _POSIX_Priority_From_core( scheduler, priority ); 62 67 return 0; 63 68 } -
cpukit/posix/src/pthreadsetschedparam.c
reec08ef r5a32c48 29 29 #include <rtems/posix/priorityimpl.h> 30 30 #include <rtems/score/threadimpl.h> 31 #include <rtems/score/schedulerimpl.h> 31 32 32 33 typedef struct { … … 46 47 POSIX_Set_sched_param_context *context; 47 48 const struct sched_param *param; 49 const Scheduler_Control *scheduler; 48 50 POSIX_API_Control *api; 49 51 int low_prio; … … 55 57 context = arg; 56 58 param = context->param; 59 scheduler = _Scheduler_Get_own( the_thread ); 57 60 58 61 if ( context->policy == SCHED_SPORADIC ) { … … 64 67 } 65 68 66 if ( !_POSIX_Priority_Is_valid( low_prio ) ) {69 if ( !_POSIX_Priority_Is_valid( scheduler, low_prio ) ) { 67 70 context->error = EINVAL; 68 71 return false; 69 72 } 70 73 71 if ( !_POSIX_Priority_Is_valid( high_prio ) ) {74 if ( !_POSIX_Priority_Is_valid( scheduler, high_prio ) ) { 72 75 context->error = EINVAL; 73 76 return false; 74 77 } 75 78 76 core_low_prio = _POSIX_Priority_To_core( low_prio );77 core_high_prio = _POSIX_Priority_To_core( high_prio );79 core_low_prio = _POSIX_Priority_To_core( scheduler, low_prio ); 80 core_high_prio = _POSIX_Priority_To_core( scheduler, high_prio ); 78 81 79 82 *new_priority_p = core_high_prio; -
cpukit/posix/src/pthreadsetschedprio.c
reec08ef r5a32c48 17 17 #include <rtems/posix/threadsup.h> 18 18 #include <rtems/score/threadimpl.h> 19 #include <rtems/score/schedulerimpl.h> 19 20 20 21 typedef struct { … … 31 32 POSIX_Set_sched_prio_context *context; 32 33 int prio; 34 const Scheduler_Control *scheduler; 33 35 POSIX_API_Control *api; 34 36 Priority_Control current_priority; … … 37 39 context = arg; 38 40 prio = context->prio; 41 scheduler = _Scheduler_Get_own( the_thread ); 39 42 40 if ( !_POSIX_Priority_Is_valid( prio ) ) {43 if ( !_POSIX_Priority_Is_valid( scheduler, prio ) ) { 41 44 context->error = EINVAL; 42 45 return false; 43 46 } 44 47 45 new_priority = _POSIX_Priority_To_core( prio );48 new_priority = _POSIX_Priority_To_core( scheduler, prio ); 46 49 *new_priority_p = new_priority; 47 50
Note: See TracChangeset
for help on using the changeset viewer.