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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [tests/] [psxtests/] [psx04/] [task3.c] - Blame information for rev 562

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*  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-1999.
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.OARcorp.com/rtems/license.html.
16
 *
17
 *  $Id: task3.c,v 1.2 2001-09-27 12:02:24 chris Exp $
18
 */
19
 
20
#include "system.h"
21
#include <signal.h>
22
 
23
void *Task_3(
24
  void *argument
25
)
26
{
27
  int           status;
28
  int           sig;
29
  union sigval  value;
30
  sigset_t      mask;
31
  siginfo_t     info;
32
 
33
  value.sival_int = SIGUSR1;
34
 
35
  printf( "Task_3: sigqueue SIGUSR1 with value= %d\n", value.sival_int );
36
  status = sigqueue( getpid(), SIGUSR1, value );
37
  assert( !status );
38
 
39
     /* catch signal with sigwaitinfo */
40
 
41
  empty_line();
42
 
43
  status = sigemptyset( &mask );
44
  assert( !status );
45
 
46
  status = sigaddset( &mask, SIGUSR1 );
47
  assert( !status );
48
 
49
  printf( "Task_3: sigwaitinfo SIGUSR1 with value= %d\n", value.sival_int );
50
  status = sigwaitinfo( &mask, &info );
51
 
52
     /* switch to Init */
53
 
54
  assert( !(status==-1) );
55
  printf(
56
    "Task_3: si_signo= %d si_code= %d value= %d\n",
57
    info.si_signo,
58
    info.si_code,
59
    info.si_value.sival_int
60
  );
61
 
62
     /* catch signal with sigwait */
63
 
64
  empty_line();
65
 
66
  status = sigemptyset( &mask );
67
  assert( !status );
68
 
69
  status = sigaddset( &mask, SIGUSR1 );
70
  assert( !status );
71
 
72
  printf( "Task_3: sigwait SIGUSR1\n" );
73
  status = sigwait( &mask, &sig );
74
 
75
     /* switch to Init */
76
 
77
  assert( !status );
78
  printf( "Task_3: signo= %d\n", sig );
79
 
80
     /* catch signal with pause */
81
 
82
  empty_line();
83
 
84
  status = sigemptyset( &mask );
85
  assert( !status );
86
 
87
  status = sigaddset( &mask, SIGUSR1 );
88
  assert( !status );
89
 
90
  printf( "Task_3: pause\n" );
91
  status = pause( );
92
 
93
     /* switch to Init */
94
 
95
  assert( !(status==-1) );
96
  printf( "Task_3: pause= %d\n", status );
97
 
98
 
99
     /* send signal to Init task before it has pended for a signal */
100
 
101
  empty_line();
102
 
103
  printf( "Task_3: sending SIGUSR2\n" );
104
  status = pthread_kill( Init_id, SIGUSR2 );
105
  assert( !status );
106
 
107
  printf( "Task_3: sleep so the Init task can reguest a signal\n" );
108
  status = sleep( 1 );
109
  assert( !status );
110
 
111
     /* end of task 3 */
112
  printf( "Task_3: exit\n" );
113
  pthread_exit( NULL );
114
 
115
     /* switch to Init */
116
 
117
  return NULL; /* just so the compiler thinks we returned something */
118
}

powered by: WebSVN 2.1.0

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