source: rtems/testsuites/sptests/sp07/task2.c @ ac7d5ef0

4.104.114.84.95
Last change on this file since ac7d5ef0 was ac7d5ef0, checked in by Joel Sherrill <joel.sherrill@…>, on 05/11/95 at 17:39:37

Initial revision

  • Property mode set to 100644
File size: 2.4 KB
Line 
1/*  Task_2
2 *
3 *  This routine serves as a test task.  Plays with priorities to verify
4 *  that the highest priority task is always executed.
5 *
6 *  Input parameters:
7 *    argument - task argument
8 *
9 *  Output parameters:  NONE
10 *
11 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
12 *  On-Line Applications Research Corporation (OAR).
13 *  All rights assigned to U.S. Government, 1994.
14 *
15 *  This material may be reproduced by or for the U.S. Government pursuant
16 *  to the copyright license under the clause at DFARS 252.227-7013.  This
17 *  notice must appear in all copies of this file and its derivatives.
18 *
19 *  $Id$
20 */
21
22#include "system.h"
23
24rtems_task Task_2(
25  rtems_task_argument argument
26)
27{
28  rtems_status_code   status;
29  rtems_task_priority the_priority;
30  rtems_task_priority previous_priority;
31
32  while( FOREVER ) {
33
34    status = rtems_task_get_note( RTEMS_SELF, RTEMS_NOTEPAD_8, &the_priority );
35    directive_failed( status, "rtems_task_get_note" );
36    printf(
37"TA2 - rtems_task_get_note - get RTEMS_NOTEPAD_8 - current priority: %02d\n",
38      the_priority
39    );
40
41    if ( --the_priority == 0 ) {
42      puts( "TA2 - rtems_task_suspend - suspend TA1" );
43      status = rtems_task_suspend( Task_id[ 1 ] );
44      directive_failed( status, "rtems_task_suspend" );
45
46      puts( "TA2 - rtems_task_set_priority - set priority of TA1 ( blocked )" );
47      status = rtems_task_set_priority( Task_id[ 1 ], 5, &previous_priority );
48      directive_failed( status, "rtems_task_set_priority" );
49
50      status = rtems_task_delete( Task_id[ 1 ] );          /* TA1 is blocked */
51      directive_failed( status, "rtems_task_delete of TA1" );
52
53      status = rtems_task_delete( Task_id[ 3 ] );          /* TA3 is ready   */
54      directive_failed( status, "rtems_task_delete of TA3" );
55
56      status = rtems_task_delete( RTEMS_SELF );
57      directive_failed( status, "rtems_task_delete of SELD" );
58
59    } else {
60
61      printf( "TA2 - rtems_task_set_note - set TA1's RTEMS_NOTEPAD_8: %02d\n",
62              the_priority
63      );
64      status = rtems_task_set_note(Task_id[ 1 ], RTEMS_NOTEPAD_8, the_priority);
65      directive_failed( status, "rtems_task_set_note" );
66
67      printf( "TA2 - rtems_task_set_priority - set TA1's priority: %02d\n",
68              the_priority
69      );
70      status = rtems_task_set_priority(
71                 Task_id[ 1 ],
72                 the_priority,
73                 &previous_priority
74      );
75      directive_failed( status, "rtems_task_set_priority" );
76    }
77  }
78}
Note: See TracBrowser for help on using the repository browser.