source: rtems/testsuites/sptests/sp12/task1.c @ 3a4ae6c

4.104.114.84.9
Last change on this file since 3a4ae6c was ac7d5ef0, checked in by Joel Sherrill <joel.sherrill@…>, on May 11, 1995 at 5:39:37 PM

Initial revision

  • Property mode set to 100644
File size: 4.6 KB
Line 
1/*  Task_1
2 *
3 *  This routine serves as a test task.  It verifies the semaphore manager.
4 *
5 *  Input parameters:
6 *    argument - task argument
7 *
8 *  Output parameters:  NONE
9 *
10 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
11 *  On-Line Applications Research Corporation (OAR).
12 *  All rights assigned to U.S. Government, 1994.
13 *
14 *  This material may be reproduced by or for the U.S. Government pursuant
15 *  to the copyright license under the clause at DFARS 252.227-7013.  This
16 *  notice must appear in all copies of this file and its derivatives.
17 *
18 *  $Id$
19 */
20
21#include "system.h"
22
23rtems_task Task_1(
24  rtems_task_argument argument
25)
26{
27  rtems_id          smid;
28  rtems_status_code status;
29
30  status = rtems_semaphore_ident(
31    Semaphore_name[ 1 ],
32    RTEMS_SEARCH_ALL_NODES,
33    &smid
34  );
35  printf( "TA1 - rtems_semaphore_ident - smid => %08x\n", smid );
36  directive_failed( status, "rtems_semaphore_ident of SM1" );
37
38  puts( "TA1 - rtems_semaphore_obtain - wait forever on SM2" );
39  status = rtems_semaphore_obtain(
40    Semaphore_id[ 2 ],
41    RTEMS_DEFAULT_OPTIONS,
42    RTEMS_NO_TIMEOUT
43  );
44  directive_failed( status, "rtems_semaphore_obtain of SM2" );
45  puts( "TA1 - got SM2" );
46
47  puts( "TA1 - rtems_semaphore_obtain - wait forever on SM3" );
48  status = rtems_semaphore_obtain(
49    Semaphore_id[ 3 ],
50    RTEMS_DEFAULT_OPTIONS,
51    RTEMS_NO_TIMEOUT
52  );
53  directive_failed( status, "rtems_semaphore_obtain of SM3" );
54  puts( "TA1 - got SM3" );
55
56  puts( "TA1 - rtems_semaphore_obtain - get SM1 - RTEMS_NO_WAIT" );
57  status = rtems_semaphore_obtain(
58    Semaphore_id[ 1 ],
59    RTEMS_NO_WAIT,
60    RTEMS_NO_TIMEOUT
61  );
62  directive_failed( status, "rtems_semaphore_obtain of SM1" );
63  puts( "TA1 - got SM1" );
64
65  puts( "TA1 - rtems_task_wake_after - sleep 5 seconds" );
66  status = rtems_task_wake_after( 5*TICKS_PER_SECOND );
67  directive_failed( status, "rtems_task_wake_after" );
68
69pause();
70
71  puts( "TA1 - rtems_semaphore_release - release SM1" );
72  status = rtems_semaphore_release( Semaphore_id[ 1 ] );
73  directive_failed( status, "rtems_semaphore_release of SM1" );
74
75  puts(
76    "TA1 - rtems_semaphore_obtain - waiting for SM1 with 10 second timeout"
77  );
78  status = rtems_semaphore_obtain(
79    Semaphore_id[ 1 ],
80    RTEMS_DEFAULT_OPTIONS,
81    10 * TICKS_PER_SECOND
82  );
83  directive_failed( status, "rtems_semaphore_obtain of SM1" );
84  puts( "TA1 - got SM1" );
85
86  puts( "TA1 - rtems_semaphore_release - release SM2" );
87  status = rtems_semaphore_release( Semaphore_id[ 2 ] );
88  directive_failed( status, "rtems_semaphore_release of SM2" );
89
90  puts( "TA1 - rtems_task_wake_after - sleep 5 seconds" );
91  status = rtems_task_wake_after( 5*TICKS_PER_SECOND );
92  directive_failed( status, "rtems_task_wake_after" );
93
94pause();
95
96  puts( "TA1 - rtems_task_delete - delete TA3" );
97  status = rtems_task_delete( Task_id[ 3 ] );
98  directive_failed( status, "rtems_task_delete of TA3" );
99
100  status = rtems_task_create(
101    Task_name[ 4 ],
102    4,
103    2048,
104    RTEMS_DEFAULT_MODES,
105    RTEMS_DEFAULT_ATTRIBUTES,
106    &Task_id[ 4 ]
107  );
108  directive_failed( status, "rtems_task_create of TA4" );
109
110  status = rtems_task_create(
111    Task_name[ 5 ],
112    4,
113    2048,
114    RTEMS_DEFAULT_MODES,
115    RTEMS_DEFAULT_ATTRIBUTES,
116    &Task_id[ 5 ]
117   );
118  directive_failed( status, "rtems_task_create of TA5" );
119
120  status = rtems_task_start( Task_id[ 4 ], Task_4, 0 );
121  directive_failed( status, "rtems_task_start of TA4" );
122
123  status = rtems_task_start( Task_id[ 5 ], Task5, 0 );
124  directive_failed( status, "rtems_task_start of TA5" );
125
126  puts( "TA1 - rtems_task_wake_after - sleep 5 seconds" );
127  status = rtems_task_wake_after( 5*TICKS_PER_SECOND );
128  directive_failed( status, "rtems_task_wake_after" );
129
130  puts( "TA1 - rtems_task_delete - delete TA4" );
131  status = rtems_task_delete( Task_id[ 4 ] );
132  directive_failed( status, "rtems_task_delete of TA4" );
133
134  puts( "TA1 - rtems_semaphore_release - release SM1" );
135  status = rtems_semaphore_release( Semaphore_id[ 1 ] );
136  directive_failed( status, "rtems_semaphore_release on SM1" );
137
138  puts( "TA1 - rtems_task_wake_after - sleep 5 seconds" );
139  status = rtems_task_wake_after( 5*TICKS_PER_SECOND );
140  directive_failed( status, "rtems_task_wake_after" );
141
142  puts( "TA1 - rtems_semaphore_delete - delete SM1" );
143  status = rtems_semaphore_delete( Semaphore_id[ 1 ] );
144  directive_failed( status, "rtems_semaphore_delete of SM1" );
145
146  puts( "TA1 - rtems_semaphore_delete - delete SM3" );
147  status = rtems_semaphore_delete( Semaphore_id[ 3 ] );
148  directive_failed( status, "rtems_semaphore_delete of SM3" );
149
150  puts( "TA1 - rtems_task_delete - delete self" );
151  status = rtems_task_delete( RTEMS_SELF );
152  directive_failed( status, "rtems_task_delete of TA1" );
153}
Note: See TracBrowser for help on using the repository browser.