source: rtems/testsuites/mptests/mp08/task1.c @ 8bdcfc4

4.104.114.84.95
Last change on this file since 8bdcfc4 was ac7d5ef0, checked in by Joel Sherrill <joel.sherrill@…>, on May 11, 1995 at 5:39:37 PM

Initial revision

  • Property mode set to 100644
File size: 2.4 KB
Line 
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 *
11 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
12 *  On-Line Applications Research Corporation (OAR).
13 *  All rights assigned to U.S. Government, 1994.
14 *
15 *  This material may be reproduced by or for the U.S. Government pursuant
16 *  to the copyright license under the clause at DFARS 252.227-7013.  This
17 *  notice must appear in all copies of this file and its derivatives.
18 *
19 *  $Id$
20 */
21
22#include "system.h"
23
24rtems_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}
Note: See TracBrowser for help on using the repository browser.