source: rtems/testsuites/mptests/mp13/task2.c @ 03f2154e

4.104.114.84.95
Last change on this file since 03f2154e was 03f2154e, checked in by Joel Sherrill <joel.sherrill@…>, on Apr 22, 1997 at 5:20:27 PM

headers updated to reflect new style copyright notice as part
of switching to the modified GNU GPL.

  • Property mode set to 100644
File size: 2.8 KB
Line 
1/*  Test_task2
2 *
3 *  This task attempts to receive control of a global semaphore.
4 *  If running on the node on which the semaphore resides, the wait is
5 *  forever, otherwise it times out on a remote semaphore.
6 *
7 *  Input parameters:
8 *    argument - task argument
9 *
10 *  Output parameters:  NONE
11 *
12 *  COPYRIGHT (c) 1989-1997.
13 *  On-Line Applications Research Corporation (OAR).
14 *  Copyright assigned to U.S. Government, 1994.
15 *
16 *  The license and distribution terms for this file may in
17 *  the file LICENSE in this distribution or at
18 *  http://www.OARcorp.com/rtems/license.html.
19 *
20 *  $Id$
21 */
22
23#include "system.h"
24
25rtems_task Test_task2(
26  rtems_task_argument argument
27)
28{
29  rtems_status_code status;
30
31  puts( "Getting SMID of semaphore" );
32  do {
33    status = rtems_semaphore_ident(
34      Semaphore_name[ 1 ],
35      RTEMS_SEARCH_ALL_NODES,
36      &Semaphore_id[ 1 ]
37    );
38  } while ( !rtems_is_status_successful( status ) );
39
40  directive_failed( status, "rtems_semaphore_ident" );
41
42  if ( Multiprocessing_configuration.node == 1 ) {
43    status = rtems_task_wake_after( TICKS_PER_SECOND );
44    directive_failed( status, "rtems_task_wake_after" );
45
46    puts( "Releasing semaphore ..." );
47    status = rtems_semaphore_release( Semaphore_id[ 1 ] );
48    directive_failed( status, "rtems_semaphore_release" );
49
50    status = rtems_task_wake_after( TICKS_PER_SECOND / 2 );
51    directive_failed( status, "rtems_task_wake_after" );
52
53    puts( "Getting semaphore ..." );
54    status = rtems_semaphore_obtain(
55      Semaphore_id[ 1 ],
56      RTEMS_DEFAULT_OPTIONS,
57      RTEMS_NO_TIMEOUT
58    );
59    directive_failed( status, "rtems_semaphore_obtain" );
60
61    puts( "Getting semaphore ..." );
62    status = rtems_semaphore_obtain(
63      Semaphore_id[ 1 ],
64      RTEMS_DEFAULT_OPTIONS,
65      RTEMS_NO_TIMEOUT
66    );
67    puts( "How did I get back from here????" );
68    directive_failed( status, "rtems_semaphore_obtain" );
69  }
70
71/*
72  status = rtems_task_wake_after( TICKS_PER_SECOND / 2 );
73  directive_failed( status, "rtems_task_wake_after" );
74*/
75
76  puts( "Getting semaphore ..." );
77  status = rtems_semaphore_obtain(
78    Semaphore_id[ 1 ],
79    RTEMS_DEFAULT_OPTIONS,
80    RTEMS_NO_TIMEOUT
81  );
82  directive_failed( status, "rtems_semaphore_obtain" );
83
84  puts( "Releasing semaphore ..." );
85  status = rtems_semaphore_release( Semaphore_id[ 1 ] );
86  directive_failed( status, "rtems_semaphore_release" );
87
88  status = rtems_task_wake_after( TICKS_PER_SECOND );
89  directive_failed( status, "rtems_task_wake_after" );
90
91  puts( "Getting semaphore ..." );
92  status = rtems_semaphore_obtain(
93    Semaphore_id[ 1 ],
94    RTEMS_DEFAULT_OPTIONS,
95    2 * TICKS_PER_SECOND
96  );
97  fatal_directive_status(
98    status,
99    RTEMS_TIMEOUT,
100    "rtems_semaphore_obtain"
101  );
102  puts( "rtems_semaphore_obtain correctly returned RTEMS_TIMEOUT" );
103
104  puts( "*** END OF TEST 13 ***" );
105  exit( 0 );
106}
Note: See TracBrowser for help on using the repository browser.