OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [exec/] [rtems/] [src/] [eventsurrender.c] - Blame information for rev 173

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
2
 *  Event Manager
3
 *
4
 *  COPYRIGHT (c) 1989-1999.
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.OARcorp.com/rtems/license.html.
10
 *
11
 *  $Id: eventsurrender.c,v 1.2 2001-09-27 11:59:19 chris Exp $
12
 */
13
 
14
#include <rtems/system.h>
15
#include <rtems/rtems/status.h>
16
#include <rtems/rtems/event.h>
17
#include <rtems/score/isr.h>
18
#include <rtems/score/object.h>
19
#include <rtems/rtems/options.h>
20
#include <rtems/score/states.h>
21
#include <rtems/score/thread.h>
22
#include <rtems/rtems/tasks.h>
23
 
24
/*PAGE
25
 *
26
 *  _Event_Surrender
27
 *
28
 *  This routines remove a thread from the specified threadq.
29
 *
30
 *  Input parameters:
31
 *    the_thread - pointer to thread to be dequeued
32
 *
33
 *  Output parameters: NONE
34
 *
35
 *  INTERRUPT LATENCY:
36
 *    before flash
37
 *    after flash
38
 *    check sync
39
 */
40
 
41
void _Event_Surrender(
42
  Thread_Control *the_thread
43
)
44
{
45
  ISR_Level           level;
46
  rtems_event_set     pending_events;
47
  rtems_event_set     event_condition;
48
  rtems_event_set     seized_events;
49
  rtems_option        option_set;
50
  RTEMS_API_Control  *api;
51
 
52
  api = the_thread->API_Extensions[ THREAD_API_RTEMS ];
53
 
54
  option_set = (rtems_option) the_thread->Wait.option;
55
 
56
  _ISR_Disable( level );
57
  pending_events  = api->pending_events;
58
  event_condition = (rtems_event_set) the_thread->Wait.count;
59
 
60
  seized_events = _Event_sets_Get( pending_events, event_condition );
61
 
62
  if ( !_Event_sets_Is_empty( seized_events ) ) {
63
    if ( _States_Is_waiting_for_event( the_thread->current_state ) ) {
64
      if ( seized_events == event_condition || _Options_Is_any( option_set ) ) {
65
        api->pending_events =
66
           _Event_sets_Clear( pending_events, seized_events );
67
        *(rtems_event_set *)the_thread->Wait.return_argument = seized_events;
68
 
69
        _ISR_Flash( level );
70
 
71
        if ( !_Watchdog_Is_active( &the_thread->Timer ) ) {
72
          _ISR_Enable( level );
73
          _Thread_Unblock( the_thread );
74
        }
75
        else {
76
          _Watchdog_Deactivate( &the_thread->Timer );
77
          _ISR_Enable( level );
78
          (void) _Watchdog_Remove( &the_thread->Timer );
79
          _Thread_Unblock( the_thread );
80
        }
81
        return;
82
      }
83
    }
84
 
85
    switch ( _Event_Sync_state ) {
86
      case EVENT_SYNC_SYNCHRONIZED:
87
      case EVENT_SYNC_SATISFIED:
88
        break;
89
 
90
      case EVENT_SYNC_NOTHING_HAPPENED:
91
      case EVENT_SYNC_TIMEOUT:
92
        if ( !_Thread_Is_executing( the_thread ) )
93
          break;
94
 
95
        if ( seized_events == event_condition || _Options_Is_any(option_set) ) {
96
          api->pending_events =
97
               _Event_sets_Clear( pending_events,seized_events );
98
          *(rtems_event_set *)the_thread->Wait.return_argument = seized_events;
99
          _Event_Sync_state = EVENT_SYNC_SATISFIED;
100
        }
101
        break;
102
    }
103
  }
104
  _ISR_Enable( level );
105
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.