Changeset 2d51251 in rtems-schedsim
- Timestamp:
- 05/09/14 13:35:58 (10 years ago)
- Branches:
- master
- Children:
- b1b31c0
- Parents:
- 0745eed
- git-author:
- Jennifer Averett <jennifer.averett@…> (05/09/14 13:35:58)
- git-committer:
- Jennifer Averett <jennifer.averett@…> (05/09/14 13:37:18)
- Location:
- schedsim
- Files:
-
- 9 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
schedsim/configure.ac
r0745eed r2d51251 77 77 [1], 78 78 [if SMP is enabled]) 79 80 RTEMS_CPUOPT([__RTEMS_HAVE_SYS_CPUSET_H__], 81 [true], 82 [1], 83 [<sys/cpuset.h> is provided]) 79 84 80 85 RTEMS_CPUOPT([RTEMS_NETWORKING], -
schedsim/rtems/Makefile.am
r0745eed r2d51251 4 4 5 5 cpukitdir=@rtems_srcdir@/cpukit 6 rtemscdir=@rtems_srcdir@/c 6 7 librtems_a_CPPFLAGS = -D__RTEMS_VIOLATE_KERNEL_VISIBILITY__ 8 librtems_a_CPPFLAGS += -D_GNU_SOURCE 7 9 librtems_a_CPPFLAGS += -I$(top_builddir)/score/include 8 10 librtems_a_CPPFLAGS += -I$(srcdir)/sched_cpu … … 246 248 librtems_a_SOURCES += $(cpukitdir)/score/src/schedulerprioritysmp.c 247 249 librtems_a_SOURCES += $(cpukitdir)/score/src/schedulersimplesmp.c 248 librtems_a_SOURCES += $(cpukitdir)/score/src/schedulersmpstartidle.c 250 librtems_a_SOURCES += $(cpukitdir)/score/src/debugisthreaddispatchingallowed.c 251 librtems_a_SOURCES += $(cpukitdir)/score/src/schedulerdefaultgetaffinity.c 252 librtems_a_SOURCES += $(cpukitdir)/score/src/schedulerdefaultsetaffinity.c 253 librtems_a_SOURCES += $(cpukitdir)/score/src/cpuset.c 249 254 endif 250 255 … … 255 260 256 261 schedsim_include_HEADERS = \ 257 ${cpukitdir}/rtems/include/rtems.h 262 ${cpukitdir}/rtems/include/rtems.h \ 263 sched_cpu/stdatomic.h \ 264 sched_cpu/sys/_types.h \ 265 sched_cpu/machine/_types.h \ 266 sched_cpu/machine/_default_types.h \ 267 sched_cpu/sys/features.h \ 268 sched_cpu/sys/lock.h \ 269 sched_cpu/sys/cpuset.h 258 270 259 271 schedsim_rtems_include_HEADERS = \ … … 282 294 $(cpukitdir)/libcsupport/include/rtems/malloc.h \ 283 295 sched_cpu/rtems/stringto.h \ 284 sched_cpu/rtems/asm.h 296 sched_cpu/rtems/asm.h 285 297 286 298 if HAS_PTHREADS … … 293 305 ${cpukitdir}/score/include/rtems/score/coremutex.h \ 294 306 ${cpukitdir}/score/include/rtems/score/corerwlock.h \ 307 ${cpukitdir}/score/include/rtems/score/cpuset.h \ 308 ${cpukitdir}/score/include/rtems/score/cpusetimpl.h \ 309 ${cpukitdir}/score/include/rtems/score/cpustdatomic.h \ 295 310 ${cpukitdir}/score/include/rtems/score/threadsync.h \ 296 311 ${cpukitdir}/score/include/rtems/score/priority.h \ … … 335 350 $(top_builddir)/score/include/rtems/score/cpuopts.h \ 336 351 sched_cpu/rtems/score/cpu.h \ 352 sched_cpu/rtems/score/cpuatomic.h \ 337 353 sched_cpu/rtems/score/types.h \ 338 354 sched_cpu/rtems/score/no_cpu.h -
schedsim/rtems/rtems_init.c
r0745eed r2d51251 46 46 47 47 #include <rtems/posix/keyimpl.h> 48 49 void Init__wrap__Thread_Dispatch(); 48 50 49 51 /* … … 136 138 _System_state_Set( SYSTEM_STATE_UP ); 137 139 138 _SMP_Request_start_multitasking();140 _SMP_Request_start_multitasking(); 139 141 140 142 _Thread_Start_multitasking(); 143 144 /* Add Initialization of the Thread_Dispatch wrapper */ 145 Init__wrap__Thread_Dispatch(); 141 146 142 147 /* … … 144 149 */ 145 150 #if defined(RTEMS_SMP) 146 #error "NOT IMPLEMENTED" 151 { 152 ISR_Level level; 153 154 /* 155 * On SMP we enter _Thread_Handler() with interrupts disabled and 156 * _Thread_Dispatch() obtained the per-CPU lock for us. We have to 157 * release it here and set the desired interrupt level of the thread. 158 */ 159 Per_CPU_Control *cpu_self = _Per_CPU_Get(); 160 161 _Assert( cpu_self->thread_dispatch_disable_level == 1 ); 162 _Assert( _ISR_Get_level() != 0 ); 163 164 cpu_self->thread_dispatch_disable_level = 0; 165 _Profiling_Thread_dispatch_enable( cpu_self, 0 ); 166 167 _Per_CPU_Release( cpu_self ); 168 169 level = _Thread_Executing->Start.isr_level; 170 _ISR_Set_level( level); 171 172 /* 173 * The thread dispatch level changed from one to zero. Make sure we lose 174 * no thread dispatch necessary update. 175 */ 176 _Thread_Dispatch(); 177 } 147 178 #else 148 179 _Thread_Enable_dispatch(); -
schedsim/rtems/sched_cpu/cpu.c
r0745eed r2d51251 20 20 #include <rtems/score/wkspace.h> 21 21 22 int _CPU_ISR_level_on_sched_cpu; 23 22 24 /* _CPU_Initialize 23 25 * … … 33 35 void _CPU_Initialize(void) 34 36 { 35 /* 36 * If there is not an easy way to initialize the FP context 37 * during Context_Initialize, then it is usually easier to 38 * save an "uninitialized" FP context here and copy it to 39 * the task's during Context_Initialize. 40 */ 41 42 /* FP context initialization support goes here */ 37 _CPU_ISR_level_on_sched_cpu = 1; 43 38 } 44 39 45 /*PAGE 46 * 47 * _CPU_ISR_Get_level 48 * 49 * NO_CPU Specific Information: 50 * 51 * XXX document implementation including references if appropriate 52 */ 53 54 uint32_t _CPU_ISR_Get_level( void ) 55 { 56 /* 57 * This routine returns the current interrupt level. 58 */ 59 60 return 0; 61 } 62 63 /*PAGE 64 * 40 /* 65 41 * _CPU_ISR_install_raw_handler 66 42 * … … 82 58 } 83 59 84 /*PAGE 85 * 60 /* 86 61 * _CPU_ISR_install_vector 87 62 * … … 126 101 } 127 102 128 /*PAGE 129 * 103 /* 130 104 * _CPU_Install_interrupt_stack 131 105 * … … 139 113 } 140 114 141 /*PAGE 142 * 115 /* 143 116 * _CPU_Thread_Idle_body 144 117 * -
schedsim/rtems/sched_cpu/rtems/score/cpu.h
r0745eed r2d51251 721 721 722 722 /** 723 * XXX fake cpu isr level variable 724 */ 725 extern int _CPU_ISR_level_on_sched_cpu; 726 727 /** 723 728 * @ingroup CPUInterrupt 724 729 * Disable all interrupts for an RTEMS critical section. The previous … … 733 738 #define _CPU_ISR_Disable( _isr_cookie ) \ 734 739 { \ 735 (_isr_cookie) = 0; /* do something to prevent warnings */ \ 740 (_isr_cookie) = _CPU_ISR_level_on_sched_cpu; \ 741 _CPU_ISR_level_on_sched_cpu = 1; \ 736 742 } 737 743 … … 750 756 #define _CPU_ISR_Enable( _isr_cookie ) \ 751 757 { \ 758 _CPU_ISR_level_on_sched_cpu = (_isr_cookie); \ 752 759 } 753 760 … … 788 795 #define _CPU_ISR_Set_level( new_level ) \ 789 796 { \ 797 _CPU_ISR_level_on_sched_cpu = (new_level); \ 790 798 } 791 799 … … 801 809 * XXX document implementation including references if appropriate 802 810 */ 803 uint32_t _CPU_ISR_Get_level( void ); 811 #define _CPU_ISR_Get_level() (uint32_t) _CPU_ISR_level_on_sched_cpu 804 812 805 813 /* end of ISR handler macros */ … … 1221 1229 #define _CPU_Context_switch_to_first_task_smp(_context ) 1222 1230 1223 RTEMS_COMPILER_PURE_ATTRIBUTE static inline uint32_t 1224 _CPU_SMP_Get_current_processor( void ) 1225 { 1226 return 0; 1227 } 1228 1229 #define _CPU_SMP_Send_interrupt( dest); 1230 1231 static inline void _CPU_SMP_Processor_event_broadcast( void ) 1232 { 1233 } 1234 1235 static inline void _CPU_SMP_Processor_event_receive( void ) 1236 { 1237 } 1231 uint32_t _CPU_SMP_Get_current_processor( void ); 1232 uint32_t _CPU_SMP_Initialize( void ); 1233 bool _CPU_SMP_Start_processor( uint32_t cpu_index ); 1234 void _CPU_SMP_Finalize_initialization( uint32_t cpu_count ); 1235 void _CPU_SMP_Send_interrupt( uint32_t target_processor_index ); 1236 void _CPU_SMP_Processor_event_broadcast( void ); 1237 void _CPU_SMP_Processor_event_receive( void ); 1238 1238 #endif 1239 1239 typedef struct { -
schedsim/shell/schedsim_priority/smp_stub.c
r0745eed r2d51251 12 12 #include <rtems.h> 13 13 #include <rtems/bspIo.h> 14 #include <rtems/bspsmp.h>15 14 #include <stdlib.h> 16 15 16 uint32_t _CPU_SMP_Initialize( void ) 17 { 18 /* return the number of CPUs */ 19 return 1; /* XXX */ 20 } 17 21 18 void bsp_smp_secondary_cpu_initialize(int cpu) 22 bool _CPU_SMP_Start_processor( uint32_t cpu_index ) 23 { 24 return true; 25 } 26 27 void _CPU_SMP_Finalize_initialization( uint32_t cpu_count ) 19 28 { 20 29 } 21 30 22 int bsp_smp_processor_id(void) 31 void _CPU_SMP_Send_interrupt( uint32_t target_processor_index ) 32 { 33 } 34 35 void _CPU_SMP_Processor_event_broadcast( void ) 36 { 37 } 38 39 void _CPU_SMP_Processor_event_receive( void ) 40 { 41 } 42 43 uint32_t _CPU_SMP_Get_current_processor( void ) 23 44 { 24 45 return 0; 25 46 } 26 27 uint32_t bsp_smp_initialize(28 uint32_t configured_cpu_count29 )30 {31 /* return the number of CPUs */32 return configured_cpu_count;33 }34 35 void bsp_smp_broadcast_interrupt(void)36 {37 }38 39 void bsp_smp_broadcast_message(40 uint32_t message41 )42 {43 }44 45 void bsp_smp_interrupt_cpu(46 int cpu47 )48 {49 }50 51 void bsp_smp_delay( int max )52 {53 }54 55 void bsp_smp_wait_for(56 volatile unsigned int *address,57 unsigned int desired,58 int maximum_usecs59 )60 {61 int iterations;62 volatile int i;63 volatile unsigned int *p = address;64 65 for (iterations=0 ; iterations < maximum_usecs ; iterations++ ) {66 *p = desired;67 /* XXX hack to make simulator happy */68 }69 }70 -
schedsim/shell/schedsim_priority/wrap_thread_dispatch.c
r0745eed r2d51251 25 25 extern void __real__Thread_Dispatch(void); 26 26 27 void Init__wrap__Thread_Dispatch() 28 { 29 } 30 27 31 void check_heir_and_executing(void) 28 32 { -
schedsim/shell/schedsim_smpsimple/Makefile.am
r0745eed r2d51251 25 25 schedsim_smpsimple_CPPFLAGS += -I$(cpukitdir)/posix/inline 26 26 endif 27 ## Ensure all linker provided symbols are available 28 schedsim_smpsimple_LDFLAGS = 29 schedsim_smpsimple_LDFLAGS += -Wl,--defsym=_TLS_Data_begin=0 30 schedsim_smpsimple_LDFLAGS += -Wl,--defsym=_TLS_BSS_end=0 31 schedsim_smpsimple_LDFLAGS += -Wl,--defsym=_TLS_Alignment=4 27 32 28 schedsim_smpsimple_LDFLAGS =-Wl,--wrap=_Thread_Dispatch 33 ## Wrap _Thread_Dispatch so we can see context switches 34 schedsim_smpsimple_LDFLAGS +=-Wl,--wrap=_Thread_Dispatch 35 29 36 ## schedsim_smpsimple_LDADD +=-Wl,--start-group 30 37 schedsim_smpsimple_LDADD = ../shared/libschedsim.a -
schedsim/shell/schedsim_smpsimple/main_current_cpu.c
r0745eed r2d51251 18 18 19 19 #include <rtems.h> 20 #include <rtems/bspsmp.h>21 20 #include <rtems/score/percpu.h> 22 21 #include <rtems/score/schedulerpriority.h> -
schedsim/shell/schedsim_smpsimple/main_dispatch.c
r0745eed r2d51251 18 18 19 19 #include <rtems.h> 20 #include <rtems/bspsmp.h>21 20 #include <rtems/score/percpu.h> 22 21 #include <rtems/score/smp.h> -
schedsim/shell/schedsim_smpsimple/main_dump_ready_tasks.c
r0745eed r2d51251 18 18 #include <rtems/score/chainimpl.h> 19 19 #include <rtems/score/thread.h> 20 #include <rtems/score/assert.h> 20 21 21 #include <rtems/score/schedulerpriority.h> 22 /* 23 * Note: This source depends upon the scheduler being 24 * tested. 25 */ 26 #include <rtems/score/schedulersimplesmp.h> 22 27 23 28 int main_dump_ready_tasks(int argc, char **argv) … … 27 32 Thread_Control *t; 28 33 34 Scheduler_simple_SMP_Context * self = 35 (Scheduler_simple_SMP_Context *) _Scheduler_Table[0].context; 36 37 /* We don't support this yet */ 38 _Assert( _Scheduler_Count != 1 ); 39 29 40 printf( "=== Ready Set of Threads\n" ); 30 chain = (Chain_Control *)_Scheduler.information;41 chain = &self->Ready; 31 42 for (n = _Chain_First( chain ); !_Chain_Is_tail(chain, n); n = n->next) { 32 43 t = (Thread_Control *)n; -
schedsim/shell/schedsim_smpsimple/smp_stub.c
r0745eed r2d51251 12 12 #include <rtems.h> 13 13 #include <rtems/bspIo.h> 14 #include <rtems/bspsmp.h>15 14 #include <stdlib.h> 16 15 … … 18 17 extern uint32_t Schedsim_Maximum_CPUs_From_Command_Line; 19 18 20 void bsp_smp_secondary_cpu_initialize(int cpu) 21 { 22 Schedsim_Current_cpu = 0; 23 } 24 25 int bsp_smp_processor_id(void) 26 { 27 return Schedsim_Current_cpu; 28 } 29 30 uint32_t bsp_smp_initialize( 31 uint32_t configured_cpu_count 32 ) 19 uint32_t _CPU_SMP_Initialize( void ) 33 20 { 34 21 if ( configured_cpu_count < Schedsim_Maximum_CPUs_From_Command_Line ) { … … 44 31 } 45 32 46 void bsp_smp_broadcast_interrupt(void) 33 bool _CPU_SMP_Start_processor( uint32_t cpu_index ) 34 { 35 return true; 36 } 37 38 void _CPU_SMP_Finalize_initialization( uint32_t cpu_count ) 47 39 { 48 40 } 49 41 50 void bsp_smp_broadcast_message( 51 uint32_t message 52 ) 42 void _CPU_SMP_Send_interrupt( uint32_t target_processor_index ) 43 { 44 } 45 46 void _CPU_SMP_Processor_event_broadcast( void ) 47 { 48 Per_CPU_Control *cpu = _Per_CPU_Get(); 49 uint32_t cpu_count = _SMP_Get_processor_count(); 50 uint32_t cpu_index; 51 Per_CPU_State state = cpu->state; 52 53 if (state == PER_CPU_STATE_REQUEST_START_MULTITASKING) { 54 for ( cpu_index = 0 ; cpu_index < cpu_count ; ++cpu_index ) { 55 cpu = _Per_CPU_Get_by_index( cpu_index ); 56 state = cpu->state; 57 if (state == PER_CPU_STATE_INITIAL ) 58 cpu->state = PER_CPU_STATE_READY_TO_START_MULTITASKING; 59 } 60 } 61 } 62 63 64 void _CPU_SMP_Processor_event_receive( void ) 53 65 { 54 66 } 55 67 56 void bsp_smp_interrupt_cpu( 57 int cpu 58 ) 68 uint32_t _CPU_SMP_Get_current_processor( void ) 59 69 { 70 return Schedsim_Current_cpu; 60 71 } 61 62 void bsp_smp_delay( int max )63 {64 }65 66 void bsp_smp_wait_for(67 volatile unsigned int *address,68 unsigned int desired,69 int maximum_usecs70 )71 {72 int iterations;73 volatile int i;74 volatile unsigned int *p = address;75 76 for (iterations=0 ; iterations < maximum_usecs ; iterations++ ) {77 *p = desired;78 /* XXX hack to make simulator happy */79 }80 }81 -
schedsim/shell/schedsim_smpsimple/wrap_thread_dispatch.c
r0745eed r2d51251 13 13 #include <schedsim_shell.h> 14 14 15 #include <stdlib.h> 15 16 #include <stdio.h> 16 17 #include <rtems.h> 17 18 18 Thread_Control *last_heir = NULL; 19 Thread_Control *last_executing = NULL; 19 typedef Thread_Control * Thread_Control_ptr; 20 extern uint32_t Schedsim_Current_cpu; 21 22 Thread_Control_ptr *last_heir = NULL; 23 Thread_Control_ptr *last_executing = NULL; 20 24 21 25 extern void __real__Thread_Dispatch(void); 22 26 27 void Init__wrap__Thread_Dispatch() 28 { 29 last_heir = (Thread_Control_ptr *) calloc( sizeof( Thread_Control_ptr ), _SMP_Processor_count ); 30 last_executing = (Thread_Control_ptr *) calloc( sizeof( Thread_Control_ptr ), _SMP_Processor_count ); 31 } 32 23 33 void check_heir_and_executing(void) 24 34 { 25 if ( last_heir != _Thread_Heir )35 if ( last_heir[Schedsim_Current_cpu] != _Thread_Heir ) 26 36 PRINT_HEIR(); 27 37 28 if ( last_executing != _Thread_Executing )38 if ( last_executing[Schedsim_Current_cpu] != _Thread_Executing ) 29 39 PRINT_EXECUTING(); 30 40 31 last_heir = _Thread_Heir;32 last_executing = _Thread_Executing;41 last_heir[Schedsim_Current_cpu] = _Thread_Heir; 42 last_executing[Schedsim_Current_cpu] = _Thread_Executing; 33 43 } 34 44 35 45 void __wrap__Thread_Dispatch(void) 36 46 { 37 check_heir_and_executing(); 47 uint32_t cpu; 48 uint32_t current_cpu; 49 50 current_cpu = Schedsim_Current_cpu; 51 for ( cpu=0 ; cpu < _SMP_Processor_count ; cpu++ ) { 52 Schedsim_Current_cpu = cpu; 53 check_heir_and_executing(); 38 54 __real__Thread_Dispatch(); 39 check_heir_and_executing(); 55 check_heir_and_executing(); 56 } 57 58 Schedsim_Current_cpu = current_cpu; 40 59 } 60
Note: See TracChangeset
for help on using the changeset viewer.