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:
783 bytes
|
Line | |
---|
1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Thread Yield |
---|
5 | * |
---|
6 | * @ingroup ScoreThread |
---|
7 | */ |
---|
8 | |
---|
9 | /* |
---|
10 | * Copyright (c) 2014 embedded brains GmbH. All rights reserved. |
---|
11 | * |
---|
12 | * embedded brains GmbH |
---|
13 | * Dornierstr. 4 |
---|
14 | * 82178 Puchheim |
---|
15 | * Germany |
---|
16 | * <rtems@embedded-brains.de> |
---|
17 | * |
---|
18 | * The license and distribution terms for this file may be |
---|
19 | * found in the file LICENSE in this distribution or at |
---|
20 | * http://www.rtems.org/license/LICENSE. |
---|
21 | */ |
---|
22 | |
---|
23 | #if HAVE_CONFIG_H |
---|
24 | #include "config.h" |
---|
25 | #endif |
---|
26 | |
---|
27 | #include <rtems/score/threadimpl.h> |
---|
28 | #include <rtems/score/schedulerimpl.h> |
---|
29 | |
---|
30 | void _Thread_Yield( Thread_Control *executing ) |
---|
31 | { |
---|
32 | ISR_Level level; |
---|
33 | |
---|
34 | _ISR_Disable( level ); |
---|
35 | |
---|
36 | if ( _States_Is_ready( executing->current_state ) ) { |
---|
37 | _Scheduler_Yield( _Scheduler_Get( executing ), executing ); |
---|
38 | } |
---|
39 | |
---|
40 | _ISR_Enable( level ); |
---|
41 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.