source: rtems/c/src/tests/psxtests/psx04/task3.c @ 60b791ad

4.104.114.84.95
Last change on this file since 60b791ad was 60b791ad, checked in by Joel Sherrill <joel.sherrill@…>, on 02/17/98 at 23:46:28

updated copyright to 1998

  • Property mode set to 100644
File size: 2.4 KB
Line 
1/*  Task_3
2 *
3 *  This routine serves as a test task.
4 *
5 *  Input parameters:
6 *    argument - task argument
7 *
8 *  Output parameters:  NONE
9 *
10 *  COPYRIGHT (c) 1989-1998.
11 *  On-Line Applications Research Corporation (OAR).
12 *  Copyright assigned to U.S. Government, 1994.
13 *
14 *  The license and distribution terms for this file may be
15 *  found in the file LICENSE in this distribution or at
16 *  http://www.OARcorp.com/rtems/license.html.
17 *
18 *  $Id$
19 */
20
21#include "system.h"
22#include <signal.h>
23
24void *Task_3(
25  void *argument
26)
27{
28  int           status;
29  int           sig;
30  union sigval  value;
31  sigset_t      mask;
32  siginfo_t     info;
33
34  value.sival_int = SIGUSR1;
35
36  printf( "Task_3: sigqueue SIGUSR1 with value= %d\n", value.sival_int );
37  status = sigqueue( getpid(), SIGUSR1, value );
38  assert( !status );
39
40     /* catch signal with sigwaitinfo */
41
42  empty_line();
43
44  status = sigemptyset( &mask );
45  assert( !status );
46
47  status = sigaddset( &mask, SIGUSR1 );
48  assert( !status );
49
50  printf( "Task_3: sigwaitinfo SIGUSR1 with value= %d\n", value.sival_int );
51  status = sigwaitinfo( &mask, &info );
52
53     /* switch to Init */
54
55  assert( !(status==-1) );
56  printf(
57    "Task_3: si_signo= %d si_code= %d value= %d\n",
58    info.si_signo,
59    info.si_code,
60    info.si_value.sival_int
61  );
62
63     /* catch signal with sigwait */
64
65  empty_line();
66
67  status = sigemptyset( &mask );
68  assert( !status );
69 
70  status = sigaddset( &mask, SIGUSR1 );
71  assert( !status );
72 
73  printf( "Task_3: sigwait SIGUSR1\n" );
74  status = sigwait( &mask, &sig );
75 
76     /* switch to Init */
77 
78  assert( !status );
79  printf( "Task_3: signo= %d\n", sig );
80
81     /* catch signal with pause */
82 
83  empty_line();
84
85  status = sigemptyset( &mask );
86  assert( !status );
87 
88  status = sigaddset( &mask, SIGUSR1 );
89  assert( !status );
90 
91  printf( "Task_3: pause\n" );
92  status = pause( );
93 
94     /* switch to Init */
95 
96  assert( !(status==-1) );
97  printf( "Task_3: pause= %d\n", status );
98 
99
100     /* send signal to Init task before it has pended for a signal */
101
102  empty_line();
103
104  printf( "Task_3: sending SIGUSR2\n" );
105  status = pthread_kill( Init_id, SIGUSR2 );
106  assert( !status );
107
108  printf( "Task_3: sleep so the Init task can reguest a signal\n" );
109  status = sleep( 1 );
110  assert( !status );
111
112     /* end of task 3 */
113  printf( "Task_3: exit\n" );
114  pthread_exit( NULL );
115
116     /* switch to Init */
117
118  return NULL; /* just so the compiler thinks we returned something */
119}
Note: See TracBrowser for help on using the repository browser.