5
Last change
on this file since 66cb142 was
1fcac5ad,
checked in by Sebastian Huber <sebastian.huber@…>, on 07/25/16 at 14:35:37
|
score: Turn thread lock into thread wait lock
The _Thread_Lock_acquire() function had a potentially infinite run-time
due to the lack of fairness at atomic operations level.
Update #2412.
Update #2556.
Update #2765.
|
-
Property mode set to
100644
|
File size:
1.5 KB
|
Line | |
---|
1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Constant used to receive the set of currently pending events in |
---|
5 | * @ingroup ClassicEventSet Event Set |
---|
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/eventimpl.h> |
---|
22 | #include <rtems/rtems/tasks.h> |
---|
23 | #include <rtems/score/statesimpl.h> |
---|
24 | #include <rtems/score/threadimpl.h> |
---|
25 | |
---|
26 | rtems_status_code rtems_event_receive( |
---|
27 | rtems_event_set event_in, |
---|
28 | rtems_option option_set, |
---|
29 | rtems_interval ticks, |
---|
30 | rtems_event_set *event_out |
---|
31 | ) |
---|
32 | { |
---|
33 | rtems_status_code sc; |
---|
34 | |
---|
35 | if ( event_out != NULL ) { |
---|
36 | ISR_lock_Context lock_context; |
---|
37 | Thread_Control *executing; |
---|
38 | RTEMS_API_Control *api; |
---|
39 | Event_Control *event; |
---|
40 | |
---|
41 | executing = _Thread_Wait_acquire_default_for_executing( &lock_context ); |
---|
42 | api = executing->API_Extensions[ THREAD_API_RTEMS ]; |
---|
43 | event = &api->Event; |
---|
44 | |
---|
45 | if ( !_Event_sets_Is_empty( event_in ) ) { |
---|
46 | sc = _Event_Seize( |
---|
47 | event_in, |
---|
48 | option_set, |
---|
49 | ticks, |
---|
50 | event_out, |
---|
51 | executing, |
---|
52 | event, |
---|
53 | THREAD_WAIT_CLASS_EVENT, |
---|
54 | STATES_WAITING_FOR_EVENT, |
---|
55 | &lock_context |
---|
56 | ); |
---|
57 | } else { |
---|
58 | *event_out = event->pending_events; |
---|
59 | _Thread_Wait_release_default( executing, &lock_context ); |
---|
60 | sc = RTEMS_SUCCESSFUL; |
---|
61 | } |
---|
62 | } else { |
---|
63 | sc = RTEMS_INVALID_ADDRESS; |
---|
64 | } |
---|
65 | |
---|
66 | return sc; |
---|
67 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.