Ignore:
Timestamp:
Jun 12, 2014, 12:37:57 PM (5 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
a80c3b6
Parents:
970aa80
git-author:
Sebastian Huber <sebastian.huber@…> (06/12/14 12:37:57)
git-committer:
Sebastian Huber <sebastian.huber@…> (06/12/14 14:13:26)
Message:

score: PR2181: Add _Thread_Yield()

The _Scheduler_Yield() was called by the executing thread with thread
dispatching disabled and interrupts enabled. The rtems_task_suspend()
is explicitly allowed in ISRs:

http://rtems.org/onlinedocs/doc-current/share/rtems/html/c_user/Interrupt-Manager-Directives-Allowed-from-an-ISR.html#Interrupt-Manager-Directives-Allowed-from-an-ISR

Unlike the other scheduler operations the locking was performed inside
the operation. This lead to the following race condition. Suppose a
ISR suspends the executing thread right before the yield scheduler
operation. Now the executing thread is not longer in the set of ready
threads. The typical scheduler operations did not check the thread
state and will now extract the thread again and enqueue it. This
corrupted data structures.

Add _Thread_Yield() and do the scheduler yield operation with interrupts
disabled. This has a negligible effect on the interrupt latency.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/rtems/src/taskwakeafter.c

    r970aa80 r701dd96f  
    2121#include <rtems/rtems/tasks.h>
    2222#include <rtems/score/threadimpl.h>
    23 #include <rtems/score/schedulerimpl.h>
    2423#include <rtems/score/watchdogimpl.h>
    2524
     
    3837
    3938    if ( ticks == 0 ) {
    40       _Scheduler_Yield( _Scheduler_Get( executing ), executing );
     39      _Thread_Yield( executing );
    4140    } else {
    4241      _Thread_Set_state( executing, STATES_DELAYING );
Note: See TracChangeset for help on using the changeset viewer.