source: rtems/testsuites/sptests/sp07/task1.c @ c499856

4.115
Last change on this file since c499856 was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 2.4 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2011.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.org/license/LICENSE.
8 */
9
10#ifdef HAVE_CONFIG_H
11#include "config.h"
12#endif
13
14#include "system.h"
15
16rtems_task Task_1(
17  rtems_task_argument argument
18)
19{
20  rtems_status_code   status;
21  rtems_task_priority the_priority;
22  rtems_task_priority previous_priority;
23  rtems_id            my_id;
24
25  my_id = rtems_task_self();
26
27  rtems_test_pause();
28
29  status = rtems_task_set_priority(
30    RTEMS_SELF,
31    RTEMS_CURRENT_PRIORITY,
32    &the_priority
33  );
34  directive_failed( status, "rtems_task_set_priority" );
35  printf(
36    "TA1 - rtems_task_set_priority - get initial "
37       "priority of self: %02" PRIdrtems_task_priority "\n",
38    the_priority
39  );
40
41  while( FOREVER ) {
42    status = rtems_task_get_note( my_id, RTEMS_NOTEPAD_8, &the_priority );
43    directive_failed( status, "rtems_task_get_note" );
44    printf(
45      "TA1 - rtems_task_get_note - get RTEMS_NOTEPAD_8 - "
46         "current priority: %02" PRIdrtems_task_priority "\n",
47      the_priority
48    );
49
50    if ( --the_priority == 0 ) {
51      puts( "TA1 - rtems_task_suspend - suspend TA2" );
52      status = rtems_task_suspend( Task_id[ 2 ] );
53      directive_failed( status, "rtems_task_suspend" );
54
55      puts( "TA1 - rtems_task_set_priority - set priority of TA2 ( blocked )" );
56      status = rtems_task_set_priority( Task_id[ 2 ], 5, &previous_priority );
57      directive_failed( status, "rtems_task_set_priority" );
58
59      status = rtems_task_delete( Task_id[ 2 ] );
60      directive_failed( status, "rtems_task_delete of TA2" );
61
62      status = rtems_task_delete( RTEMS_SELF );
63      directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
64    }
65
66    printf(
67      "TA1 - rtems_task_set_note - set TA2's RTEMS_NOTEPAD_8: "
68          "%02" PRIdrtems_task_priority "\n",
69      the_priority
70    );
71    status = rtems_task_set_note( Task_id[ 2 ], RTEMS_NOTEPAD_8, the_priority );
72    directive_failed( status, "rtems_task_set_note" );
73
74    printf(
75      "TA1 - rtems_task_set_priority - set TA2's priority: "
76          "%02" PRIdrtems_task_priority "\n",
77      the_priority
78    );
79    status = rtems_task_set_priority(
80               Task_id[ 2 ],
81               the_priority,
82               &previous_priority
83    );
84    directive_failed( status, "rtems_task_set_priority" );
85  }
86}
Note: See TracBrowser for help on using the repository browser.