OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [tests/] [tmtests/] [tm03/] [task1.c] - Blame information for rev 547

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

Line No. Rev Author Line
1 30 unneback
/*
2
 *
3
 *  COPYRIGHT (c) 1989-1999.
4
 *  On-Line Applications Research Corporation (OAR).
5
 *
6
 *  The license and distribution terms for this file may be
7
 *  found in the file LICENSE in this distribution or at
8
 *  http://www.OARcorp.com/rtems/license.html.
9
 *
10
 *  $Id: task1.c,v 1.2 2001-09-27 12:02:41 chris Exp $
11
 */
12
 
13
#define TEST_INIT
14
#include "system.h"
15
 
16
rtems_id Semaphore_id;
17
rtems_task test_init(
18
  rtems_task_argument argument
19
);
20
 
21
rtems_task Middle_tasks(
22
  rtems_task_argument argument
23
);
24
 
25
rtems_task High_task(
26
  rtems_task_argument argument
27
);
28
 
29
 
30
rtems_task Init(
31
  rtems_task_argument argument
32
)
33
{
34
  rtems_status_code status;
35
  rtems_id          task_id;
36
 
37
  Print_Warning();
38
 
39
  puts( "\n\n*** TIME TEST 3 ***" );
40
  status = rtems_task_create(
41
    rtems_build_name( 'T', 'A', '1', ' ' ),
42
    252,
43
    RTEMS_MINIMUM_STACK_SIZE,
44
    RTEMS_DEFAULT_MODES,
45
    RTEMS_DEFAULT_ATTRIBUTES,
46
    &task_id
47
  );
48
  directive_failed( status, "rtems_task_create of test_init" );
49
 
50
  status = rtems_task_start( task_id, test_init, 0 );
51
  directive_failed( status, "rtems_task_start of test_init" );
52
 
53
  status = rtems_task_delete( RTEMS_SELF );
54
  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
55
}
56
 
57
rtems_task test_init(
58
  rtems_task_argument argument
59
)
60
{
61
  rtems_status_code   status;
62
  rtems_unsigned32    index;
63
  rtems_id            task_id;
64
  rtems_task_priority priority;
65
 
66
  priority = 250;
67
 
68
  status = rtems_semaphore_create(
69
    rtems_build_name( 'S', 'M', '1', '\0'),
70
    0,
71
    RTEMS_DEFAULT_ATTRIBUTES,
72
    RTEMS_NO_PRIORITY,
73
    &Semaphore_id
74
  );
75
  directive_failed( status, "rtems_semaphore_create of SM1" );
76
 
77
  for ( index = 2 ; index <= OPERATION_COUNT ; index ++ ) {
78
    rtems_task_create(
79
      rtems_build_name( 'M', 'I', 'D', ' ' ),
80
      priority,
81
      RTEMS_MINIMUM_STACK_SIZE,
82
      RTEMS_DEFAULT_MODES,
83
      RTEMS_DEFAULT_ATTRIBUTES,
84
      &task_id
85
    );
86
    directive_failed( status, "rtems_task_create middle" );
87
 
88
    priority--;
89
 
90
    rtems_task_start( task_id, Middle_tasks, 0 );
91
    directive_failed( status, "rtems_task_start middle" );
92
  }
93
 
94
  status = rtems_task_create(
95
    rtems_build_name( 'H', 'I', 'G', 'H' ),
96
    priority,
97
    RTEMS_MINIMUM_STACK_SIZE,
98
    RTEMS_DEFAULT_MODES,
99
    RTEMS_DEFAULT_ATTRIBUTES,
100
    &task_id
101
  );
102
  directive_failed( status, "rtems_task_create of high task" );
103
 
104
  status = rtems_task_start( task_id, High_task, 0 );
105
  directive_failed( status, "rtems_task_start of high task" );
106
 
107
  Timer_initialize();                          /* start the timer */
108
  status = rtems_semaphore_release( Semaphore_id );
109
}
110
 
111
rtems_task Middle_tasks(
112
  rtems_task_argument argument
113
)
114
{
115
  rtems_status_code status;
116
 
117
  status = rtems_semaphore_obtain(
118
    Semaphore_id,
119
    RTEMS_DEFAULT_OPTIONS,
120
    RTEMS_NO_TIMEOUT
121
  );
122
 
123
  status = rtems_semaphore_release( Semaphore_id );
124
}
125
 
126
rtems_task High_task(
127
  rtems_task_argument argument
128
)
129
{
130
  rtems_status_code status;
131
 
132
  status = rtems_semaphore_obtain(
133
    Semaphore_id,
134
    RTEMS_DEFAULT_OPTIONS,
135
    RTEMS_NO_TIMEOUT
136
  );
137
 
138
  end_time = Read_timer();
139
 
140
  put_time(
141
    "rtems_semaphore_release: task readied -- preempts caller",
142
    end_time,
143
    OPERATION_COUNT,
144
    0,
145
    CALLING_OVERHEAD_SEMAPHORE_RELEASE
146
  );
147
 
148
  puts( "*** END OF TEST 3 ***" );
149
  exit( 0 );
150
}

powered by: WebSVN 2.1.0

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