summaryrefslogtreecommitdiffstats
path: root/cpukit/rtems/src/tasksetscheduler.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-07-25 16:35:37 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-07-27 10:55:30 +0200
commit1fcac5adc5ed38fb88ce4c6d24b2ca2e27e3cd10 (patch)
tree7d2fed265befa680902ff146acb3305a360f9116 /cpukit/rtems/src/tasksetscheduler.c
parentscore: Priority inherit thread queue operations (diff)
downloadrtems-1fcac5adc5ed38fb88ce4c6d24b2ca2e27e3cd10.tar.bz2
score: Turn thread lock into thread wait lock
The _Thread_Lock_acquire() function had a potentially infinite run-time due to the lack of fairness at atomic operations level. Update #2412. Update #2556. Update #2765.
Diffstat (limited to 'cpukit/rtems/src/tasksetscheduler.c')
-rw-r--r--cpukit/rtems/src/tasksetscheduler.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/cpukit/rtems/src/tasksetscheduler.c b/cpukit/rtems/src/tasksetscheduler.c
index 175f235f02..0ff74d9c97 100644
--- a/cpukit/rtems/src/tasksetscheduler.c
+++ b/cpukit/rtems/src/tasksetscheduler.c
@@ -28,10 +28,9 @@ rtems_status_code rtems_task_set_scheduler(
{
const Scheduler_Control *scheduler;
Thread_Control *the_thread;
- ISR_lock_Context lock_context;
- ISR_lock_Context state_lock_context;
+ Thread_queue_Context queue_context;
+ ISR_lock_Context state_context;
Per_CPU_Control *cpu_self;
- void *lock;
bool valid;
Priority_Control core_priority;
Status_Control status;
@@ -45,7 +44,7 @@ rtems_status_code rtems_task_set_scheduler(
return RTEMS_INVALID_PRIORITY;
}
- the_thread = _Thread_Get( task_id, &lock_context );
+ the_thread = _Thread_Get( task_id, &queue_context.Lock_context );
if ( the_thread == NULL ) {
#if defined(RTEMS_MULTIPROCESSING)
@@ -57,16 +56,15 @@ rtems_status_code rtems_task_set_scheduler(
return RTEMS_INVALID_ID;
}
- cpu_self = _Thread_Dispatch_disable_critical( &lock_context );
- _ISR_lock_ISR_enable( &lock_context );
+ cpu_self = _Thread_Dispatch_disable_critical( &queue_context.Lock_context );
- lock = _Thread_Lock_acquire( the_thread, &lock_context );
- _Thread_State_acquire_critical( the_thread, &state_lock_context );
+ _Thread_Wait_acquire_critical( the_thread, &queue_context );
+ _Thread_State_acquire_critical( the_thread, &state_context );
status = _Scheduler_Set( scheduler, the_thread, core_priority );
- _Thread_State_release_critical( the_thread, &state_lock_context );
- _Thread_Lock_release( lock, &lock_context );
+ _Thread_State_release_critical( the_thread, &state_context );
+ _Thread_Wait_release( the_thread, &queue_context );
_Thread_Dispatch_enable( cpu_self );
return _Status_Get( status );
}