source: rtems/testsuites/smptests/smp03/init.c @ 39e51758

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

smp: Add and use _CPU_SMP_Get_current_processor()

Add and use _SMP_Get_current_processor() and
rtems_smp_get_current_processor().

Delete bsp_smp_interrupt_cpu().

Change type of current processor index from int to uint32_t to match
_SMP_Processor_count type.

  • Property mode set to 100644
File size: 2.3 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
17#include <stdio.h>
18#include <inttypes.h>
19
20void Loop() {
21  volatile int i;
22
23  for (i=0; i<300000; i++);
24}
25
26void PrintTaskInfo(
27  const char *task_name
28)
29{
30  uint32_t cpu_num;
31
32  cpu_num = rtems_smp_get_current_processor();
33
34  locked_printf("  CPU %" PRIu32 " running task %s\n", cpu_num, task_name );
35}
36
37rtems_task Init(
38  rtems_task_argument argument
39)
40{
41  uint32_t          i;
42  char              ch = '0';
43  rtems_id          id;
44  rtems_status_code status;
45
46  Loop();
47  locked_print_initialize();
48
49  locked_printf( "\n\n***  SMP03 TEST ***\n" );
50
51  /* Initialize the TaskRan array */
52  TaskRan[0] = true;
53  for ( i=1; i<rtems_smp_get_processor_count() ; i++ ) {
54    TaskRan[i] = false;
55  }
56
57  /* Show that the init task is running on this cpu */
58  PrintTaskInfo( "Init" );
59
60  /* for each remaining cpu create and start a task */
61  for ( i=1; i < rtems_smp_get_processor_count(); i++ ){
62
63    ch = '0' + i;
64
65    status = rtems_task_create(
66      rtems_build_name( 'T', 'A', ch, ' ' ),
67      CONFIGURE_INIT_TASK_PRIORITY + (2*i),
68      RTEMS_MINIMUM_STACK_SIZE,
69      RTEMS_PREEMPT,
70      RTEMS_DEFAULT_ATTRIBUTES,
71      &id
72    );
73    status = rtems_task_start( id, Test_task, i );
74   
75    /* Allow task to start before starting next task.
76     * This is necessary on some simulators.
77     */
78    while (TaskRan[i] == false)
79      ;
80  }
81
82  /* Create/Start an aditional task with the highest priority */
83  status = rtems_task_create(
84    rtems_build_name( 'T', 'A', ch, ' ' ),
85    3,
86    RTEMS_MINIMUM_STACK_SIZE,
87    RTEMS_PREEMPT,
88    RTEMS_DEFAULT_ATTRIBUTES,
89    &id
90  );
91  status = rtems_task_start(id,Test_task,rtems_smp_get_processor_count());
92
93  /* Wait on all tasks to run */
94  while (1) {
95    TestFinished = true;
96    for ( i=1; i < (rtems_smp_get_processor_count()+1) ; i++ ) {
97      if (TaskRan[i] == false)
98        TestFinished = false;
99    }
100    if (TestFinished) {
101      locked_printf( "*** END OF TEST SMP03 ***\n" );
102      rtems_test_exit( 0 );
103    }
104  }
105
106  rtems_test_exit( 0 );   
107}
Note: See TracBrowser for help on using the repository browser.