OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [tests/] [sptests/] [sp07/] [task2.c] - Blame information for rev 609

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*  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-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.OARcorp.com/rtems/license.html.
17
 *
18
 *  $Id: task2.c,v 1.2 2001-09-27 12:02:31 chris Exp $
19
 */
20
 
21
#include "system.h"
22
 
23
rtems_task Task_2(
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
 
31
  while( FOREVER ) {
32
 
33
    status = rtems_task_get_note( RTEMS_SELF, RTEMS_NOTEPAD_8, &the_priority );
34
    directive_failed( status, "rtems_task_get_note" );
35
    printf(
36
"TA2 - rtems_task_get_note - get RTEMS_NOTEPAD_8 - current priority: %02d\n",
37
      the_priority
38
    );
39
 
40
    if ( --the_priority == 0 ) {
41
      puts( "TA2 - rtems_task_suspend - suspend TA1" );
42
      status = rtems_task_suspend( Task_id[ 1 ] );
43
      directive_failed( status, "rtems_task_suspend" );
44
 
45
      puts( "TA2 - rtems_task_set_priority - set priority of TA1 ( blocked )" );
46
      status = rtems_task_set_priority( Task_id[ 1 ], 5, &previous_priority );
47
      directive_failed( status, "rtems_task_set_priority" );
48
 
49
      status = rtems_task_delete( Task_id[ 1 ] );          /* TA1 is blocked */
50
      directive_failed( status, "rtems_task_delete of TA1" );
51
 
52
      status = rtems_task_delete( Task_id[ 3 ] );          /* TA3 is ready   */
53
      directive_failed( status, "rtems_task_delete of TA3" );
54
 
55
      status = rtems_task_delete( RTEMS_SELF );
56
      directive_failed( status, "rtems_task_delete of SELD" );
57
 
58
    } else {
59
 
60
      printf( "TA2 - rtems_task_set_note - set TA1's RTEMS_NOTEPAD_8: %02d\n",
61
              the_priority
62
      );
63
      status = rtems_task_set_note(Task_id[ 1 ], RTEMS_NOTEPAD_8, the_priority);
64
      directive_failed( status, "rtems_task_set_note" );
65
 
66
      printf( "TA2 - rtems_task_set_priority - set TA1's priority: %02d\n",
67
              the_priority
68
      );
69
      status = rtems_task_set_priority(
70
                 Task_id[ 1 ],
71
                 the_priority,
72
                 &previous_priority
73
      );
74
      directive_failed( status, "rtems_task_set_priority" );
75
    }
76
  }
77
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.