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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [tests/] [sptests/] [sp12/] [pridrv.c] - Blame information for rev 30

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

Line No. Rev Author Line
1 30 unneback
/*  Priority_test_driver
2
 *
3
 *  This routine is the initialization task for this test program.
4
 *  It is a user initialization task and has the responsibility for creating
5
 *  and starting the tasks that make up the test.  If the time of day
6
 *  clock is required for the test, it should also be set to a known
7
 *  value by this function.
8
 *
9
 *  Input parameters:
10
 *    priority_base - priority_base switch
11
 *
12
 *  Output parameters:  NONE
13
 *
14
 *  COPYRIGHT (c) 1989-1999.
15
 *  On-Line Applications Research Corporation (OAR).
16
 *
17
 *  The license and distribution terms for this file may be
18
 *  found in the file LICENSE in this distribution or at
19
 *  http://www.OARcorp.com/rtems/license.html.
20
 *
21
 *  $Id: pridrv.c,v 1.2 2001-09-27 12:02:32 chris Exp $
22
 */
23
 
24
#include "system.h"
25
 
26
void Priority_test_driver(
27
  rtems_unsigned32 priority_base
28
)
29
{
30
  rtems_task_priority previous_priority;
31
  rtems_unsigned32    index;
32
  rtems_status_code   status;
33
 
34
  for ( index = 1 ; index <= 5 ; index++ ) {
35
    switch ( index ) {
36
       case 1:
37
       case 2:
38
       case 3:
39
         Task_priority[ index ] = priority_base + index;
40
         break;
41
       default:
42
         Task_priority[ index ] = priority_base + 3;
43
         break;
44
    }
45
 
46
    status = rtems_task_create(
47
      Priority_task_name[ index ],
48
      Task_priority[ index ],
49
      RTEMS_MINIMUM_STACK_SIZE * 2,
50
      RTEMS_DEFAULT_MODES,
51
      RTEMS_DEFAULT_ATTRIBUTES,
52
      &Priority_task_id[ index ]
53
    );
54
    directive_failed( status, "rtems_task_create loop" );
55
 
56
  }
57
 
58
  if ( priority_base == 0 ) {
59
    for ( index = 1 ; index <= 5 ; index++ ) {
60
      status = rtems_task_start(
61
        Priority_task_id[ index ],
62
        Priority_task,
63
        index
64
      );
65
      directive_failed( status, "rtems_task_start loop" );
66
    }
67
  } else {
68
    for ( index = 5 ; index >= 1 ; index-- ) {
69
      status = rtems_task_start(
70
        Priority_task_id[ index ],
71
        Priority_task,
72
        index
73
      );
74
      directive_failed( status, "rtems_task_start loop" );
75
 
76
      status = rtems_task_wake_after( TICKS_PER_SECOND );
77
      directive_failed( status, "rtems_task_wake_after loop" );
78
 
79
      if ( priority_base == 64 ) {
80
        if ( index == 4 ) {
81
          status = rtems_task_set_priority(
82
            Priority_task_id[ 5 ],
83
            priority_base + 4,
84
            &previous_priority
85
          );
86
          printf( "PDRV - change priority of PRI5 from %d to %d\n",
87
             previous_priority,
88
             priority_base + 4
89
          );
90
          directive_failed( status, "PDRV rtems_task_set_priority" );
91
        }
92
        status = rtems_task_set_priority(
93
          Priority_task_id[ 5 ],
94
          RTEMS_CURRENT_PRIORITY,
95
          &previous_priority
96
        );
97
        directive_failed( status, "PDRV rtems_task_set_priority CURRENT" );
98
        printf( "PDRV - priority of PRI5 is %d\n", previous_priority );
99
      }
100
    }
101
  }
102
 
103
  status = rtems_task_wake_after( TICKS_PER_SECOND );
104
  directive_failed( status, "rtems_task_wake_after after loop" );
105
 
106
  if ( priority_base == 0 ) {
107
    for ( index = 1 ; index <= 5 ; index++ ) {
108
      status = rtems_semaphore_release( Semaphore_id[ 2 ] );
109
      directive_failed( status, "rtems_semaphore_release loop" );
110
    }
111
  }
112
 
113
  if ( priority_base == 64 ) {
114
    puts( "PDRV - rtems_task_resume - PRI5" );
115
    status = rtems_task_resume( Priority_task_id[ 5 ] );
116
    directive_failed( status, "rtems_task_resume" );
117
 
118
    status = rtems_task_wake_after( 1 * TICKS_PER_SECOND );
119
    directive_failed( status, "rtems_task_wake_after so PRI5 can run" );
120
 
121
    status = rtems_task_delete( Priority_task_id[ 5 ] );
122
    directive_failed( status, "rtems_task_delete of PRI5" );
123
  }
124
  else {
125
    for ( index = 1 ; index <= 5 ; index++ ) {
126
      status = rtems_task_delete( Priority_task_id[ index ] );
127
      directive_failed( status, "rtems_task_delete loop" );
128
    }
129
  }
130
}

powered by: WebSVN 2.1.0

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