4.115
Last change
on this file since 701dd96f was
701dd96f,
checked in by Sebastian Huber <sebastian.huber@…>, on 06/12/14 at 12:37:57
|
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.
|
-
Property mode set to
100644
|
File size:
1.1 KB
|
Line | |
---|
1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief RTEMS Task Wake After |
---|
5 | * @ingroup ClassicTasks |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-1999. |
---|
10 | * On-Line Applications Research Corporation (OAR). |
---|
11 | * |
---|
12 | * The license and distribution terms for this file may be |
---|
13 | * found in the file LICENSE in this distribution or at |
---|
14 | * http://www.rtems.org/license/LICENSE. |
---|
15 | */ |
---|
16 | |
---|
17 | #if HAVE_CONFIG_H |
---|
18 | #include "config.h" |
---|
19 | #endif |
---|
20 | |
---|
21 | #include <rtems/rtems/tasks.h> |
---|
22 | #include <rtems/score/threadimpl.h> |
---|
23 | #include <rtems/score/watchdogimpl.h> |
---|
24 | |
---|
25 | rtems_status_code rtems_task_wake_after( |
---|
26 | rtems_interval ticks |
---|
27 | ) |
---|
28 | { |
---|
29 | /* |
---|
30 | * It is critical to obtain the executing thread after thread dispatching is |
---|
31 | * disabled on SMP configurations. |
---|
32 | */ |
---|
33 | Thread_Control *executing; |
---|
34 | |
---|
35 | _Thread_Disable_dispatch(); |
---|
36 | executing = _Thread_Executing; |
---|
37 | |
---|
38 | if ( ticks == 0 ) { |
---|
39 | _Thread_Yield( executing ); |
---|
40 | } else { |
---|
41 | _Thread_Set_state( executing, STATES_DELAYING ); |
---|
42 | _Watchdog_Initialize( |
---|
43 | &executing->Timer, |
---|
44 | _Thread_Delay_ended, |
---|
45 | executing->Object.id, |
---|
46 | NULL |
---|
47 | ); |
---|
48 | _Watchdog_Insert_ticks( &executing->Timer, ticks ); |
---|
49 | } |
---|
50 | _Thread_Enable_dispatch(); |
---|
51 | return RTEMS_SUCCESSFUL; |
---|
52 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.