source: rtems/testsuites/mptests/mp14/smtask1.c @ df40cc9

4.115
Last change on this file since df40cc9 was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

  • 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.org/license/LICENSE.
16 */
17
18#ifdef HAVE_CONFIG_H
19#include "config.h"
20#endif
21
22#include "system.h"
23
24extern rtems_multiprocessing_table Multiprocessing_configuration;
25
26rtems_task Semaphore_task(
27  rtems_task_argument argument
28)
29{
30  uint32_t    count;
31  rtems_status_code status;
32  uint32_t    yield_count;
33
34  puts( "Getting SMID of semaphore" );
35  while ( FOREVER ) {
36    status = rtems_semaphore_ident(
37      Semaphore_name[ 1 ],
38      RTEMS_SEARCH_ALL_NODES,
39      &Semaphore_id[ 1 ]
40    );
41    if ( status == RTEMS_SUCCESSFUL )
42      break;
43    puts( "rtems_semaphore_ident FAILED!!" );
44    rtems_task_wake_after(2);
45  }
46
47  yield_count = 100;
48
49  while ( Stop_Test == false ) {
50
51    for ( count=SEMAPHORE_DOT_COUNT ; Stop_Test == false && count ; count-- ) {
52      status = rtems_semaphore_obtain(
53        Semaphore_id[ 1 ],
54        RTEMS_DEFAULT_OPTIONS,
55        RTEMS_NO_TIMEOUT
56      );
57      directive_failed( status, "rtems_semaphore_obtain" );
58
59      status = rtems_semaphore_release( Semaphore_id[ 1 ] );
60      directive_failed( status, "rtems_semaphore_release" );
61
62      if ( Stop_Test == false )
63        if ( Multiprocessing_configuration.node == 1 && --yield_count == 0 ) {
64          status = rtems_task_wake_after( RTEMS_YIELD_PROCESSOR );
65          directive_failed( status, "rtems_task_wake_after" );
66
67          yield_count = 100;
68        }
69    }
70    put_dot( 's' );
71  }
72
73  Exit_test();
74}
Note: See TracBrowser for help on using the repository browser.