source: rtems/testsuites/smptests/smp03/init.c @ 5c283458

4.115
Last change on this file since 5c283458 was 5c283458, checked in by Jennifer Averett <Jennifer.Averett@…>, on 07/29/11 at 18:14:49

2011-07-29 Jennifer Averett <Jennifer.Averett@…>

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