Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:44

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /*
0004  *  COPYRIGHT (c) 1989-2011.
0005  *  On-Line Applications Research Corporation (OAR).
0006  *
0007  * Redistribution and use in source and binary forms, with or without
0008  * modification, are permitted provided that the following conditions
0009  * are met:
0010  * 1. Redistributions of source code must retain the above copyright
0011  *    notice, this list of conditions and the following disclaimer.
0012  * 2. Redistributions in binary form must reproduce the above copyright
0013  *    notice, this list of conditions and the following disclaimer in the
0014  *    documentation and/or other materials provided with the distribution.
0015  *
0016  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0017  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0018  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0019  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0020  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0021  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0022  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0023  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0024  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0025  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0026  * POSSIBILITY OF SUCH DAMAGE.
0027  */
0028 
0029 #ifdef HAVE_CONFIG_H
0030 #include "config.h"
0031 #endif
0032 
0033 #include "system.h"
0034 
0035 rtems_task Task_2(
0036   rtems_task_argument argument
0037 )
0038 {
0039   rtems_event_set   eventout;
0040   rtems_time_of_day time;
0041   rtems_status_code status;
0042 
0043   status = rtems_task_wake_after( rtems_clock_get_ticks_per_second() );
0044   directive_failed( status, "rtems_task_wake_after" );
0045 
0046   puts( "TA2 - rtems_event_receive - waiting forever on RTEMS_EVENT_16" );
0047   status = rtems_event_receive(
0048     RTEMS_EVENT_16,
0049     RTEMS_DEFAULT_OPTIONS,
0050     RTEMS_NO_TIMEOUT,
0051     &eventout
0052   );
0053   directive_failed( status, "rtems_event_receive" );
0054   printf(
0055     "TA2 - RTEMS_EVENT_16 received - eventout => %08" PRIxrtems_event_set "\n",
0056      eventout
0057   );
0058 
0059   puts(
0060     "TA2 - rtems_event_send - send RTEMS_EVENT_14 and RTEMS_EVENT_15 to TA1"
0061   );
0062   status = rtems_event_send( Task_id[ 1 ], RTEMS_EVENT_14 | RTEMS_EVENT_15 );
0063   directive_failed( status, "rtems_event_send" );
0064 
0065   puts(
0066     "TA2 - rtems_event_receive - RTEMS_EVENT_17 or "
0067       "RTEMS_EVENT_18 - forever and ANY"
0068   );
0069   status = rtems_event_receive(
0070     RTEMS_EVENT_17 | RTEMS_EVENT_18,
0071     RTEMS_EVENT_ANY,
0072     RTEMS_NO_TIMEOUT,
0073     &eventout
0074   );
0075   directive_failed( status, "rtems_event_receive" );
0076   printf(
0077     "TA2 - RTEMS_EVENT_17 or RTEMS_EVENT_18 received - "
0078       "eventout => %08" PRIxrtems_event_set "\n",
0079     eventout
0080   );
0081 
0082   puts( "TA2 - rtems_event_send - send RTEMS_EVENT_14 to TA1" );
0083   status = rtems_event_send( Task_id[ 1 ], RTEMS_EVENT_14 );
0084   directive_failed( status, "rtems_event_send" );
0085 
0086   build_time( &time, 2, 12, 1988, 8, 15, 0, 0 );
0087   print_time( "TA2 - rtems_clock_set - ", &time, "\n" );
0088   status = rtems_clock_set( &time );
0089   directive_failed( status, "TA2 rtems_clock_set" );
0090 
0091   time.second += 4;
0092   puts(
0093     "TA2 - rtems_event_send - sending RTEMS_EVENT_10 to self after 4 seconds"
0094   );
0095   status = rtems_timer_fire_when(
0096     Timer_id[ 5 ],
0097     &time,
0098     TA2_send_10_to_self,
0099     NULL
0100   );
0101   directive_failed( status, "rtems_timer_fire_when after 4 seconds" );
0102 
0103   puts( "TA2 - rtems_event_receive - waiting forever on RTEMS_EVENT_10" );
0104   status = rtems_event_receive(
0105     RTEMS_EVENT_10,
0106     RTEMS_DEFAULT_OPTIONS,
0107     RTEMS_NO_TIMEOUT,
0108     &eventout
0109   );
0110   directive_failed( status, "rtems_event_receive" );
0111 
0112   status = rtems_clock_get_tod( &time );
0113   directive_failed( status, "rtems_clock_get_tod" );
0114 
0115   printf(
0116     "TA2 - RTEMS_EVENT_10 received - eventout => %08" PRIxrtems_event_set "\n",
0117      eventout
0118   );
0119   print_time( "TA2 - rtems_clock_get_tod - ", &time, "\n" );
0120 
0121   puts( "TA2 - rtems_event_receive - RTEMS_PENDING_EVENTS" );
0122   status = rtems_event_receive(
0123     RTEMS_PENDING_EVENTS,
0124     RTEMS_DEFAULT_OPTIONS,
0125     RTEMS_NO_TIMEOUT,
0126     &eventout
0127   );
0128   directive_failed( status, "rtems_event_receive" );
0129   printf( "TA2 - eventout => %08" PRIxrtems_event_set "\n", eventout );
0130 
0131   puts( "TA2 - rtems_event_receive - RTEMS_EVENT_19 - RTEMS_NO_WAIT" );
0132   status = rtems_event_receive(
0133     RTEMS_EVENT_19,
0134     RTEMS_NO_WAIT,
0135     RTEMS_NO_TIMEOUT,
0136     &eventout
0137   );
0138   directive_failed( status, "rtems_event_receive" );
0139   printf(
0140     "TA2 - RTEMS_EVENT_19 received - eventout => %08" PRIxrtems_event_set "\n",
0141      eventout
0142   );
0143 
0144   puts( "TA2 - rtems_task_delete - deletes self" );
0145   status = rtems_task_delete( Task_id[ 2 ] );
0146   directive_failed( status, "rtems_task_delete of TA2" );
0147 }