summaryrefslogtreecommitdiffstats
path: root/cpukit/posix/src/pthreadsetschedparam.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-04-06 16:26:22 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-04-12 07:36:14 +0200
commit9555341f0fc309243e1d92f95e4278a7b820f485 (patch)
tree74c17533f5d7205a93bc4d993fda5de47d043fe9 /cpukit/posix/src/pthreadsetschedparam.c
parentposix: Use proper lock for sigaction() (diff)
downloadrtems-9555341f0fc309243e1d92f95e4278a7b820f485.tar.bz2
posix: Use a dedicated lock for scheduler changes
Update #2555.
Diffstat (limited to 'cpukit/posix/src/pthreadsetschedparam.c')
-rw-r--r--cpukit/posix/src/pthreadsetschedparam.c34
1 files changed, 20 insertions, 14 deletions
diff --git a/cpukit/posix/src/pthreadsetschedparam.c b/cpukit/posix/src/pthreadsetschedparam.c
index c9560f59ac..57a2bc8ce1 100644
--- a/cpukit/posix/src/pthreadsetschedparam.c
+++ b/cpukit/posix/src/pthreadsetschedparam.c
@@ -44,7 +44,8 @@ int pthread_setschedparam(
Objects_Locations location;
int rc;
Priority_Control unused;
- ISR_Level level;
+ ISR_lock_Context lock_context;
+ Priority_Control new_priority;
/*
* Check all the parameters
@@ -70,10 +71,10 @@ int pthread_setschedparam(
case OBJECTS_LOCAL:
api = the_thread->API_Extensions[ THREAD_API_POSIX ];
+ _POSIX_Threads_Scheduler_acquire( api, &lock_context );
+
if ( api->schedpolicy == SCHED_SPORADIC ) {
- _ISR_Disable( level );
_Watchdog_Per_CPU_remove_relative( &api->Sporadic_timer );
- _ISR_Enable( level );
}
api->schedpolicy = policy;
@@ -84,26 +85,31 @@ int pthread_setschedparam(
the_thread->budget_algorithm = budget_algorithm;
the_thread->budget_callout = budget_callout;
- switch ( api->schedpolicy ) {
+ switch ( policy ) {
case SCHED_OTHER:
case SCHED_FIFO:
case SCHED_RR:
the_thread->cpu_time_budget =
rtems_configuration_get_ticks_per_timeslice();
-
- _Thread_Set_priority(
- the_thread,
- _POSIX_Priority_To_core( api->schedparam.sched_priority ),
- &unused,
- true
- );
+ new_priority =
+ _POSIX_Priority_To_core( api->schedparam.sched_priority );
break;
case SCHED_SPORADIC:
api->ss_high_priority = api->schedparam.sched_priority;
- _ISR_Disable( level );
- _Watchdog_Per_CPU_remove_relative( &api->Sporadic_timer );
- _ISR_Enable( level );
+ break;
+ }
+
+ _POSIX_Threads_Scheduler_release( api, &lock_context );
+
+ switch ( policy ) {
+ case SCHED_OTHER:
+ case SCHED_FIFO:
+ case SCHED_RR:
+ _Thread_Set_priority( the_thread, new_priority, &unused, true );
+ break;
+
+ case SCHED_SPORADIC:
_POSIX_Threads_Sporadic_budget_TSR( &api->Sporadic_timer );
break;
}