source: rtems/testsuites/smptests/smp04/init.c @ 602b1f61

4.115
Last change on this file since 602b1f61 was e049eea, checked in by Joel Sherrill <joel.sherrill@…>, on 06/28/11 at 21:08:48

2011-06-28 Joel Sherrill <joel.sherrill@…>

  • .configure.ac.swp, ChangeLog?, Makefile.am, README, config.h.in, configure.ac, smp01/.cvsignore, smp01/Makefile.am, smp01/init.c, smp01/smp01.doc, smp01/smp01.scn, smp01/system.h, smp01/tasks.c, smp02/.cvsignore, smp02/Makefile.am, smp02/init.c, smp02/smp02.doc, smp02/smp02.scn, smp02/system.h, smp02/tasks.c, smp03/.cvsignore, smp03/Makefile.am, smp03/init.c, smp03/smp03.doc, smp03/smp03.scn, smp03/system.h, smp03/tasks.c, smp04/.cvsignore, smp04/Makefile.am, smp04/init.c, smp04/smp04.doc, smp04/smp04.scn, smp04/system.h, smp04/tasks.c, smp05/.cvsignore, smp05/Makefile.am, smp05/init.c, smp05/smp05.doc, smp05/smp05.scn, smp06/.cvsignore, smp06/Makefile.am, smp06/init.c, smp06/smp06.doc, smp06/smp06.scn, smp07/.cvsignore, smp07/Makefile.am, smp07/init.c, smp07/smp07.doc, smp07/smp07.scn, smp08/.cvsignore, smp08/Makefile.am, smp08/init.c, smp08/smp08.doc, smp08/smp08.scn, smp08/system.h, smp08/tasks.c, smp09/.cvsignore, smp09/Makefile.am, smp09/init.c, smp09/smp09.doc, smp09/smp09.scn: New files.
  • Property mode set to 100644
File size: 2.5 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
21
22void Loop() {
23  volatile int i;
24
25  for (i=0; i<500000; i++);
26}
27
28void PrintTaskInfo(
29  const char *task_name
30)
31{
32  int               cpu_num;
33
34  cpu_num = bsp_smp_processor_id();
35
36  locked_printf("  CPU %d running task %s\n", cpu_num, task_name );
37}
38
39rtems_task Init(
40  rtems_task_argument argument
41)
42{
43  int               i;
44  char              ch;
45  rtems_id          id;
46  rtems_status_code status;
47  bool              allDone;
48
49  Loop();
50  locked_print_initialize();
51  locked_printf( "\n\n***  SMP04 TEST ***\n" );
52
53  PrintTaskInfo( "Init" );
54
55  TaskRan[0] = true;
56  for ( i=1; i <= rtems_smp_get_number_of_processors() ; i++ )
57    TaskRan[i] = false;
58 
59  for ( i=1; i < rtems_smp_get_number_of_processors() ; i++ ){
60
61    /* Create and start tasks for each CPU */
62    ch = '0' + i;
63    locked_printf(
64      "Create a TA%c a %s task\n",
65      ch,
66      ((i%2) ? "RTEMS_PREEMPT" : "RTEMS_NO_PREEMPT" )
67    );
68
69    status = rtems_task_create(
70      rtems_build_name( 'T', 'A', ch, ' ' ),
71      CONFIGURE_INIT_TASK_PRIORITY +
72        (2*rtems_smp_get_number_of_processors()) - (2*i),
73      RTEMS_MINIMUM_STACK_SIZE,
74      ((i%2) ? RTEMS_PREEMPT : RTEMS_NO_PREEMPT),
75      RTEMS_DEFAULT_ATTRIBUTES,
76      &id
77    );
78  }
79
80  for ( i=1; i < rtems_smp_get_number_of_processors() ; i++ ){
81    status = rtems_task_start( id, Test_task, i );
82
83    /* Force a wait on the task to run in order to synchronize on
84     * simulated systems.
85     */   
86    while (TaskRan[i] == false)
87      ;
88  }
89
90  ch = '0' + rtems_smp_get_number_of_processors() ;
91
92  status = rtems_task_create(
93    rtems_build_name( 'T', 'A', ch, ' ' ),
94    3,
95    RTEMS_MINIMUM_STACK_SIZE,
96    RTEMS_PREEMPT,
97    RTEMS_DEFAULT_ATTRIBUTES,
98    &id
99  );
100  status = rtems_task_start(
101    id,
102    Test_task,
103    rtems_smp_get_number_of_processors()
104  );
105 
106  /* Wait on the all tasks to run */
107  while (1) {
108    allDone = true;
109    for ( i=1; i<=rtems_smp_get_number_of_processors() ; i++ ) {
110      if (TaskRan[i] == false)
111        allDone = false;
112    }
113    if (allDone) {
114      Loop();
115      locked_printf( "*** END OF TEST SMP04 ***" );
116      rtems_test_exit( 0 );
117    }
118  }
119}
Note: See TracBrowser for help on using the repository browser.