source: rtems/testsuites/sptests/sp12/task2.c

Last change on this file was 51b3cbca, checked in by Sebastian Huber <sebastian.huber@…>, on Oct 4, 2018 at 1:23:25 PM

tests: Use rtems_task_exit()

Update #3533.

  • Property mode set to 100644
File size: 1.8 KB
Line 
1/*  Task_2
2 *
3 *  This routine serves as a test task.  It simply obtains semaphores
4 *  1 and 2, the later when it is a high priority task.
5 *
6 *  Input parameters:
7 *    argument - task argument
8 *
9 *  Output parameters:  NONE
10 *
11 *  COPYRIGHT (c) 1989-1999.
12 *  On-Line Applications Research Corporation (OAR).
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.rtems.org/license/LICENSE.
17 */
18
19
20#ifdef HAVE_CONFIG_H
21#include "config.h"
22#endif
23
24#include "system.h"
25
26rtems_task Task_2(
27  rtems_task_argument argument
28)
29{
30  rtems_status_code   status;
31  rtems_task_priority previous_priority;
32
33  puts( "TA2 - rtems_semaphore_obtain - wait forever on SM1" );
34  status = rtems_semaphore_obtain(
35    Semaphore_id[ 1 ],
36    RTEMS_DEFAULT_OPTIONS,
37    RTEMS_NO_TIMEOUT
38  );
39  puts( "TA2 - got SM1" );
40  directive_failed( status, "rtems_semaphore_obtain on SM1" );
41
42  puts( "TA2 - rtems_semaphore_release - release SM1" );
43  status = rtems_semaphore_release( Semaphore_id[ 1 ] );
44  directive_failed( status, "rtems_semaphore_release on SM1" );
45
46  puts( "TA2 - rtems_task_set_priority - make self highest priority task" );
47  status = rtems_task_set_priority( RTEMS_SELF, 3, &previous_priority );
48  directive_failed( status, "rtems_task_set_priority on TA2" );
49
50  puts( "TA2 - rtems_semaphore_obtain - wait forever on SM2" );
51  status = rtems_semaphore_obtain(
52    Semaphore_id[ 2 ],
53    RTEMS_DEFAULT_OPTIONS,
54    RTEMS_NO_TIMEOUT
55  );
56  puts( "TA2 - got SM2" );
57  directive_failed( status, "rtems_semaphore_obtain on SM2" );
58
59  puts( "TA2 - rtems_semaphore_release - release SM2" );
60  status = rtems_semaphore_release( Semaphore_id[ 2 ] );
61  directive_failed( status, "rtems_semaphore_release on SM2" );
62
63  puts( "TA2 - rtems_task_exit" );
64  rtems_task_exit();
65}
Note: See TracBrowser for help on using the repository browser.