source: rtems/testsuites/mptests/mp08/task1.c @ c499856

4.115
Last change on this file since c499856 was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 2.3 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-2009.
12 *  On-Line Applications Research Corporation (OAR).
13 *
14 *  The license and distribution terms for this file may be
15 *  found in the file LICENSE in this distribution or at
16 *  http://www.rtems.org/license/LICENSE.
17 */
18
19#ifdef HAVE_CONFIG_H
20#include "config.h"
21#endif
22
23#include "system.h"
24
25rtems_task Test_task(
26  rtems_task_argument argument
27)
28{
29  uint32_t    count;
30  rtems_status_code status;
31
32  puts( "Getting SMID of semaphore" );
33
34  do {
35    status = rtems_semaphore_ident(
36      Semaphore_name[ 1 ],
37      RTEMS_SEARCH_ALL_NODES,
38      &Semaphore_id[ 1 ]
39    );
40  } while ( !rtems_is_status_successful( status ) );
41
42  if ( Multiprocessing_configuration.node == 2 ) {
43    status = rtems_semaphore_delete( Semaphore_id[ 1 ] );
44    fatal_directive_status(
45      status,
46      RTEMS_ILLEGAL_ON_REMOTE_OBJECT,
47      "rtems_semaphore_delete did not return RTEMS_ILLEGAL_ON_REMOTE_OBJECT"
48    );
49    puts(
50      "rtems_semaphore_delete correctly returned RTEMS_ILLEGAL_ON_REMOTE_OBJECT"
51    );
52  }
53
54  count = 0;            /* number of times node 1 releases semaphore */
55  while ( FOREVER ) {
56    put_dot( 'p' );
57    status = rtems_semaphore_obtain(
58      Semaphore_id[ 1 ],
59      RTEMS_DEFAULT_OPTIONS,
60      RTEMS_NO_TIMEOUT
61    );
62    if ( status != RTEMS_SUCCESSFUL ) {
63      fatal_directive_status(
64        status,
65        RTEMS_OBJECT_WAS_DELETED,
66        "rtems_semaphore_obtain"
67      );
68      puts( "\nGlobal semaphore deleted" );
69      puts( "*** END OF TEST 8 ***" );
70      rtems_test_exit( 0 );
71    }
72
73    if ( Multiprocessing_configuration.node == 1 && ++count == 1000 ) {
74      status = rtems_task_wake_after( rtems_clock_get_ticks_per_second() );
75      directive_failed( status, "rtems_task_wake_after" );
76
77      puts( "\nDeleting global semaphore" );
78      status = rtems_semaphore_delete( Semaphore_id[ 1 ] );
79      directive_failed( status, "rtems_semaphore_delete" );
80
81      puts( "*** END OF TEST 8 ***" );
82      rtems_test_exit( 0 );
83    }
84    else {
85      put_dot( 'v' );
86      status = rtems_semaphore_release( Semaphore_id[ 1 ] );
87      directive_failed( status, "rtems_semaphore_release FAILED!!" );
88    }
89  }
90}
Note: See TracBrowser for help on using the repository browser.