source: rtems/testsuites/sptests/sp07/task1.c @ 9c691ef

4.104.114.95
Last change on this file since 9c691ef was 9c691ef, checked in by Joel Sherrill <joel.sherrill@…>, on 12/13/07 at 21:45:23

2007-12-13 Joel Sherrill <joel.sherrill@…>

  • sp07/init.c, sp07/sp07.scn, sp07/task1.c: Add tests for using notepad with the current task's ID or SELF
  • sp09/screen02.c, sp09/screen04.c, sp09/sp09.scn: Add test missing test cases for clock_get.
  • Property mode set to 100644
File size: 2.5 KB
Line 
1/*  Task_1
2 *
3 *  This routine serves as a test task.  It verifies intertask communication
4 *  using task notepads and verifies the the user extensions (tcreate, etc).
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.com/license/LICENSE.
17 *
18 *  $Id$
19 */
20
21#include "system.h"
22
23rtems_task Task_1(
24  rtems_task_argument argument
25)
26{
27  rtems_status_code   status;
28  rtems_task_priority the_priority;
29  rtems_task_priority previous_priority;
30  rtems_id            my_id;
31
32  /* XXX really need a Classic API service for this */
33  my_id = _Thread_Executing->Object.id;
34
35  rtems_test_pause();
36
37  status = rtems_task_set_priority(
38    RTEMS_SELF,
39    RTEMS_CURRENT_PRIORITY,
40    &the_priority
41  );
42  directive_failed( status, "rtems_task_set_priority" );
43  printf(
44    "TA1 - rtems_task_set_priority - get initial priority of self: %02d\n",
45    the_priority
46  );
47
48  while( FOREVER ) {
49    status = rtems_task_get_note( my_id, RTEMS_NOTEPAD_8, &the_priority );
50    directive_failed( status, "rtems_task_get_note" );
51    printf(
52"TA1 - rtems_task_get_note - get RTEMS_NOTEPAD_8 - current priority: %02d\n",
53       the_priority
54    );
55
56    if ( --the_priority == 0 ) {
57      puts( "TA1 - rtems_task_suspend - suspend TA2" );
58      status = rtems_task_suspend( Task_id[ 2 ] );
59      directive_failed( status, "rtems_task_suspend" );
60
61      puts( "TA1 - rtems_task_set_priority - set priority of TA2 ( blocked )" );
62      status = rtems_task_set_priority( Task_id[ 2 ], 5, &previous_priority );
63      directive_failed( status, "rtems_task_set_priority" );
64
65      status = rtems_task_delete( Task_id[ 2 ] );
66      directive_failed( status, "rtems_task_delete of TA2" );
67
68      status = rtems_task_delete( RTEMS_SELF );
69      directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
70    }
71
72    printf( "TA1 - rtems_task_set_note - set TA2's RTEMS_NOTEPAD_8: %02d\n",
73            the_priority
74    );
75    status = rtems_task_set_note( Task_id[ 2 ], RTEMS_NOTEPAD_8, the_priority );
76    directive_failed( status, "rtems_task_set_note" );
77
78    printf( "TA1 - rtems_task_set_priority - set TA2's priority: %02d\n",
79            the_priority
80    );
81    status = rtems_task_set_priority(
82               Task_id[ 2 ],
83               the_priority,
84               &previous_priority
85    );
86    directive_failed( status, "rtems_task_set_priority" );
87  }
88}
Note: See TracBrowser for help on using the repository browser.