source: rtems/testsuites/smptests/smp01/init.c @ edde99b

4.115
Last change on this file since edde99b was edde99b, checked in by Sebastian Huber <sebastian.huber@…>, on 06/14/13 at 12:26:34

score: Rename rtems_smp_get_number_of_processors()

Rename in rtems_smp_get_processor_count(). Always provide
<rtems/score/smp.h> and <rtems/rtems/smp.h>. Add
_SMP_Get_processor_count(). This function will be a compile time
constant defined to be one on uni-processor configurations. This allows
iterations over all processors without overhead on uni-processor
configurations.

  • Property mode set to 100644
File size: 1.9 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2011.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.com/license/LICENSE.
8 */
9
10#ifdef HAVE_CONFIG_H
11#include "config.h"
12#endif
13
14#define CONFIGURE_INIT
15#include "system.h"
16
17void Loop() {
18  volatile int i;
19
20  for (i=0; i<300000; i++);
21}
22
23rtems_task Init(
24  rtems_task_argument argument
25)
26{
27  int                i;
28  char               ch;
29  int                cpu_self;
30  rtems_id           id;
31  rtems_status_code  status;
32  bool               allDone;
33
34  cpu_self = bsp_smp_processor_id();
35
36  /* XXX - Delay a bit to allow debug messages from
37   * startup to print.  This may need to go away when
38   * debug messages go away.
39   */
40  Loop();
41  locked_print_initialize();
42
43  /* Put start of test message */
44  locked_printf( "\n\n***  SMP01 TEST ***\n" );
45
46  /* Initialize the TaskRan array */
47  for ( i=0; i<rtems_smp_get_processor_count() ; i++ ) {
48    TaskRan[i] = false;
49  }
50
51  /* Create and start tasks for each processor */
52  for ( i=0; i< rtems_smp_get_processor_count() ; i++ ) {
53    if ( i != cpu_self ) {
54      ch = '0' + i;
55
56      status = rtems_task_create(
57        rtems_build_name( 'T', 'A', ch, ' ' ),
58        1,
59        RTEMS_MINIMUM_STACK_SIZE,
60        RTEMS_DEFAULT_MODES,
61        RTEMS_DEFAULT_ATTRIBUTES,
62        &id
63      );
64      directive_failed( status, "task create" );
65
66      locked_printf(" CPU %d start task TA%c\n", cpu_self, ch);
67      status = rtems_task_start( id, Test_task, i+1 );
68      directive_failed( status, "task start" );
69
70      Loop();
71    }
72  }
73 
74  /* Wait on the all tasks to run */
75  while (1) {
76    allDone = true;
77    for ( i=0; i<rtems_smp_get_processor_count() ; i++ ) {
78      if ( i != cpu_self && TaskRan[i] == false)
79        allDone = false;
80    }
81    if (allDone) {
82      locked_printf( "*** END OF TEST SMP01 ***\n" );
83      rtems_test_exit( 0 );
84    }
85  }
86
87}
Note: See TracBrowser for help on using the repository browser.