1 | /* Sm_test_task |
---|
2 | * |
---|
3 | * This task continuously obtains and releases a global semaphore. |
---|
4 | * |
---|
5 | * Input parameters: |
---|
6 | * argument - task argument |
---|
7 | * |
---|
8 | * Output parameters: NONE |
---|
9 | * |
---|
10 | * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. |
---|
11 | * On-Line Applications Research Corporation (OAR). |
---|
12 | * All rights assigned to U.S. Government, 1994. |
---|
13 | * |
---|
14 | * This material may be reproduced by or for the U.S. Government pursuant |
---|
15 | * to the copyright license under the clause at DFARS 252.227-7013. This |
---|
16 | * notice must appear in all copies of this file and its derivatives. |
---|
17 | * |
---|
18 | * $Id$ |
---|
19 | */ |
---|
20 | |
---|
21 | #include "system.h" |
---|
22 | |
---|
23 | extern rtems_multiprocessing_table Multiprocessing_configuration; |
---|
24 | |
---|
25 | rtems_task Semaphore_task( |
---|
26 | rtems_task_argument argument |
---|
27 | ) |
---|
28 | { |
---|
29 | rtems_unsigned32 count; |
---|
30 | rtems_status_code status; |
---|
31 | rtems_unsigned32 yield_count; |
---|
32 | |
---|
33 | puts( "Getting SMID of semaphore" ); |
---|
34 | while ( FOREVER ) { |
---|
35 | status = rtems_semaphore_ident( |
---|
36 | Semaphore_name[ 1 ], |
---|
37 | RTEMS_SEARCH_ALL_NODES, |
---|
38 | &Semaphore_id[ 1 ] |
---|
39 | ); |
---|
40 | if ( status == RTEMS_SUCCESSFUL ) |
---|
41 | break; |
---|
42 | puts( "rtems_semaphore_ident FAILED!!" ); |
---|
43 | } |
---|
44 | |
---|
45 | while ( Stop_Test == FALSE ) { |
---|
46 | yield_count = 100; |
---|
47 | |
---|
48 | for ( count=SEMAPHORE_DOT_COUNT ; Stop_Test == FALSE && count ; count-- ) { |
---|
49 | status = rtems_semaphore_obtain( |
---|
50 | Semaphore_id[ 1 ], |
---|
51 | RTEMS_DEFAULT_OPTIONS, |
---|
52 | RTEMS_NO_TIMEOUT |
---|
53 | ); |
---|
54 | directive_failed( status, "rtems_semaphore_obtain" ); |
---|
55 | |
---|
56 | status = rtems_semaphore_release( Semaphore_id[ 1 ] ); |
---|
57 | directive_failed( status, "rtems_semaphore_release" ); |
---|
58 | |
---|
59 | if ( Multiprocessing_configuration.node == 1 && --yield_count == 0 ) { |
---|
60 | status = rtems_task_wake_after( RTEMS_YIELD_PROCESSOR ); |
---|
61 | directive_failed( status, "rtems_task_wake_after" ); |
---|
62 | |
---|
63 | yield_count = 100; |
---|
64 | } |
---|
65 | } |
---|
66 | put_dot( 's' ); |
---|
67 | } |
---|
68 | |
---|
69 | Exit_test(); |
---|
70 | } |
---|