source: rtems/testsuites/psxtests/psx04/task3.c @ f9eb21d

4.104.115
Last change on this file since f9eb21d was f9eb21d, checked in by Chris Johns <chrisj@…>, on 06/17/09 at 22:58:19

2009-06-18 Chris Johns <chrisj@…>

  • psx04/task3.c: Declare unions volatile to workaround the H8300 gcc bug.
  • 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-2009.
11 *  On-Line Applications Research Corporation (OAR).
12 *
13 *  The license and distribution terms for this file may be
14 *  found in the file LICENSE in this distribution or at
15 *  http://www.rtems.com/license/LICENSE.
16 *
17 *  $Id$
18 */
19
20#include "system.h"
21#include <signal.h>
22
23void *Task_3(
24  void *argument
25)
26{
27  unsigned int  remaining;
28  int           status;
29  int           sig;
30  volatile union sigval  value; /* should be removed once the H8300 target is fixed */
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  remaining = 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.