source: rtems/cpukit/rtems/src/eventtimeout.c @ 39691cd

4.10
Last change on this file since 39691cd was 39691cd, checked in by Sebastian Huber <sebastian.huber@…>, on 01/02/13 at 17:56:35

rtems: Critical fix for events

Commit 4b45c1393ce4ee3e1c2762ef3145d2bd6b5b38da marked a test in
_Event_Timeout() as debug only. This test is required also in non-debug
configurations since otherwise state corruption can happen. A revised
test sptests/spintrcritical10 checks the relevant sequences.

  • Property mode set to 100644
File size: 2.6 KB
Line 
1/*
2 *  Event Manager
3 *
4 *  COPYRIGHT (c) 1989-2008.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 *
11 *  $Id$
12 */
13
14#if HAVE_CONFIG_H
15#include "config.h"
16#endif
17
18#include <rtems/system.h>
19#include <rtems/rtems/status.h>
20#include <rtems/rtems/event.h>
21#include <rtems/score/isr.h>
22#include <rtems/score/object.h>
23#include <rtems/rtems/options.h>
24#include <rtems/score/states.h>
25#include <rtems/score/thread.h>
26#include <rtems/rtems/tasks.h>
27
28/*PAGE
29 *
30 *  _Event_Timeout
31 *
32 *  This routine processes a thread which timeouts while waiting to
33 *  receive an event_set. It is called by the watchdog handler.
34 *
35 *  Input parameters:
36 *    id - thread id
37 *
38 *  Output parameters: NONE
39 */
40
41void _Event_Timeout(
42  Objects_Id  id,
43  void       *ignored
44)
45{
46  Thread_Control    *the_thread;
47  Objects_Locations  location;
48  ISR_Level          level;
49
50  the_thread = _Thread_Get( id, &location );
51  switch ( location ) {
52
53    case OBJECTS_LOCAL:
54
55      /*
56       *  If the event manager is not synchronized, then it is either
57       *  "nothing happened", "timeout", or "satisfied".   If the_thread
58       *  is the executing thread, then it is in the process of blocking
59       *  and it is the thread which is responsible for the synchronization
60       *  process.
61       *
62       *  If it is not satisfied, then it is "nothing happened" and
63       *  this is the "timeout" transition.  After a request is satisfied,
64       *  a timeout is not allowed to occur.
65       */
66      _ISR_Disable( level );
67        /*
68         * Verify that the thread is still waiting for the event condition.
69         * This test is necessary to avoid state corruption if the timeout
70         * happens after the event condition is satisfied in
71         * _Event_Surrender().  A satisfied event condition is indicated with
72         * count set to zero.
73         */
74        if ( !the_thread->Wait.count ) {
75          _Thread_Unnest_dispatch();
76          _ISR_Enable( level );
77          return;
78        }
79
80        the_thread->Wait.count = 0;
81        if ( _Thread_Is_executing( the_thread ) ) {
82          if ( _Event_Sync_state == THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED )
83            _Event_Sync_state = THREAD_BLOCKING_OPERATION_TIMEOUT;
84        }
85
86        the_thread->Wait.return_code = RTEMS_TIMEOUT;
87      _ISR_Enable( level );
88      _Thread_Unblock( the_thread );
89      _Thread_Unnest_dispatch();
90      break;
91
92#if defined(RTEMS_MULTIPROCESSING)
93    case OBJECTS_REMOTE:  /* impossible */
94#endif
95    case OBJECTS_ERROR:
96      break;
97  }
98}
Note: See TracBrowser for help on using the repository browser.