diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2013-06-10 16:15:46 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2013-06-14 16:26:08 +0200 |
commit | 6eba7c857b9e72bc4ed8e55f0c9538c45631484f (patch) | |
tree | 09847feda8d2183412ab57d59602b3f08481d2ae /cpukit/posix/src | |
parent | scheduler: Add start idle thread operation (diff) | |
download | rtems-6eba7c857b9e72bc4ed8e55f0c9538c45631484f.tar.bz2 |
scheduler: Specify thread of yield operation
The yielding thread of the yield operation is now specified by a
parameter. The tick operation may be performed for each executing
thread in a SMP configuration.
Diffstat (limited to 'cpukit/posix/src')
-rw-r--r-- | cpukit/posix/src/nanosleep.c | 21 | ||||
-rw-r--r-- | cpukit/posix/src/sched_yield.c | 2 |
2 files changed, 15 insertions, 8 deletions
diff --git a/cpukit/posix/src/nanosleep.c b/cpukit/posix/src/nanosleep.c index b59b9934b0..7d37480218 100644 --- a/cpukit/posix/src/nanosleep.c +++ b/cpukit/posix/src/nanosleep.c @@ -39,6 +39,12 @@ int nanosleep( struct timespec *rmtp ) { + /* + * It is critical to obtain the executing thread after thread dispatching is + * disabled on SMP configurations. + */ + Thread_Control *executing; + Watchdog_Interval ticks; @@ -61,7 +67,8 @@ int nanosleep( if ( !ticks ) { _Thread_Disable_dispatch(); - _Scheduler_Yield(); + executing = _Thread_Executing; + _Scheduler_Yield( executing ); _Thread_Enable_dispatch(); if ( rmtp ) { rmtp->tv_sec = 0; @@ -74,24 +81,24 @@ int nanosleep( * Block for the desired amount of time */ _Thread_Disable_dispatch(); + executing = _Thread_Executing; _Thread_Set_state( - _Thread_Executing, + executing, STATES_DELAYING | STATES_INTERRUPTIBLE_BY_SIGNAL ); _Watchdog_Initialize( - &_Thread_Executing->Timer, + &executing->Timer, _Thread_Delay_ended, - _Thread_Executing->Object.id, + executing->Object.id, NULL ); - _Watchdog_Insert_ticks( &_Thread_Executing->Timer, ticks ); + _Watchdog_Insert_ticks( &executing->Timer, ticks ); _Thread_Enable_dispatch(); /* calculate time remaining */ if ( rmtp ) { - ticks -= - _Thread_Executing->Timer.stop_time - _Thread_Executing->Timer.start_time; + ticks -= executing->Timer.stop_time - executing->Timer.start_time; _Timespec_From_ticks( ticks, rmtp ); diff --git a/cpukit/posix/src/sched_yield.c b/cpukit/posix/src/sched_yield.c index 207cbb286a..d9e5d9b852 100644 --- a/cpukit/posix/src/sched_yield.c +++ b/cpukit/posix/src/sched_yield.c @@ -32,7 +32,7 @@ int sched_yield( void ) { _Thread_Disable_dispatch(); - _Scheduler_Yield(); + _Scheduler_Yield( _Thread_Executing ); _Thread_Enable_dispatch(); return 0; } |