source: rtems/testsuites/sptests/sp12/task1.c @ d2b93bfd

4.104.114.84.95
Last change on this file since d2b93bfd was d2b93bfd, checked in by Joel Sherrill <joel.sherrill@…>, on 09/04/03 at 18:53:48

2003-09-04 Joel Sherrill <joel@…>

  • sp01/init.c, sp01/sp01.doc, sp01/system.h, sp01/task1.c, sp02/init.c, sp02/preempt.c, sp02/sp02.doc, sp02/system.h, sp02/task1.c, sp02/task2.c, sp02/task3.c, sp03/init.c, sp03/sp03.doc, sp03/system.h, sp03/task1.c, sp03/task2.c, sp04/init.c, sp04/sp04.doc, sp04/system.h, sp04/task1.c, sp04/task2.c, sp04/task3.c, sp04/tswitch.c, sp05/init.c, sp05/sp05.doc, sp05/system.h, sp05/task1.c, sp05/task2.c, sp05/task3.c, sp06/init.c, sp06/sp06.doc, sp06/system.h, sp06/task1.c, sp06/task2.c, sp06/task3.c, sp07/init.c, sp07/sp07.doc, sp07/system.h, sp07/task1.c, sp07/task2.c, sp07/task3.c, sp07/task4.c, sp07/taskexit.c, sp07/tcreate.c, sp07/tdelete.c, sp07/trestart.c, sp07/tstart.c, sp08/init.c, sp08/sp08.doc, sp08/system.h, sp08/task1.c, sp09/delay.c, sp09/init.c, sp09/isr.c, sp09/screen01.c, sp09/screen02.c, sp09/screen03.c, sp09/screen04.c, sp09/screen05.c, sp09/screen06.c, sp09/screen07.c, sp09/screen08.c, sp09/screen09.c, sp09/screen10.c, sp09/screen11.c, sp09/screen12.c, sp09/screen13.c, sp09/screen14.c, sp09/sp09.doc, sp09/system.h, sp09/task1.c, sp09/task2.c, sp09/task3.c, sp09/task4.c, sp11/init.c, sp11/sp11.doc, sp11/system.h, sp11/task1.c, sp11/task2.c, sp11/timer.c, sp12/init.c, sp12/pridrv.c, sp12/pritask.c, sp12/sp12.doc, sp12/system.h, sp12/task1.c, sp12/task2.c, sp12/task3.c, sp12/task4.c, sp12/task5.c, sp13/fillbuff.c, sp13/init.c, sp13/putbuff.c, sp13/sp13.doc, sp13/system.h, sp13/task1.c, sp13/task2.c, sp13/task3.c, sp14/asr.c, sp14/init.c, sp14/sp14.doc, sp14/system.h, sp14/task1.c, sp14/task2.c, sp15/init.c, sp15/sp15.doc, sp15/system.h, sp15/task1.c, sp16/init.c, sp16/sp16.doc, sp16/system.h, sp16/task1.c, sp16/task2.c, sp16/task3.c, sp16/task4.c, sp16/task5.c, sp17/asr.c, sp17/init.c, sp17/sp17.doc, sp17/system.h, sp17/task1.c, sp17/task2.c, sp19/first.c, sp19/fptask.c, sp19/fptest.h, sp19/init.c, sp19/inttest.h, sp19/sp19.doc, sp19/system.h, sp19/task1.c, sp20/getall.c, sp20/init.c, sp20/sp20.doc, sp20/system.h, sp20/task1.c, sp21/init.c, sp21/sp21.doc, sp21/system.h, sp21/task1.c, sp22/delay.c, sp22/init.c, sp22/prtime.c, sp22/sp22.doc, sp22/system.h, sp22/task1.c, sp23/init.c, sp23/sp23.doc, sp23/system.h, sp23/task1.c, sp24/init.c, sp24/resume.c, sp24/sp24.doc, sp24/system.h, sp24/task1.c, sp25/init.c, sp25/sp25.doc, sp25/system.h, sp25/task1.c, sp26/init.c, sp26/sp26.doc, sp26/system.h, sp26/task1.c, sp30/init.c, sp30/resume.c, sp30/sp30.doc, sp30/system.h, sp30/task1.c, sp31/delay.c, sp31/init.c, sp31/prtime.c, sp31/sp31.doc, sp31/system.h, sp31/task1.c, sp32/init.c, spfatal/fatal.c, spfatal/init.c, spfatal/puterr.c, spfatal/spfatal.doc, spfatal/system.h, spfatal/task1.c, spsize/getint.c, spsize/init.c, spsize/size.c, spsize/system.h: URL for license changed.
  • Property mode set to 100644
