source: rtems/c/src/tests/mptests/mp14/smtask1.c @ 0836603

4.104.114.84.95
Last change on this file since 0836603 was 2122a0b, checked in by Joel Sherrill <joel.sherrill@…>, on 09/19/95 at 21:44:33

Modifications from Tony Bennett accepted to tune this test a little.

  • Property mode set to 100644
File size: 1.9 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, 1990, 1991, 1992, 1993, 1994.
11 *  On-Line Applications Research Corporation (OAR).
12 *  All rights assigned to U.S. Government, 1994.
13 *
14 *  This material may be reproduced by or for the U.S. Government pursuant
15 *  to the copyright license under the clause at DFARS 252.227-7013.  This
16 *  notice must appear in all copies of this file and its derivatives.
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.