[ac7d5ef0] | 1 | /* Test_task |
---|
| 2 | * |
---|
| 3 | * This task tests global semaphore operations. It verifies that |
---|
| 4 | * global semaphore errors are correctly returned. |
---|
| 5 | * |
---|
| 6 | * Input parameters: |
---|
| 7 | * argument - task argument |
---|
| 8 | * |
---|
| 9 | * Output parameters: NONE |
---|
| 10 | * |
---|
[03f2154e] | 11 | * COPYRIGHT (c) 1989-1997. |
---|
[ac7d5ef0] | 12 | * On-Line Applications Research Corporation (OAR). |
---|
[03f2154e] | 13 | * Copyright assigned to U.S. Government, 1994. |
---|
[ac7d5ef0] | 14 | * |
---|
[98e4ebf5] | 15 | * The license and distribution terms for this file may be |
---|
| 16 | * found in the file LICENSE in this distribution or at |
---|
[03f2154e] | 17 | * http://www.OARcorp.com/rtems/license.html. |
---|
[ac7d5ef0] | 18 | * |
---|
| 19 | * $Id$ |
---|
| 20 | */ |
---|
| 21 | |
---|
| 22 | #include "system.h" |
---|
| 23 | |
---|
| 24 | rtems_task Test_task( |
---|
| 25 | rtems_task_argument argument |
---|
| 26 | ) |
---|
| 27 | { |
---|
| 28 | rtems_unsigned32 count; |
---|
| 29 | rtems_status_code status; |
---|
| 30 | |
---|
| 31 | puts( "Getting SMID of semaphore" ); |
---|
| 32 | |
---|
| 33 | do { |
---|
| 34 | status = rtems_semaphore_ident( |
---|
| 35 | Semaphore_name[ 1 ], |
---|
| 36 | RTEMS_SEARCH_ALL_NODES, |
---|
| 37 | &Semaphore_id[ 1 ] |
---|
| 38 | ); |
---|
| 39 | } while ( !rtems_is_status_successful( status ) ); |
---|
| 40 | |
---|
| 41 | if ( Multiprocessing_configuration.node == 2 ) { |
---|
| 42 | status = rtems_semaphore_delete( Semaphore_id[ 1 ] ); |
---|
| 43 | fatal_directive_status( |
---|
| 44 | status, |
---|
| 45 | RTEMS_ILLEGAL_ON_REMOTE_OBJECT, |
---|
| 46 | "rtems_semaphore_delete did not return RTEMS_ILLEGAL_ON_REMOTE_OBJECT" |
---|
| 47 | ); |
---|
| 48 | puts( |
---|
| 49 | "rtems_semaphore_delete correctly returned RTEMS_ILLEGAL_ON_REMOTE_OBJECT" |
---|
| 50 | ); |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | count = 0; /* number of times node 1 releases semaphore */ |
---|
| 54 | while ( FOREVER ) { |
---|
| 55 | put_dot( 'p' ); |
---|
| 56 | status = rtems_semaphore_obtain( |
---|
| 57 | Semaphore_id[ 1 ], |
---|
| 58 | RTEMS_DEFAULT_OPTIONS, |
---|
| 59 | RTEMS_NO_TIMEOUT |
---|
| 60 | ); |
---|
| 61 | if ( status != RTEMS_SUCCESSFUL ) { |
---|
| 62 | fatal_directive_status( |
---|
| 63 | status, |
---|
| 64 | RTEMS_OBJECT_WAS_DELETED, |
---|
| 65 | "rtems_semaphore_obtain" |
---|
| 66 | ); |
---|
| 67 | puts( "\nGlobal semaphore deleted" ); |
---|
| 68 | puts( "*** END OF TEST 8 ***" ); |
---|
| 69 | exit( 0 ); |
---|
| 70 | } |
---|
| 71 | |
---|
| 72 | if ( Multiprocessing_configuration.node == 1 && ++count == 1000 ) { |
---|
| 73 | status = rtems_task_wake_after( TICKS_PER_SECOND ); |
---|
| 74 | directive_failed( status, "rtems_task_wake_after" ); |
---|
| 75 | |
---|
| 76 | puts( "\nDeleting global semaphore" ); |
---|
| 77 | status = rtems_semaphore_delete( Semaphore_id[ 1 ] ); |
---|
| 78 | directive_failed( status, "rtems_semaphore_delete" ); |
---|
| 79 | |
---|
| 80 | puts( "*** END OF TEST 8 ***" ); |
---|
| 81 | exit( 0 ); |
---|
| 82 | } |
---|
| 83 | else { |
---|
| 84 | put_dot( 'v' ); |
---|
| 85 | status = rtems_semaphore_release( Semaphore_id[ 1 ] ); |
---|
| 86 | directive_failed( status, "rtems_semaphore_release FAILED!!" ); |
---|
| 87 | } |
---|
| 88 | } |
---|
| 89 | } |
---|