source: rtems/testsuites/mptests/mp14/smtask1.c @ 48e02af

4.115
Last change on this file since 48e02af was a4bc4d6e, checked in by Ralf Corsepius <ralf.corsepius@…>, on 02/22/11 at 10:00:39

Add HAVE_CONFIG_H.

  • 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-1999.
11 *  On-Line Applications Research Corporation (OAR).
12 *
13 *  The license and distribution terms for this file may be
14 *  found in the file LICENSE in this distribution or at
15 *  http://www.rtems.com/license/LICENSE.
16 *
17 *  $Id$
18 */
19
20#ifdef HAVE_CONFIG_H
21#include "config.h"
22#endif
23
24#include "system.h"
25
26extern rtems_multiprocessing_table Multiprocessing_configuration;
27
28rtems_task Semaphore_task(
29  rtems_task_argument argument
30)
31{
32  uint32_t    count;
33  rtems_status_code status;
34  uint32_t    yield_count;
35
36  puts( "Getting SMID of semaphore" );
37  while ( FOREVER ) {
38    status = rtems_semaphore_ident(
39      Semaphore_name[ 1 ],
40      RTEMS_SEARCH_ALL_NODES,
41      &Semaphore_id[ 1 ]
42    );
43    if ( status == RTEMS_SUCCESSFUL )
44      break;
45    puts( "rtems_semaphore_ident FAILED!!" );
46    rtems_task_wake_after(2);
47  }
48
49  yield_count = 100;
50
51  while ( Stop_Test == false ) {
52
53    for ( count=SEMAPHORE_DOT_COUNT ; Stop_Test == false && count ; count-- ) {
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      status = rtems_semaphore_release( Semaphore_id[ 1 ] );
62      directive_failed( status, "rtems_semaphore_release" );
63
64      if ( Stop_Test == false )
65        if ( Multiprocessing_configuration.node == 1 && --yield_count == 0 ) {
66          status = rtems_task_wake_after( RTEMS_YIELD_PROCESSOR );
67          directive_failed( status, "rtems_task_wake_after" );
68
69          yield_count = 100;
70        }
71    }
72    put_dot( 's' );
73  }
74
75  Exit_test();
76}
Note: See TracBrowser for help on using the repository browser.