source: rtems/testsuites/smptests/smp06/init.c @ d1c5c01f

4.11
Last change on this file since d1c5c01f was d19cce29, checked in by Sebastian Huber <sebastian.huber@…>, on Aug 5, 2013 at 12:54:11 PM

score: Per-CPU thread dispatch disable level

Use a per-CPU thread dispatch disable level. So instead of one global
thread dispatch disable level we have now one instance per processor.
This is a major performance improvement for SMP. On non-SMP
configurations this may simplifiy the interrupt entry/exit code.

The giant lock is still present, but it is now decoupled from the thread
dispatching in _Thread_Dispatch(), _Thread_Handler(),
_Thread_Restart_self() and the interrupt entry/exit. Access to the
giant lock is now available via _Giant_Acquire() and _Giant_Release().
The giant lock is still implicitly acquired via
_Thread_Dispatch_decrement_disable_level().

The giant lock is only acquired for high-level operations in interrupt
handlers (e.g. release of a semaphore, sending of an event).

As a side-effect this change fixes the lost thread dispatch necessary
indication bug in _Thread_Dispatch().

A per-CPU thread dispatch disable level greatly simplifies the SMP
support for the interrupt entry/exit code since no spin locks have to be
acquired in this area. It is only necessary to get the current
processor index and use this to calculate the address of the own per-CPU
control. This reduces the interrupt latency considerably.

All elements for the interrupt entry/exit code are now part of the
Per_CPU_Control structure: thread dispatch disable level, ISR nest level
and thread dispatch necessary. Nothing else is required (except CPU
port specific stuff like on SPARC).

  • Property mode set to 100644
File size: 2.8 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#include <tmacros.h>
15#include "test_support.h"
16
17volatile bool Ran;
18
19static void success(void)
20{
21  locked_printf( "*** END OF TEST SMP06 ***\n" );
22  rtems_test_exit( 0 );
23}
24
25rtems_task Test_task(
26  rtems_task_argument do_exit
27)
28{
29  uint32_t          cpu_num;
30  char              name[5];
31  char             *p;
32
33  p = rtems_object_get_name( RTEMS_SELF, 5, name );
34  rtems_test_assert( p != NULL );
35
36  cpu_num = rtems_smp_get_current_processor();
37  locked_printf(" CPU %" PRIu32 " running Task %s\n", cpu_num, name);
38
39  Ran = true;
40
41  if ( do_exit ) {
42    success();
43  }
44  while(1)
45    ;
46}
47
48rtems_task Init(
49  rtems_task_argument argument
50)
51{
52  uint32_t           cpu_num;
53  rtems_id           id;
54  rtems_status_code  status;
55
56  locked_print_initialize();
57  locked_printf( "\n\n*** TEST SMP06 ***\n" );
58
59  if ( rtems_smp_get_processor_count() == 1 ) {
60    success();
61  }
62
63  locked_printf( "rtems_clock_tick - so this task has run longer\n" );
64  status = rtems_clock_tick();
65  directive_failed( status, "clock tick" );
66
67  cpu_num = rtems_smp_get_current_processor();
68
69  /*
70   * Create a task at equal priority.
71   */
72  Ran = false;
73  status = rtems_task_create(
74    rtems_build_name( 'T', 'A', '1', ' ' ),
75    2,
76    RTEMS_MINIMUM_STACK_SIZE,
77    RTEMS_PREEMPT,
78    RTEMS_DEFAULT_ATTRIBUTES,
79    &id
80  );
81  directive_failed( status, "task create" );
82
83  locked_printf(" CPU %" PRIu32 " start task TA1\n", cpu_num );
84
85  status = rtems_task_start( id, Test_task, 0 );
86  directive_failed( status, "task start" );
87
88  while ( Ran == false )
89    ;
90
91  /*
92   * Create a task at greater priority.
93   */
94  Ran = false;
95  status = rtems_task_create(
96    rtems_build_name( 'T', 'A', '2', ' ' ),
97    1,
98    RTEMS_MINIMUM_STACK_SIZE,
99    RTEMS_PREEMPT,
100    RTEMS_DEFAULT_ATTRIBUTES,
101    &id
102  );
103  directive_failed( status, "task create" );
104
105  cpu_num = rtems_smp_get_current_processor();
106  locked_printf(" CPU %" PRIu32 " start task TA2\n", cpu_num );
107
108  status = rtems_task_start( id, Test_task, 1 );
109  directive_failed( status, "task start" );
110
111  while ( 1 )
112    ;
113}
114
115/* configuration information */
116
117#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
118#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
119
120#define CONFIGURE_SMP_APPLICATION
121#define CONFIGURE_SMP_MAXIMUM_PROCESSORS  2
122
123#define CONFIGURE_MAXIMUM_TASKS           4
124
125#define CONFIGURE_MAXIMUM_SEMAPHORES 1
126
127#define CONFIGURE_INIT_TASK_PRIORITY      2
128#define CONFIGURE_INIT_TASK_INITIAL_MODES RTEMS_PREEMPT
129#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
130
131#define CONFIGURE_INIT
132
133#include <rtems/confdefs.h>
134/* end of file */
Note: See TracBrowser for help on using the repository browser.