OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [tests/] [mptests/] [mp13/] [task2.c] - Blame information for rev 173

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*  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-1999.
13
 *  On-Line Applications Research Corporation (OAR).
14
 *
15
 *  The license and distribution terms for this file may be
16
 *  found in the file LICENSE in this distribution or at
17
 *  http://www.OARcorp.com/rtems/license.html.
18
 *
19
 *  $Id: task2.c,v 1.2 2001-09-27 12:02:22 chris Exp $
20
 */
21
 
22
#include "system.h"
23
 
24
rtems_task Test_task2(
25
  rtems_task_argument argument
26
)
27
{
28
  rtems_status_code status;
29
 
30
  puts( "Getting SMID of semaphore" );
31
  do {
32
    status = rtems_semaphore_ident(
33
      Semaphore_name[ 1 ],
34
      RTEMS_SEARCH_ALL_NODES,
35
      &Semaphore_id[ 1 ]
36
    );
37
  } while ( !rtems_is_status_successful( status ) );
38
 
39
  directive_failed( status, "rtems_semaphore_ident" );
40
 
41
  if ( Multiprocessing_configuration.node == 1 ) {
42
    status = rtems_task_wake_after( TICKS_PER_SECOND );
43
    directive_failed( status, "rtems_task_wake_after" );
44
 
45
    puts( "Releasing semaphore ..." );
46
    status = rtems_semaphore_release( Semaphore_id[ 1 ] );
47
    directive_failed( status, "rtems_semaphore_release" );
48
 
49
    status = rtems_task_wake_after( TICKS_PER_SECOND / 2 );
50
    directive_failed( status, "rtems_task_wake_after" );
51
 
52
    puts( "Getting semaphore ..." );
53
    status = rtems_semaphore_obtain(
54
      Semaphore_id[ 1 ],
55
      RTEMS_DEFAULT_OPTIONS,
56
      RTEMS_NO_TIMEOUT
57
    );
58
    directive_failed( status, "rtems_semaphore_obtain" );
59
 
60
    puts( "Getting semaphore ..." );
61
    status = rtems_semaphore_obtain(
62
      Semaphore_id[ 1 ],
63
      RTEMS_DEFAULT_OPTIONS,
64
      RTEMS_NO_TIMEOUT
65
    );
66
    puts( "How did I get back from here????" );
67
    directive_failed( status, "rtems_semaphore_obtain" );
68
  }
69
 
70
/*
71
  status = rtems_task_wake_after( TICKS_PER_SECOND / 2 );
72
  directive_failed( status, "rtems_task_wake_after" );
73
*/
74
 
75
  puts( "Getting semaphore ..." );
76
  status = rtems_semaphore_obtain(
77
    Semaphore_id[ 1 ],
78
    RTEMS_DEFAULT_OPTIONS,
79
    RTEMS_NO_TIMEOUT
80
  );
81
  directive_failed( status, "rtems_semaphore_obtain" );
82
 
83
  puts( "Releasing semaphore ..." );
84
  status = rtems_semaphore_release( Semaphore_id[ 1 ] );
85
  directive_failed( status, "rtems_semaphore_release" );
86
 
87
  status = rtems_task_wake_after( TICKS_PER_SECOND );
88
  directive_failed( status, "rtems_task_wake_after" );
89
 
90
  puts( "Getting semaphore ..." );
91
  status = rtems_semaphore_obtain(
92
    Semaphore_id[ 1 ],
93
    RTEMS_DEFAULT_OPTIONS,
94
    2 * TICKS_PER_SECOND
95
  );
96
  fatal_directive_status(
97
    status,
98
    RTEMS_TIMEOUT,
99
    "rtems_semaphore_obtain"
100
  );
101
  puts( "rtems_semaphore_obtain correctly returned RTEMS_TIMEOUT" );
102
 
103
  puts( "*** END OF TEST 13 ***" );
104
  exit( 0 );
105
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.