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/] [sptests/] [sp12/] [task1.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
/*  Task_1
2
 *
3
 *  This routine serves as a test task.  It verifies the semaphore manager.
4
 *
5
 *  Input parameters:
6
 *    argument - task argument
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
 *  $Id: task1.c,v 1.2 2001-09-27 12:02:32 chris Exp $
18
 */
19
 
20
#include "system.h"
21
 
22
rtems_task Task_1(
23
  rtems_task_argument argument
24
)
25
{
26
  rtems_id          smid;
27
  rtems_status_code status;
28
 
29
  status = rtems_semaphore_ident(
30
    Semaphore_name[ 1 ],
31
    RTEMS_SEARCH_ALL_NODES,
32
    &smid
33
  );
34
  printf( "TA1 - rtems_semaphore_ident - smid => %08x\n", smid );
35
  directive_failed( status, "rtems_semaphore_ident of SM1" );
36
 
37
  puts( "TA1 - rtems_semaphore_obtain - wait forever on SM2" );
38
  status = rtems_semaphore_obtain(
39
    Semaphore_id[ 2 ],
40
    RTEMS_DEFAULT_OPTIONS,
41
    RTEMS_NO_TIMEOUT
42
  );
43
  directive_failed( status, "rtems_semaphore_obtain of SM2" );
44
  puts( "TA1 - got SM2" );
45
 
46
  puts( "TA1 - rtems_semaphore_obtain - wait forever on SM3" );
47
  status = rtems_semaphore_obtain(
48
    Semaphore_id[ 3 ],
49
    RTEMS_DEFAULT_OPTIONS,
50
    RTEMS_NO_TIMEOUT
51
  );
52
  directive_failed( status, "rtems_semaphore_obtain of SM3" );
53
  puts( "TA1 - got SM3" );
54
 
55
  puts( "TA1 - rtems_semaphore_obtain - get SM1 - RTEMS_NO_WAIT" );
56
  status = rtems_semaphore_obtain(
57
    Semaphore_id[ 1 ],
58
    RTEMS_NO_WAIT,
59
    RTEMS_NO_TIMEOUT
60
  );
61
  directive_failed( status, "rtems_semaphore_obtain of SM1" );
62
  puts( "TA1 - got SM1" );
63
 
64
  puts( "TA1 - rtems_task_wake_after - sleep 5 seconds" );
65
  status = rtems_task_wake_after( 5*TICKS_PER_SECOND );
66
  directive_failed( status, "rtems_task_wake_after" );
67
 
68
rtems_test_pause();
69
 
70
  puts( "TA1 - rtems_semaphore_release - release SM1" );
71
  status = rtems_semaphore_release( Semaphore_id[ 1 ] );
72
  directive_failed( status, "rtems_semaphore_release of SM1" );
73
 
74
  puts(
75
    "TA1 - rtems_semaphore_obtain - waiting for SM1 with 10 second timeout"
76
  );
77
  status = rtems_semaphore_obtain(
78
    Semaphore_id[ 1 ],
79
    RTEMS_DEFAULT_OPTIONS,
80
    10 * TICKS_PER_SECOND
81
  );
82
  directive_failed( status, "rtems_semaphore_obtain of SM1" );
83
  puts( "TA1 - got SM1" );
84
 
85
  puts( "TA1 - rtems_semaphore_release - release SM2" );
86
  status = rtems_semaphore_release( Semaphore_id[ 2 ] );
87
  directive_failed( status, "rtems_semaphore_release of SM2" );
88
 
89
  puts( "TA1 - rtems_task_wake_after - sleep 5 seconds" );
90
  status = rtems_task_wake_after( 5*TICKS_PER_SECOND );
91
  directive_failed( status, "rtems_task_wake_after" );
92
 
93
rtems_test_pause();
94
 
95
  puts( "TA1 - rtems_task_delete - delete TA3" );
96
  status = rtems_task_delete( Task_id[ 3 ] );
97
  directive_failed( status, "rtems_task_delete of TA3" );
98
 
99
  status = rtems_task_create(
100
    Task_name[ 4 ],
101
    4,
102
    RTEMS_MINIMUM_STACK_SIZE,
103
    RTEMS_DEFAULT_MODES,
104
    RTEMS_DEFAULT_ATTRIBUTES,
105
    &Task_id[ 4 ]
106
  );
107
  directive_failed( status, "rtems_task_create of TA4" );
108
 
109
  status = rtems_task_create(
110
    Task_name[ 5 ],
111
    4,
112
    RTEMS_MINIMUM_STACK_SIZE,
113
    RTEMS_DEFAULT_MODES,
114
    RTEMS_DEFAULT_ATTRIBUTES,
115
    &Task_id[ 5 ]
116
   );
117
  directive_failed( status, "rtems_task_create of TA5" );
118
 
119
  status = rtems_task_start( Task_id[ 4 ], Task_4, 0 );
120
  directive_failed( status, "rtems_task_start of TA4" );
121
 
122
  status = rtems_task_start( Task_id[ 5 ], Task5, 0 );
123
  directive_failed( status, "rtems_task_start of TA5" );
124
 
125
  puts( "TA1 - rtems_task_wake_after - sleep 5 seconds" );
126
  status = rtems_task_wake_after( 5*TICKS_PER_SECOND );
127
  directive_failed( status, "rtems_task_wake_after" );
128
 
129
  puts( "TA1 - rtems_task_delete - delete TA4" );
130
  status = rtems_task_delete( Task_id[ 4 ] );
131
  directive_failed( status, "rtems_task_delete of TA4" );
132
 
133
  puts( "TA1 - rtems_semaphore_release - release SM1" );
134
  status = rtems_semaphore_release( Semaphore_id[ 1 ] );
135
  directive_failed( status, "rtems_semaphore_release on SM1" );
136
 
137
  puts( "TA1 - rtems_task_wake_after - sleep 5 seconds" );
138
  status = rtems_task_wake_after( 5*TICKS_PER_SECOND );
139
  directive_failed( status, "rtems_task_wake_after" );
140
 
141
  puts( "TA1 - rtems_semaphore_delete - delete SM1" );
142
  status = rtems_semaphore_delete( Semaphore_id[ 1 ] );
143
  directive_failed( status, "rtems_semaphore_delete of SM1" );
144
 
145
  puts( "TA1 - rtems_semaphore_delete - delete SM3" );
146
  status = rtems_semaphore_delete( Semaphore_id[ 3 ] );
147
  directive_failed( status, "rtems_semaphore_delete of SM3" );
148
 
149
  puts( "TA1 - rtems_task_delete - delete self" );
150
  status = rtems_task_delete( RTEMS_SELF );
151
  directive_failed( status, "rtems_task_delete of TA1" );
152
}

powered by: WebSVN 2.1.0

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