File size: 4.5 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-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.rtems.com/license/LICENSE.
16 *
17 *  $Id$
18 */
19
20#include "system.h"
21
22rtems_task Task_1(
23  rtems_task_argument argument
24)
25{
26  rtems_id          smid;
27  rtems_status_code status;
28
29  status = rtems_semaphore_ident(
30    Semaphore_name[ 1 ],
31    RTEMS_SEARCH_ALL_NODES,
32    &smid
33  );
34  printf( "TA1 - rtems_semaphore_ident - smid => %08x\n", smid );
35  directive_failed( status, "rtems_semaphore_ident of SM1" );
36
37  puts( "TA1 - rtems_semaphore_obtain - wait forever on SM2" );
38  status = rtems_semaphore_obtain(
39    Semaphore_id[ 2 ],
40    RTEMS_DEFAULT_OPTIONS,
41    RTEMS_NO_TIMEOUT
42  );
43  directive_failed( status, "rtems_semaphore_obtain of SM2" );
44  puts( "TA1 - got SM2" );
45
46  puts( "TA1 - rtems_semaphore_obtain - wait forever on SM3" );
47  status = rtems_semaphore_obtain(
48    Semaphore_id[ 3 ],
49    RTEMS_DEFAULT_OPTIONS,
50    RTEMS_NO_TIMEOUT
51  );
52  directive_failed( status, "rtems_semaphore_obtain of SM3" );
53  puts( "TA1 - got SM3" );
54
55  puts( "TA1 - rtems_semaphore_obtain - get SM1 - RTEMS_NO_WAIT" );
56  status = rtems_semaphore_obtain(
57    Semaphore_id[ 1 ],
58    RTEMS_NO_WAIT,
59    RTEMS_NO_TIMEOUT
60  );
61  directive_failed( status, "rtems_semaphore_obtain of SM1" );
62  puts( "TA1 - got SM1" );
63
64  puts( "TA1 - rtems_task_wake_after - sleep 5 seconds" );
65  status = rtems_task_wake_after( 5*TICKS_PER_SECOND );
66  directive_failed( status, "rtems_task_wake_after" );
67
68rtems_test_pause();
69
70  puts( "TA1 - rtems_semaphore_release - release SM1" );
71  status = rtems_semaphore_release( Semaphore_id[ 1 ] );
72  directive_failed( status, "rtems_semaphore_release of SM1" );
73
74  puts(
75    "TA1 - rtems_semaphore_obtain - waiting for SM1 with 10 second timeout"
76  );
77  status = rtems_semaphore_obtain(
78    Semaphore_id[ 1 ],
79    RTEMS_DEFAULT_OPTIONS,
80    10 * TICKS_PER_SECOND
81  );
82  directive_failed( status, "rtems_semaphore_obtain of SM1" );
83  puts( "TA1 - got SM1" );
84
85  puts( "TA1 - rtems_semaphore_release - release SM2" );
86  status = rtems_semaphore_release( Semaphore_id[ 2 ] );
87  directive_failed( status, "rtems_semaphore_release of SM2" );
88
89  puts( "TA1 - rtems_task_wake_after - sleep 5 seconds" );
90  status = rtems_task_wake_after( 5*TICKS_PER_SECOND );
91  directive_failed( status, "rtems_task_wake_after" );
92
93rtems_test_pause();
94
95  puts( "TA1 - rtems_task_delete - delete TA3" );
96  status = rtems_task_delete( Task_id[ 3 ] );
97  directive_failed( status, "rtems_task_delete of TA3" );
98
99  status = rtems_task_create(
100    Task_name[ 4 ],
101    4,
102    RTEMS_MINIMUM_STACK_SIZE,
103    RTEMS_DEFAULT_MODES,
104    RTEMS_DEFAULT_ATTRIBUTES,
105    &Task_id[ 4 ]
106  );
107  directive_failed( status, "rtems_task_create of TA4" );
108
109  status = rtems_task_create(
110    Task_name[ 5 ],
111    4,
112    RTEMS_MINIMUM_STACK_SIZE,
113    RTEMS_DEFAULT_MODES,
114    RTEMS_DEFAULT_ATTRIBUTES,
115    &Task_id[ 5 ]
116   );
117  directive_failed( status, "rtems_task_create of TA5" );
118
119  status = rtems_task_start( Task_id[ 4 ], Task_4, 0 );
120  directive_failed( status, "rtems_task_start of TA4" );
121
122  status = rtems_task_start( Task_id[ 5 ], Task5, 0 );
123  directive_failed( status, "rtems_task_start of TA5" );
124
125  puts( "TA1 - rtems_task_wake_after - sleep 5 seconds" );
126  status = rtems_task_wake_after( 5*TICKS_PER_SECOND );
127  directive_failed( status, "rtems_task_wake_after" );
128
129  puts( "TA1 - rtems_task_delete - delete TA4" );
130  status = rtems_task_delete( Task_id[ 4 ] );
131  directive_failed( status, "rtems_task_delete of TA4" );
132
133  puts( "TA1 - rtems_semaphore_release - release SM1" );
134  status = rtems_semaphore_release( Semaphore_id[ 1 ] );
135  directive_failed( status, "rtems_semaphore_release on SM1" );
136
137  puts( "TA1 - rtems_task_wake_after - sleep 5 seconds" );
138  status = rtems_task_wake_after( 5*TICKS_PER_SECOND );
139  directive_failed( status, "rtems_task_wake_after" );
140
141  puts( "TA1 - rtems_semaphore_delete - delete SM1" );
142  status = rtems_semaphore_delete( Semaphore_id[ 1 ] );
143  directive_failed( status, "rtems_semaphore_delete of SM1" );
144
145  puts( "TA1 - rtems_semaphore_delete - delete SM3" );
146  status = rtems_semaphore_delete( Semaphore_id[ 3 ] );
147  directive_failed( status, "rtems_semaphore_delete of SM3" );
148
149  puts( "TA1 - rtems_task_delete - delete self" );
150  status = rtems_task_delete( RTEMS_SELF );
151  directive_failed( status, "rtems_task_delete of TA1" );
152}
Note: See TracBrowser for help on using the repository browser.