source: rtems/cpukit/rtems/src/eventtimeout.c @ 3168deaa

4.104.114.95
Last change on this file since 3168deaa was 3168deaa, checked in by Joel Sherrill <joel.sherrill@…>, on 01/22/08 at 18:28:53

2008-01-22 Joel Sherrill <joel.sherrill@…>

  • rtems/include/rtems/rtems/event.h, rtems/inline/rtems/rtems/eventset.inl, rtems/src/event.c, rtems/src/eventseize.c, rtems/src/eventsurrender.c, rtems/src/eventtimeout.c, score/Makefile.am, score/preinstall.am, score/include/rtems/score/interr.h, score/include/rtems/score/thread.h, score/include/rtems/score/threadq.h, score/include/rtems/score/tqdata.h, score/inline/rtems/score/threadq.inl, score/inline/rtems/score/tqdata.inl, score/src/threadq.c, score/src/threadqdequeue.c, score/src/threadqdequeuefifo.c, score/src/threadqdequeuepriority.c, score/src/threadqenqueue.c, score/src/threadqenqueuefifo.c, score/src/threadqenqueuepriority.c, score/src/threadqextract.c, score/src/threadqextractfifo.c, score/src/threadqextractpriority.c, score/src/threadqextractwithproxy.c, score/src/threadqfirst.c, score/src/threadqfirstfifo.c, score/src/threadqfirstpriority.c, score/src/threadqflush.c, score/src/threadqrequeue.c, score/src/threadqtimeout.c: Refactor thread queue enqueue and event blocking synchronization critical sections. This resulted in three copies of essentially the same hard to test critical section code becoming the one shared routine _Thread_blocking_operation_Cancel. In addition, the thread queue and event code now share a common synchronization enumerated type. Along the way, switches were reworked to eliminate dead code generated by gcc and comments and copyrights were updated.
  • score/include/rtems/score/threadsync.h, score/src/threadblockingoperationcancel.c: New files.
  • Property mode set to 100644
File size: 2.5 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
67
68      _ISR_Disable( level );
69        if ( !the_thread->Wait.count ) {  /* verify thread is waiting */
70          _Thread_Unnest_dispatch();
71          _ISR_Enable( level );
72          return;
73        }
74
75        the_thread->Wait.count = 0;
76        if ( _Thread_Is_executing( the_thread ) ) {
77          Thread_blocking_operation_States sync = _Event_Sync_state;
78          if ( (sync == THREAD_BLOCKING_OPERATION_SYNCHRONIZED) ||
79               (sync == THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED) ) {
80            _Event_Sync_state = THREAD_BLOCKING_OPERATION_TIMEOUT;
81          }
82        }
83
84        the_thread->Wait.return_code = RTEMS_TIMEOUT;
85      _ISR_Enable( level );
86      _Thread_Unblock( the_thread );
87      _Thread_Unnest_dispatch();
88      break;
89
90#if defined(RTEMS_MULTIPROCESSING)
91    case OBJECTS_REMOTE:  /* impossible */
92#endif
93    case OBJECTS_ERROR:
94      break;
95  }
96}
Note: See TracBrowser for help on using the repository browser.