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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems-20020807/] [c/] [src/] [tests/] [sptests/] [sp12/] [pritask.c] - Blame information for rev 1779

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

Line No. Rev Author Line
1 1026 ivang
/*  Priority_task
2
 *
3
 *  This routine serves as a test task.  It verifies the semaphore manager.
4
 *
5
 *  Input parameters:
6
 *    its_index - priority index
7
 *
8
 *  Output parameters:  NONE
9
 *
10
 *  COPYRIGHT (c) 1989-1999.
11
 *  On-Line Applications Research Corporation (OAR).
12
 *
13
 *  The license and distribution terms for this file may be
14
 *  found in the file LICENSE in this distribution or at
15
 *  http://www.OARcorp.com/rtems/license.html.
16
 *
17
 *  pritask.c,v 1.7 2002/08/02 00:52:13 joel Exp
18
 */
19
 
20
#include "system.h"
21
 
22
rtems_task Priority_task(
23
  rtems_task_argument its_index
24
)
25
{
26
  rtems_interval      timeout;
27
  rtems_task_priority its_priority;
28
  rtems_task_priority current_priority;
29
  rtems_status_code   status;
30
  rtems_unsigned32    index;
31
 
32
  its_priority = Task_priority[ its_index ];
33
 
34
  if ( its_priority < 3 )
35
    timeout = 5 * TICKS_PER_SECOND;
36
  else
37
    timeout = RTEMS_NO_TIMEOUT;
38
 
39
  put_name( Priority_task_name[ its_index ], FALSE );
40
  puts( " - rtems_semaphore_obtain - wait forever on SM2" );
41
 
42
  status = rtems_semaphore_obtain(
43
    Semaphore_id[ 2 ],
44
    RTEMS_DEFAULT_OPTIONS,
45
    timeout
46
  );
47
  directive_failed( status, "rtems_semaphore_obtain of SM2" );
48
 
49
  if ( its_priority < 64 ) {
50
    printf( "PRI%d - WHY AM I HERE? (pri=%d)", its_index, its_priority );
51
    rtems_test_exit( 0 );
52
  }
53
 
54
  if ( its_index == 5 )
55
    puts( "PRI5 - rtems_task_suspend - until all priority tasks blocked" );
56
  status = rtems_task_suspend( RTEMS_SELF );
57
  directive_failed( status, "rtems_task_suspend" );
58
 
59
  puts( "PRI5 - rtems_task_delete - all tasks waiting on SM2" );
60
  for ( index = 1 ; index < 5 ; index++ ) {
61
    status = rtems_task_delete( Priority_task_id[ index ] );
62
    directive_failed( status, "rtems_task_delete loop" );
63
  }
64
 
65
  puts( "PRI5 - rtems_semaphore_obtain - nested" );
66
  status = rtems_semaphore_obtain(
67
    Semaphore_id[ 2 ],
68
    RTEMS_DEFAULT_OPTIONS,
69
    timeout
70
  );
71
  directive_failed( status, "rtems_semaphore_obtain nested" );
72
 
73
  puts( "PRI5 - rtems_semaphore_release - nested" );
74
  status = rtems_semaphore_release( Semaphore_id[ 2 ] );
75
  directive_failed( status, "rtems_semaphore_release nested " );
76
 
77
  puts( "PRI5 - rtems_semaphore_release - restore priority" );
78
  status = rtems_semaphore_release( Semaphore_id[ 2 ] );
79
  directive_failed( status, "rtems_semaphore_release" );
80
 
81
  status = rtems_task_set_priority(
82
    RTEMS_SELF,
83
    RTEMS_CURRENT_PRIORITY,
84
    &current_priority
85
  );
86
  directive_failed( status, "PRI5 rtems_task_set_priority CURRENT" );
87
  printf( "PRI5 - priority of PRI5 is %d\n", current_priority );
88
 
89
  (void) rtems_task_suspend( RTEMS_SELF );
90
}

powered by: WebSVN 2.1.0

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