source: rtems/testsuites/smptests/smp05/init.c @ f9219db

5
Last change on this file since f9219db was f9219db, checked in by Sebastian Huber <sebastian.huber@…>, on 04/05/19 at 06:16:05

rtems: Add rtems_scheduler_get_processor_maximum()

Add rtems_scheduler_get_processor_maximum() as a replacement for
rtems_get_processor_count(). The rtems_get_processor_count() is a bit
orphaned. Adopt it by the Scheduler Manager. The count is also
misleading, since the processor set may have gaps and the actual count
of online processors may be less than the value returned by
rtems_get_processor_count().

Update #3732.

  • Property mode set to 100644
File size: 2.1 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.org/license/LICENSE.
8 */
9
10#ifdef HAVE_CONFIG_H
11#include "config.h"
12#endif
13
14#include <tmacros.h>
15#include "test_support.h"
16
17const char rtems_test_name[] = "SMP 5";
18
19rtems_task Init(
20  rtems_task_argument argument
21);
22
23rtems_task Test_task(
24  rtems_task_argument argument
25);
26
27
28static void success(void)
29{
30  TEST_END();
31  rtems_test_exit( 0 );
32}
33
34rtems_task Test_task(
35  rtems_task_argument argument
36)
37{
38  locked_printf( "Shut down from CPU %" PRIu32 "\n", rtems_scheduler_get_processor() );
39  success();
40}
41
42rtems_task Init(
43  rtems_task_argument argument
44)
45{
46  uint32_t           i;
47  char               ch;
48  uint32_t           cpu_num;
49  rtems_id           id;
50  rtems_status_code  status;
51
52  locked_print_initialize();
53  TEST_BEGIN();
54
55  if ( rtems_scheduler_get_processor_maximum() == 1 ) {
56    success();
57  }
58
59  for ( i=0; i<rtems_scheduler_get_processor_maximum() ; i++ ) {
60    ch = '1' + i;
61
62    status = rtems_task_create(
63      rtems_build_name( 'T', 'A', ch, ' ' ),
64      1,
65      RTEMS_MINIMUM_STACK_SIZE,
66      RTEMS_DEFAULT_MODES,
67      RTEMS_DEFAULT_ATTRIBUTES,
68      &id
69    );
70    directive_failed( status, "task create" );
71
72    cpu_num = rtems_scheduler_get_processor();
73    locked_printf(" CPU %" PRIu32 " start task TA%c\n", cpu_num, ch);
74
75    status = rtems_task_start( id, Test_task, i+1 );
76    directive_failed( status, "task start" );
77  }
78
79  while (1)
80    ;
81}
82
83/* configuration information */
84
85#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
86#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
87
88#define CONFIGURE_MAXIMUM_PROCESSORS   2
89
90#define CONFIGURE_MAXIMUM_TASKS            \
91    (1 + CONFIGURE_MAXIMUM_PROCESSORS)
92#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
93
94#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
95
96#define CONFIGURE_MAXIMUM_SEMAPHORES 1
97
98#define CONFIGURE_INIT
99
100#include <rtems/confdefs.h>
101/* end of file */
Note: See TracBrowser for help on using the repository browser.