source: rtems/testsuites/mptests/mp14/smtask1.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: 1.8 KB
Line 
1/*  Sm_test_task
2 *
3 *  This task continuously obtains and releases a global semaphore.
4 *
5 *  Input parameters:
6 *    argument - task argument
7 *
8 *  Output parameters:  NONE
9 *
10 *  COPYRIGHT (c) 1989-1997.
11 *  On-Line Applications Research Corporation (OAR).
12 *  Copyright assigned to U.S. Government, 1994.
13 *
14 *  The license and distribution terms for this file may in
15 *  the file LICENSE in this distribution or at
16 *  http://www.OARcorp.com/rtems/license.html.
17 *
18 *  $Id$
19 */
20
21#include "system.h"
22
23extern rtems_multiprocessing_table Multiprocessing_configuration;
24
25rtems_task Semaphore_task(
26  rtems_task_argument argument
27)
28{
29  rtems_unsigned32  count;
30  rtems_status_code status;
31  rtems_unsigned32  yield_count;
32
33  puts( "Getting SMID of semaphore" );
34  while ( FOREVER ) {
35    status = rtems_semaphore_ident(
36      Semaphore_name[ 1 ],
37      RTEMS_SEARCH_ALL_NODES,
38      &Semaphore_id[ 1 ]
39    );
40    if ( status == RTEMS_SUCCESSFUL )
41      break;
42    puts( "rtems_semaphore_ident FAILED!!" );
43    rtems_task_wake_after(2);
44  }
45
46  yield_count = 100;
47
48  while ( Stop_Test == FALSE ) {
49
50    for ( count=SEMAPHORE_DOT_COUNT ; Stop_Test == FALSE && count ; count-- ) {
51      status = rtems_semaphore_obtain(
52        Semaphore_id[ 1 ],
53        RTEMS_DEFAULT_OPTIONS,
54        RTEMS_NO_TIMEOUT
55      );
56      directive_failed( status, "rtems_semaphore_obtain" );
57
58      status = rtems_semaphore_release( Semaphore_id[ 1 ] );
59      directive_failed( status, "rtems_semaphore_release" );
60
61      if ( Stop_Test == FALSE )
62        if ( Multiprocessing_configuration.node == 1 && --yield_count == 0 ) {
63          status = rtems_task_wake_after( RTEMS_YIELD_PROCESSOR );
64          directive_failed( status, "rtems_task_wake_after" );
65
66          yield_count = 100;
67        }
68    }
69    put_dot( 's' );
70  }
71
72  Exit_test();
73}
Note: See TracBrowser for help on using the repository browser.