source: rtems/cpukit/rtems/src/event.c @ ea9d7db

4.104.114.84.95
Last change on this file since ea9d7db was ea9d7db, checked in by Joel Sherrill <joel.sherrill@…>, on Aug 4, 1995 at 10:17:48 PM

split out event support functions in anticipation of making a handler

  • Property mode set to 100644
File size: 2.5 KB
Line 
1/*
2 *  Event Manager
3 *
4 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
5 *  On-Line Applications Research Corporation (OAR).
6 *  All rights assigned to U.S. Government, 1994.
7 *
8 *  This material may be reproduced by or for the U.S. Government pursuant
9 *  to the copyright license under the clause at DFARS 252.227-7013.  This
10 *  notice must appear in all copies of this file and its derivatives.
11 *
12 *  $Id$
13 */
14
15#include <rtems/system.h>
16#include <rtems/event.h>
17#include <rtems/isr.h>
18#include <rtems/object.h>
19#include <rtems/options.h>
20#include <rtems/states.h>
21#include <rtems/thread.h>
22
23/*PAGE
24 *
25 *  rtems_event_send
26 *
27 *  This directive allows a thread send an event set to another thread.
28 *
29 *  Input parameters:
30 *    id    - thread id
31 *    event - event set
32 *
33 *  Output parameters:
34 *    RTEMS_SUCCESSFUL - if successful
35 *    error code - if unsuccessful
36 */
37
38rtems_status_code rtems_event_send(
39  Objects_Id         id,
40  rtems_event_set event_in
41)
42{
43  register Thread_Control *the_thread;
44  Objects_Locations        location;
45
46  the_thread = _Thread_Get( id, &location );
47  switch ( location ) {
48    case OBJECTS_ERROR:
49      return( RTEMS_INVALID_ID );
50    case OBJECTS_REMOTE:
51      return(
52        _Event_MP_Send_request_packet(
53          EVENT_MP_SEND_REQUEST,
54          id,
55          event_in
56        )
57      );
58    case OBJECTS_LOCAL:
59      _Event_sets_Post( event_in, &the_thread->pending_events );
60      _Event_Surrender( the_thread );
61      _Thread_Enable_dispatch();
62      return( RTEMS_SUCCESSFUL );
63  }
64
65  return( RTEMS_INTERNAL_ERROR );   /* unreached - only to remove warnings */
66}
67
68/*PAGE
69 *
70 *  rtems_event_receive
71 *
72 *  This directive allows a thread to receive a set of events.
73 *
74 *  Input parameters:
75 *    event_in   - input event condition
76 *    option_set - options
77 *    ticks      - number of ticks to wait (0 means wait forever)
78 *    event_out  - pointer to output event set
79 *
80 *  Output parameters:
81 *    event out         - event set
82 *    RTEMS_SUCCESSFUL - if successful
83 *    error code        - if unsuccessful
84 */
85
86rtems_status_code rtems_event_receive(
87  rtems_event_set  event_in,
88  rtems_option     option_set,
89  rtems_interval   ticks,
90  rtems_event_set *event_out
91)
92{
93  if ( _Event_sets_Is_empty( event_in ) ) {
94    *event_out = _Thread_Executing->pending_events;
95    return( RTEMS_SUCCESSFUL );
96  }
97
98  _Thread_Disable_dispatch();
99  _Event_Seize( event_in, option_set, ticks );
100  _Thread_Enable_dispatch();
101  *event_out = _Thread_Executing->events_out;
102  return( _Thread_Executing->Wait.return_code );
103}
Note: See TracBrowser for help on using the repository browser.