Ticket #1647: rtems-modsched.diff
File rtems-modsched.diff, 43.2 KB (added by Gedare Bloom, on 11/13/10 at 17:05:54) |
---|
-
cpukit/posix/src/nanosleep.c
RCS file: /usr1/CVS/rtems/cpukit/posix/src/nanosleep.c,v retrieving revision 1.11 diff -u -p -r1.11 nanosleep.c
18 18 19 19 #include <rtems/system.h> 20 20 #include <rtems/score/isr.h> 21 #include <rtems/score/scheduler.h> 21 22 #include <rtems/score/thread.h> 22 23 #include <rtems/score/tod.h> 23 24 … … int nanosleep( 56 57 57 58 if ( !ticks ) { 58 59 _Thread_Disable_dispatch(); 59 _ Thread_Yield_processor();60 _Scheduler_Yield(); 60 61 _Thread_Enable_dispatch(); 61 62 if ( rmtp ) { 62 63 rmtp->tv_sec = 0; -
cpukit/posix/src/sched_yield.c
RCS file: /usr1/CVS/rtems/cpukit/posix/src/sched_yield.c,v retrieving revision 1.1 diff -u -p -r1.1 sched_yield.c
19 19 #include <errno.h> 20 20 21 21 #include <rtems/system.h> 22 #include <rtems/score/scheduler.h> 22 23 #include <rtems/score/tod.h> 23 24 #include <rtems/score/thread.h> 24 25 #include <rtems/seterr.h> … … 28 29 int sched_yield( void ) 29 30 { 30 31 _Thread_Disable_dispatch(); 31 _ Thread_Yield_processor();32 _Scheduler_Yield(); 32 33 _Thread_Enable_dispatch(); 33 34 return 0; 34 35 } -
cpukit/rtems/src/taskwakeafter.c
RCS file: /usr1/CVS/rtems/cpukit/rtems/src/taskwakeafter.c,v retrieving revision 1.4 diff -u -p -r1.4 taskwakeafter.c
21 21 #include <rtems/rtems/support.h> 22 22 #include <rtems/rtems/modes.h> 23 23 #include <rtems/score/object.h> 24 #include <rtems/score/scheduler.h> 24 25 #include <rtems/score/stack.h> 25 26 #include <rtems/score/states.h> 26 27 #include <rtems/rtems/tasks.h> … … rtems_status_code rtems_task_wake_after( 52 53 { 53 54 _Thread_Disable_dispatch(); 54 55 if ( ticks == 0 ) { 55 _ Thread_Yield_processor();56 _Scheduler_Yield(); 56 57 } else { 57 58 _Thread_Set_state( _Thread_Executing, STATES_DELAYING ); 58 59 _Watchdog_Initialize( -
cpukit/sapi/include/confdefs.h
RCS file: /usr1/CVS/rtems/cpukit/sapi/include/confdefs.h,v retrieving revision 1.149 diff -u -p -r1.149 confdefs.h
rtems_fs_init_functions_t rtems_fs_in 535 535 #endif 536 536 537 537 /* 538 * Scheduler configuration. 539 * 540 * The scheduler configuration allows an application to select the 541 * scheduling policy to use. The supported configurations are: 542 * CONFIGURE_SCHEDULER_USER 543 * CONFIGURE_SCHEDULER_PRIORITY 544 * 545 * If no configuration is specified by the application, then 546 * CONFIGURE_SCHEDULER_PRIORITY is assumed to be the default. 547 * 548 * An application can define its own scheduling policy by defining 549 * CONFIGURE_SCHEDULER_USER and CONFIGURE_SCHEDULER_ENTRY_USER to point 550 * to an initialization routine. Note: CONFIGURE_SCHEDULER_USER is not 551 * fully supported, since it has no per-thread field. 552 * 553 * To add a new scheduler: 554 */ 555 #include <rtems/score/scheduler.h> 556 557 #if defined(CONFIGURE_SCHEDULER_USER) && \ 558 !defined(CONFIGURE_SCHEDULER_ENTRY_USER) 559 #error "CONFIGURE_ERROR: CONFIGURE_SCHEDULER_USER without CONFIGURE_SCHEDULER_ENTRY_USER" 560 #endif 561 562 /* enable all RTEMS-provided schedulers */ 563 #if defined(CONFIGURE_SCHEDULER_ALL) 564 #define CONFIGURE_SCHEDULER_PRIORITY 565 #endif 566 567 /* If no scheduler is specified, the priority scheduler is default. */ 568 #if !defined(CONFIGURE_SCHEDULER_USER) && \ 569 !defined(CONFIGURE_SCHEDULER_PRIORITY) 570 #define CONFIGURE_SCHEDULER_PRIORITY 571 #define CONFIGURE_SCHEDULER_POLICY _Scheduler_PRIORITY 572 #endif 573 574 /* 575 * If a user scheduler is specified and no policy is set, 576 * the user scheduler is the default policy. 577 */ 578 #if defined(CONFIGURE_SCHEDULER_USER) && \ 579 !defined(CONFIGURE_SCHEDULER_POLICY) 580 #define CONFIGURE_SCHEDULER_POLICY _Scheduler_USER 581 #endif 582 583 /* 584 * Check for priority scheduler next, as it is the default policy if there 585 * is no CONFIGURE_SCHEDULER_POLICY set and no USER scheduler provided. 586 */ 587 #if defined(CONFIGURE_SCHEDULER_PRIORITY) 588 #include <rtems/score/schedulerpriority.h> 589 #define CONFIGURE_SCHEDULER_ENTRY_PRIORITY { _Scheduler_priority_Initialize } 590 #if !defined(CONFIGURE_SCHEDULER_POLICY) 591 #define CONFIGURE_SCHEDULER_POLICY _Scheduler_PRIORITY 592 #endif 593 594 /** 595 * define the memory used by the priority scheduler 596 */ 597 #define CONFIGURE_MEMORY_SCHEDULER_PRIORITY ( \ 598 _Configure_From_workspace( \ 599 ((CONFIGURE_MAXIMUM_PRIORITY+1) * sizeof(Chain_Control)) ) \ 600 ) 601 #define CONFIGURE_MEMORY_PER_TASK_SCHEDULER_PRIORITY ( \ 602 _Configure_From_workspace(sizeof(Scheduler_priority_Per_thread)) ) 603 #endif 604 605 /* 606 * Set up the scheduler table. The scheduling code indexes this table to 607 * invoke the correct scheduling implementation. The scheduler to use is 608 * determined by the Configuration.scheduler_policy field, which is set 609 * by CONFIGURE_SCHEDULER_POLICY. If a particular scheduler is not enabled, 610 * an empty entry is included in its entry in the scheduler table. 611 */ 612 613 /** 614 * An empty scheduler entry 615 */ 616 #define CONFIGURE_SCHEDULER_NULL { NULL } 617 618 #ifdef CONFIGURE_INIT 619 /* the table of available schedulers. */ 620 const Scheduler_Table_t _Scheduler_Table[] = { 621 #if defined(CONFIGURE_SCHEDULER_USER) && \ 622 defined(CONFIGURE_SCHEDULER_ENTRY_USER) 623 CONFIGURE_SCHEDULER_ENTRY_USER, 624 #else 625 CONFIGURE_SCHEDULER_NULL, 626 #endif 627 #if defined(CONFIGURE_SCHEDULER_PRIORITY) && \ 628 defined(CONFIGURE_SCHEDULER_ENTRY_PRIORITY) 629 CONFIGURE_SCHEDULER_ENTRY_PRIORITY, 630 #else 631 CONFIGURE_SCHEDULER_NULL, 632 #endif 633 }; 634 #endif 635 636 /** 637 * Define the memory overhead for the scheduler 638 */ 639 #define CONFIGURE_MEMORY_FOR_SCHEDULER ( \ 640 CONFIGURE_MEMORY_SCHEDULER_PRIORITY \ 641 ) 642 643 #define CONFIGURE_MEMORY_PER_TASK_FOR_SCHEDULER ( \ 644 CONFIGURE_MEMORY_PER_TASK_SCHEDULER_PRIORITY \ 645 ) 646 647 /* 538 648 * If you said the IDLE task was going to do application initialization 539 649 * and didn't override the IDLE body, then something is amiss. 540 650 */ … … rtems_fs_init_functions_t rtems_fs_in 1606 1716 (_Configure_From_workspace(CONFIGURE_MINIMUM_TASK_STACK_SIZE) + \ 1607 1717 CONFIGURE_MEMORY_PER_TASK_FOR_CLASSIC_API + \ 1608 1718 CONFIGURE_MEMORY_PER_TASK_FOR_NEWLIB + \ 1609 CONFIGURE_MEMORY_PER_TASK_FOR_POSIX_API)) + \ 1719 CONFIGURE_MEMORY_PER_TASK_FOR_POSIX_API + \ 1720 CONFIGURE_MEMORY_PER_TASK_FOR_SCHEDULER)) + \ 1610 1721 _Configure_From_workspace( \ 1611 1722 _Configure_Max_Objects(_number_FP_tasks) * CONTEXT_FP_SIZE) + \ 1612 1723 _Configure_From_workspace( \ … … rtems_fs_init_functions_t rtems_fs_in 1704 1815 _Configure_Object_RAM(1, sizeof(API_Mutex_Control)) 1705 1816 1706 1817 /** 1707 * This defines the memory used by the thread ready chains. There is1708 * one chain per priority.1709 */1710 #define CONFIGURE_MEMORY_FOR_THREAD_READY_CHAINS \1711 _Configure_From_workspace( \1712 ((CONFIGURE_MAXIMUM_PRIORITY+1) * sizeof(Chain_Control)) )1713 /**1714 1818 * This defines the amount of memory reserved for the IDLE task 1715 1819 * control structures and stack. 1716 1820 */ … … rtems_fs_init_functions_t rtems_fs_in 1723 1827 */ 1724 1828 #define CONFIGURE_MEMORY_FOR_SYSTEM_OVERHEAD \ 1725 1829 ( CONFIGURE_MEMORY_FOR_IDLE_TASK + /* IDLE and stack */ \ 1726 CONFIGURE_MEMORY_FOR_ THREAD_READY_CHAINS + /* Ready chains*/ \1830 CONFIGURE_MEMORY_FOR_SCHEDULER + /* Scheduler */ \ 1727 1831 CONFIGURE_INTERRUPT_VECTOR_TABLE + /* interrupt vectors */ \ 1728 1832 CONFIGURE_INTERRUPT_STACK_MEMORY + /* interrupt stack */ \ 1729 1833 CONFIGURE_API_MUTEX_MEMORY /* allocation mutex */ \ … … rtems_fs_init_functions_t rtems_fs_in 2004 2108 CONFIGURE_MAXIMUM_USER_EXTENSIONS, /* maximum dynamic extensions */ 2005 2109 CONFIGURE_MICROSECONDS_PER_TICK, /* microseconds per clock tick */ 2006 2110 CONFIGURE_TICKS_PER_TIMESLICE, /* ticks per timeslice quantum */ 2111 CONFIGURE_SCHEDULER_POLICY, /* scheduling policy */ 2007 2112 CONFIGURE_IDLE_TASK_BODY, /* user's IDLE task */ 2008 2113 CONFIGURE_IDLE_TASK_STACK_SIZE, /* IDLE task stack size */ 2009 2114 CONFIGURE_INTERRUPT_STACK_SIZE, /* interrupt stack size */ -
cpukit/sapi/include/rtems/config.h
RCS file: /usr1/CVS/rtems/cpukit/sapi/include/rtems/config.h,v retrieving revision 1.53 diff -u -p -r1.53 config.h
typedef struct { 118 118 */ 119 119 uint32_t ticks_per_timeslice; 120 120 121 /** This field specifies the scheduling policy to use. 122 */ 123 uint32_t scheduler_policy; 124 121 125 /** This element points to the BSP's optional idle task which may override 122 126 * the default one provided with RTEMS. 123 127 */ -
cpukit/sapi/src/exinit.c
RCS file: /usr1/CVS/rtems/cpukit/sapi/src/exinit.c,v retrieving revision 1.55 diff -u -p -r1.55 exinit.c
42 42 #include <rtems/score/mpci.h> 43 43 #endif 44 44 #include <rtems/score/priority.h> 45 #include <rtems/score/ prioritybitmap.h>45 #include <rtems/score/scheduler.h> 46 46 #include <rtems/score/thread.h> 47 47 #include <rtems/score/tod.h> 48 48 #include <rtems/score/userext.h> … … void rtems_initialize_data_structures(vo 131 131 132 132 _Thread_Handler_initialization(); 133 133 134 _Scheduler_Handler_initialization(); 135 134 136 #if defined(RTEMS_MULTIPROCESSING) 135 137 _Objects_MP_Handler_initialization(); 136 138 _MPCI_Handler_initialization( RTEMS_TIMEOUT ); -
cpukit/score/Makefile.am
RCS file: /usr1/CVS/rtems/cpukit/score/Makefile.am,v retrieving revision 1.88 diff -u -p -r1.88 Makefile.am
include_rtems_score_HEADERS = include/rt 26 26 include/rtems/score/interr.h include/rtems/score/isr.h \ 27 27 include/rtems/score/object.h include/rtems/score/percpu.h \ 28 28 include/rtems/score/priority.h include/rtems/score/prioritybitmap.h \ 29 include/rtems/score/scheduler.h include/rtems/score/schedulerpriority.h \ 29 30 include/rtems/score/stack.h include/rtems/score/states.h \ 30 31 include/rtems/score/sysstate.h include/rtems/score/thread.h \ 31 32 include/rtems/score/threadq.h include/rtems/score/threadsync.h \ … … include_rtems_score_HEADERS += inline/rt 54 55 inline/rtems/score/coresem.inl inline/rtems/score/heap.inl \ 55 56 inline/rtems/score/isr.inl inline/rtems/score/object.inl \ 56 57 inline/rtems/score/priority.inl inline/rtems/score/prioritybitmap.inl \ 58 inline/rtems/score/scheduler.inl inline/rtems/score/schedulerpriority.inl \ 57 59 inline/rtems/score/stack.inl inline/rtems/score/states.inl \ 58 60 inline/rtems/score/sysstate.inl inline/rtems/score/thread.inl \ 59 61 inline/rtems/score/threadq.inl inline/rtems/score/tod.inl \ … … libscore_a_SOURCES += src/objectallocate 137 139 src/objectgetinfo.c src/objectgetinfoid.c src/objectapimaximumclass.c \ 138 140 src/objectnamespaceremove.c 139 141 142 ## SCHEDULER_C_FILES 143 libscore_a_SOURCES += src/scheduler.c 144 145 ## SCHEDULERPRIORITY_C_FILES 146 libscore_a_SOURCES += src/schedulerpriority.c \ 147 src/schedulerpriorityblock.c \ 148 src/schedulerprioritythreadschedulerallocate.c \ 149 src/schedulerprioritythreadschedulerfree.c \ 150 src/schedulerprioritythreadschedulerupdate.c \ 151 src/schedulerpriorityschedule.c \ 152 src/schedulerpriorityunblock.c \ 153 src/schedulerpriorityyield.c 154 140 155 ## PROTECTED_HEAP_C_FILES 141 156 libscore_a_SOURCES += src/pheapallocate.c \ 142 157 src/pheapextend.c src/pheapfree.c src/pheapgetsize.c \ … … libscore_a_SOURCES += src/thread.c src/t 153 168 src/threadsetstate.c src/threadsettransient.c \ 154 169 src/threadstackallocate.c src/threadstackfree.c src/threadstart.c \ 155 170 src/threadstartmultitasking.c src/threadsuspend.c \ 156 src/threadtickletimeslice.c src/threadyieldprocessor.c\171 src/threadtickletimeslice.c \ 157 172 src/iterateoverthreads.c src/threadblockingoperationcancel.c 158 173 159 174 ## THREADQ_C_FILES -
cpukit/score/preinstall.am
RCS file: /usr1/CVS/rtems/cpukit/score/preinstall.am,v retrieving revision 1.24 diff -u -p -r1.24 preinstall.am
$(PROJECT_INCLUDE)/rtems/score/priorityb 111 111 $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/prioritybitmap.h 112 112 PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/prioritybitmap.h 113 113 114 $(PROJECT_INCLUDE)/rtems/score/scheduler.h: include/rtems/score/scheduler.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) 115 $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/scheduler.h 116 PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/scheduler.h 117 118 $(PROJECT_INCLUDE)/rtems/score/schedulerpriority.h: include/rtems/score/schedulerpriority.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) 119 $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/schedulerpriority.h 120 PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/schedulerpriority.h 121 114 122 $(PROJECT_INCLUDE)/rtems/score/stack.h: include/rtems/score/stack.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) 115 123 $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/stack.h 116 124 PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/stack.h … … $(PROJECT_INCLUDE)/rtems/score/priorityb 245 253 $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/prioritybitmap.inl 246 254 PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/prioritybitmap.inl 247 255 256 $(PROJECT_INCLUDE)/rtems/score/scheduler.inl: inline/rtems/score/scheduler.inl $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) 257 $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/scheduler.inl 258 PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/scheduler.inl 259 260 $(PROJECT_INCLUDE)/rtems/score/schedulerpriority.inl: inline/rtems/score/schedulerpriority.inl $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) 261 $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/schedulerpriority.inl 262 PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/schedulerpriority.inl 263 248 264 $(PROJECT_INCLUDE)/rtems/score/stack.inl: inline/rtems/score/stack.inl $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) 249 265 $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/stack.inl 250 266 PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/stack.inl -
cpukit/score/include/rtems/score/prioritybitmap.h
RCS file: /usr1/CVS/rtems/cpukit/score/include/rtems/score/prioritybitmap.h,v retrieving revision 1.1 diff -u -p -r1.1 prioritybitmap.h
extern "C" { 37 37 38 38 #include <rtems/score/priority.h> 39 39 40 40 41 /* 41 * TODO: 42 * These should only be instantiated if using the bit map handler. The 43 * logical place for this is in confdefs.h when a scheduler that uses the 44 * bit map handler is configured. 42 * The Priority_bit_map_Control variables are instantiated only 43 * if using the bit map handler. 45 44 */ 46 45 47 46 /** 48 47 * Each sixteen bit entry in this array is associated with one of 49 48 * the sixteen entries in the Priority Bit map. 50 49 */ 51 SCORE_EXTERNvolatile Priority_bit_map_Control _Priority_Major_bit_map;50 extern volatile Priority_bit_map_Control _Priority_Major_bit_map; 52 51 53 52 /** Each bit in the Priority Bitmap indicates whether or not there are 54 53 * threads ready at a particular priority. The mapping of … … SCORE_EXTERN volatile Priority_bit_map_C 56 55 * dependent as is the value of each bit used to indicate that 57 56 * threads are ready at that priority. 58 57 */ 59 SCORE_EXTERNPriority_bit_map_Control58 extern Priority_bit_map_Control 60 59 _Priority_Bit_map[16] CPU_STRUCTURE_ALIGNMENT; 61 60 62 61 /* -
cpukit/score/include/rtems/score/thread.h
RCS file: /usr1/CVS/rtems/cpukit/score/include/rtems/score/thread.h,v retrieving revision 1.97 diff -u -p -r1.97 thread.h
extern "C" { 70 70 #endif 71 71 #include <rtems/score/object.h> 72 72 #include <rtems/score/priority.h> 73 #include <rtems/score/ prioritybitmap.h>73 #include <rtems/score/scheduler.h> 74 74 #include <rtems/score/stack.h> 75 75 #include <rtems/score/states.h> 76 76 #include <rtems/score/tod.h> … … struct Thread_Control_struct { 390 390 * since it was created. 391 391 */ 392 392 Thread_CPU_usage_t cpu_time_used; 393 /** This field points to the Ready FIFO for this priority. */394 Chain_Control *ready;395 /** This field contains precalculated priority map indices. */396 Priority_bit_map_Information Priority_map;393 /** This union holds per-thread data for the scheduler and ready queue. */ 394 union { 395 Scheduler_priority_Per_thread *priority; 396 } scheduler; 397 397 /** This field contains information about the starting state of 398 398 * this thread. 399 399 */ … … SCORE_EXTERN uint32_t _Thread_Maximum_ 456 456 SCORE_EXTERN uint32_t _Thread_Ticks_per_timeslice; 457 457 458 458 /** 459 * The following points to the array of FIFOs used to manage the460 * set of ready threads.461 */462 SCORE_EXTERN Chain_Control *_Thread_Ready_chain;463 464 /**465 459 * The following points to the thread whose floating point 466 460 * context is currently loaded. 467 461 */ … … void _Thread_Set_transient( 654 648 void _Thread_Tickle_timeslice( void ); 655 649 656 650 /** 657 * This routine is invoked when a thread wishes to voluntarily658 * transfer control of the processor to another thread of equal659 * or greater priority.660 */661 void _Thread_Yield_processor( void );662 663 /**664 651 * This routine initializes the context of the_thread to its 665 652 * appropriate starting state. 666 653 */ -
cpukit/score/inline/rtems/score/thread.inl
RCS file: /usr1/CVS/rtems/cpukit/score/inline/rtems/score/thread.inl,v retrieving revision 1.43 diff -u -p -r1.43 thread.inl
RTEMS_INLINE_ROUTINE void _Thread_Restar 120 120 } 121 121 122 122 /** 123 * This function returns a pointer to the highest priority124 * ready thread.125 */126 127 RTEMS_INLINE_ROUTINE void _Thread_Calculate_heir( void )128 {129 _Thread_Heir = (Thread_Control *)130 _Thread_Ready_chain[ _Priority_bit_map_Get_highest() ].first;131 }132 133 /**134 123 * This function returns true if the floating point context of 135 124 * the_thread is currently loaded in the floating point unit, and 136 125 * false otherwise. -
cpukit/score/src/thread.c
RCS file: /usr1/CVS/rtems/cpukit/score/src/thread.c,v retrieving revision 1.64 diff -u -p -r1.64 thread.c
24 24 #include <rtems/score/isr.h> 25 25 #include <rtems/score/object.h> 26 26 #include <rtems/score/priority.h> 27 #include <rtems/score/scheduler.h> 27 28 #include <rtems/score/states.h> 28 29 #include <rtems/score/sysstate.h> 29 30 #include <rtems/score/thread.h> … … 45 46 46 47 void _Thread_Handler_initialization(void) 47 48 { 48 uint32_t index;49 49 uint32_t ticks_per_timeslice; 50 50 uint32_t maximum_extensions; 51 51 #if defined(RTEMS_MULTIPROCESSING) … … void _Thread_Handler_initialization(void 80 80 81 81 _Thread_Ticks_per_timeslice = ticks_per_timeslice; 82 82 83 _Thread_Ready_chain = (Chain_Control *) _Workspace_Allocate_or_fatal_error(84 (PRIORITY_MAXIMUM + 1) * sizeof(Chain_Control)85 );86 87 for ( index=0; index <= PRIORITY_MAXIMUM ; index++ )88 _Chain_Initialize_empty( &_Thread_Ready_chain[ index ] );89 90 83 #if defined(RTEMS_MULTIPROCESSING) 91 84 _Thread_MP_Handler_initialization( maximum_proxies ); 92 85 #endif -
cpukit/score/src/threadchangepriority.c
RCS file: /usr1/CVS/rtems/cpukit/score/src/threadchangepriority.c,v retrieving revision 1.14 diff -u -p -r1.14 threadchangepriority.c
23 23 #include <rtems/score/isr.h> 24 24 #include <rtems/score/object.h> 25 25 #include <rtems/score/priority.h> 26 #include <rtems/score/scheduler.h> 27 #include <rtems/score/schedulerpriority.h> 26 28 #include <rtems/score/states.h> 27 29 #include <rtems/score/sysstate.h> 28 30 #include <rtems/score/thread.h> … … void _Thread_Change_priority( 117 119 * We now know the thread will be in the READY state when we remove 118 120 * the TRANSIENT state. So we have to place it on the appropriate 119 121 * Ready Queue with interrupts off. 122 * 123 * FIXME: hard-coded for priority scheduling. Might be ok since this 124 * function is specific to priority scheduling? 120 125 */ 121 126 the_thread->current_state = _States_Clear( STATES_TRANSIENT, state ); 122 127 123 _Priority_bit_map_Add( &the_thread->Priority_map );124 128 if ( prepend_it ) 125 _ Chain_Prepend_unprotected( the_thread->ready, &the_thread->Object.Node);129 _Scheduler_priority_Ready_queue_enqueue_first( the_thread ); 126 130 else 127 _ Chain_Append_unprotected( the_thread->ready, &the_thread->Object.Node);131 _Scheduler_priority_Ready_queue_enqueue( the_thread ); 128 132 } 129 133 130 134 _ISR_Flash( level ); … … void _Thread_Change_priority( 133 137 * We altered the set of thread priorities. So let's figure out 134 138 * who is the heir and if we need to switch to them. 135 139 */ 136 _ Thread_Calculate_heir();140 _Scheduler_Schedule(&_Scheduler); 137 141 138 142 if ( !_Thread_Is_executing_also_the_heir() && 139 143 _Thread_Executing->is_preemptible ) -
cpukit/score/src/threadclearstate.c
RCS file: /usr1/CVS/rtems/cpukit/score/src/threadclearstate.c,v retrieving revision 1.12 diff -u -p -r1.12 threadclearstate.c
23 23 #include <rtems/score/isr.h> 24 24 #include <rtems/score/object.h> 25 25 #include <rtems/score/priority.h> 26 #include <rtems/score/scheduler.h> 26 27 #include <rtems/score/states.h> 27 28 #include <rtems/score/sysstate.h> 28 29 #include <rtems/score/thread.h> … … void _Thread_Clear_state( 66 67 the_thread->current_state = _States_Clear( state, current_state ); 67 68 68 69 if ( _States_Is_ready( current_state ) ) { 69 70 _Priority_bit_map_Add( &the_thread->Priority_map ); 71 72 _Chain_Append_unprotected(the_thread->ready, &the_thread->Object.Node); 73 74 _ISR_Flash( level ); 75 76 /* 77 * If the thread that was unblocked is more important than the heir, 78 * then we have a new heir. This may or may not result in a 79 * context switch. 80 * 81 * Normal case: 82 * If the current thread is preemptible, then we need to do 83 * a context switch. 84 * Pseudo-ISR case: 85 * Even if the thread isn't preemptible, if the new heir is 86 * a pseudo-ISR system task, we need to do a context switch. 87 */ 88 if ( the_thread->current_priority < _Thread_Heir->current_priority ) { 89 _Thread_Heir = the_thread; 90 if ( _Thread_Executing->is_preemptible || 91 the_thread->current_priority == 0 ) 92 _Thread_Dispatch_necessary = true; 93 } 70 _Scheduler_Unblock( &_Scheduler, the_thread); 94 71 } 95 72 } 96 73 _ISR_Enable( level ); -
cpukit/score/src/threadclose.c
RCS file: /usr1/CVS/rtems/cpukit/score/src/threadclose.c,v retrieving revision 1.12 diff -u -p -r1.12 threadclose.c
23 23 #include <rtems/score/isr.h> 24 24 #include <rtems/score/object.h> 25 25 #include <rtems/score/priority.h> 26 #include <rtems/score/scheduler.h> 26 27 #include <rtems/score/states.h> 27 28 #include <rtems/score/sysstate.h> 28 29 #include <rtems/score/thread.h> … … void _Thread_Close( 86 87 } 87 88 88 89 /* 90 * Free the per-thread scheduling information. 91 */ 92 _Scheduler_Thread_scheduler_free( &_Scheduler, the_thread ); 93 94 /* 89 95 * The thread might have been FP. So deal with that. 90 96 */ 91 97 #if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE ) -
cpukit/score/src/threadinitialize.c
RCS file: /usr1/CVS/rtems/cpukit/score/src/threadinitialize.c,v retrieving revision 1.39 diff -u -p -r1.39 threadinitialize.c
23 23 #include <rtems/score/isr.h> 24 24 #include <rtems/score/object.h> 25 25 #include <rtems/score/priority.h> 26 #include <rtems/score/scheduler.h> 26 27 #include <rtems/score/states.h> 27 28 #include <rtems/score/sysstate.h> 28 29 #include <rtems/score/thread.h> … … bool _Thread_Initialize( 60 61 #if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE ) 61 62 void *fp_area; 62 63 #endif 64 void *sched = NULL; 63 65 void *extensions_area; 64 66 bool extension_status; 65 67 int i; … … bool _Thread_Initialize( 192 194 the_thread->resource_count = 0; 193 195 the_thread->real_priority = priority; 194 196 the_thread->Start.initial_priority = priority; 197 sched =_Scheduler_Thread_scheduler_allocate( &_Scheduler, the_thread ); 198 if ( !sched ) 199 goto failed; 195 200 _Thread_Set_priority( the_thread, priority ); 196 201 197 202 /* … … failed: 235 240 (void) _Workspace_Free( fp_area ); 236 241 #endif 237 242 243 if ( sched ) 244 (void) _Workspace_Free( sched ); 245 238 246 _Thread_Stack_Free( the_thread ); 239 247 return false; 240 248 -
cpukit/score/src/threadready.c
RCS file: /usr1/CVS/rtems/cpukit/score/src/threadready.c,v retrieving revision 1.9 diff -u -p -r1.9 threadready.c
23 23 #include <rtems/score/isr.h> 24 24 #include <rtems/score/object.h> 25 25 #include <rtems/score/priority.h> 26 #include <rtems/score/scheduler.h> 26 27 #include <rtems/score/states.h> 27 28 #include <rtems/score/sysstate.h> 28 29 #include <rtems/score/thread.h> … … void _Thread_Ready( 55 56 ) 56 57 { 57 58 ISR_Level level; 58 Thread_Control *heir;59 59 60 60 _ISR_Disable( level ); 61 61 62 62 the_thread->current_state = STATES_READY; 63 63 64 _Priority_bit_map_Add( &the_thread->Priority_map ); 65 66 _Chain_Append_unprotected( the_thread->ready, &the_thread->Object.Node ); 67 68 _ISR_Flash( level ); 69 70 _Thread_Calculate_heir(); 71 72 heir = _Thread_Heir; 73 74 if ( !_Thread_Is_executing( heir ) && _Thread_Executing->is_preemptible ) 75 _Thread_Dispatch_necessary = true; 64 _Scheduler_Unblock( &_Scheduler, the_thread ); 76 65 77 66 _ISR_Enable( level ); 78 67 } -
cpukit/score/src/threadresume.c
RCS file: /usr1/CVS/rtems/cpukit/score/src/threadresume.c,v retrieving revision 1.12 diff -u -p -r1.12 threadresume.c
23 23 #include <rtems/score/isr.h> 24 24 #include <rtems/score/object.h> 25 25 #include <rtems/score/priority.h> 26 #include <rtems/score/scheduler.h> 26 27 #include <rtems/score/states.h> 27 28 #include <rtems/score/sysstate.h> 28 29 #include <rtems/score/thread.h> … … void _Thread_Resume( 68 69 the_thread->current_state = _States_Clear(STATES_SUSPENDED, current_state); 69 70 70 71 if ( _States_Is_ready( current_state ) ) { 71 72 _Priority_bit_map_Add( &the_thread->Priority_map ); 73 74 _Chain_Append_unprotected(the_thread->ready, &the_thread->Object.Node); 75 76 _ISR_Flash( level ); 77 78 if ( the_thread->current_priority < _Thread_Heir->current_priority ) { 79 _Thread_Heir = the_thread; 80 if ( _Thread_Executing->is_preemptible || 81 the_thread->current_priority == 0 ) 82 _Thread_Dispatch_necessary = true; 83 } 72 _Scheduler_Unblock( &_Scheduler, the_thread ); 84 73 } 85 74 } 86 75 -
cpukit/score/src/threadsetpriority.c
RCS file: /usr1/CVS/rtems/cpukit/score/src/threadsetpriority.c,v retrieving revision 1.5 diff -u -p -r1.5 threadsetpriority.c
23 23 #include <rtems/score/isr.h> 24 24 #include <rtems/score/object.h> 25 25 #include <rtems/score/priority.h> 26 #include <rtems/score/scheduler.h> 26 27 #include <rtems/score/states.h> 27 28 #include <rtems/score/sysstate.h> 28 29 #include <rtems/score/thread.h> … … void _Thread_Set_priority( 50 51 ) 51 52 { 52 53 the_thread->current_priority = new_priority; 53 the_thread->ready = &_Thread_Ready_chain[ new_priority ];54 54 55 _Priority_bit_map_Initialize_information( 56 &the_thread->Priority_map, 57 new_priority 58 ); 55 _Scheduler_Thread_scheduler_update(&_Scheduler, the_thread); 59 56 } -
cpukit/score/src/threadsetstate.c
RCS file: /usr1/CVS/rtems/cpukit/score/src/threadsetstate.c,v retrieving revision 1.8 diff -u -p -r1.8 threadsetstate.c
23 23 #include <rtems/score/isr.h> 24 24 #include <rtems/score/object.h> 25 25 #include <rtems/score/priority.h> 26 #include <rtems/score/scheduler.h> 26 27 #include <rtems/score/states.h> 27 28 #include <rtems/score/sysstate.h> 28 29 #include <rtems/score/thread.h> … … void _Thread_Set_state( 54 55 ) 55 56 { 56 57 ISR_Level level; 57 Chain_Control *ready; 58 59 ready = the_thread->ready; 58 60 59 _ISR_Disable( level ); 61 60 if ( !_States_Is_ready( the_thread->current_state ) ) { 62 61 the_thread->current_state = … … void _Thread_Set_state( 67 66 68 67 the_thread->current_state = state; 69 68 70 if ( _Chain_Has_only_one_node( ready ) ) { 71 72 _Chain_Initialize_empty( ready ); 73 _Priority_bit_map_Remove( &the_thread->Priority_map ); 74 75 } else 76 _Chain_Extract_unprotected( &the_thread->Object.Node ); 77 78 _ISR_Flash( level ); 79 80 if ( _Thread_Is_heir( the_thread ) ) 81 _Thread_Calculate_heir(); 82 83 if ( _Thread_Is_executing( the_thread ) ) 84 _Thread_Dispatch_necessary = true; 69 _Scheduler_Block( &_Scheduler, the_thread); 85 70 86 71 _ISR_Enable( level ); 87 72 } -
cpukit/score/src/threadsettransient.c
RCS file: /usr1/CVS/rtems/cpukit/score/src/threadsettransient.c,v retrieving revision 1.6 diff -u -p -r1.6 threadsettransient.c
23 23 #include <rtems/score/isr.h> 24 24 #include <rtems/score/object.h> 25 25 #include <rtems/score/priority.h> 26 #include <rtems/score/scheduler.h> 27 #include <rtems/score/schedulerpriority.h> 26 28 #include <rtems/score/states.h> 27 29 #include <rtems/score/sysstate.h> 28 30 #include <rtems/score/thread.h> … … void _Thread_Set_transient( 54 56 { 55 57 ISR_Level level; 56 58 uint32_t old_state; 57 Chain_Control *ready; 58 59 ready = the_thread->ready; 59 60 60 _ISR_Disable( level ); 61 61 62 62 old_state = the_thread->current_state; 63 63 the_thread->current_state = _States_Set( STATES_TRANSIENT, old_state ); 64 64 65 /* FIXME: need to check which scheduler to use? */ 65 66 if ( _States_Is_ready( old_state ) ) { 66 if ( _Chain_Has_only_one_node( ready ) ) { 67 68 _Chain_Initialize_empty( ready ); 69 _Priority_bit_map_Remove( &the_thread->Priority_map ); 70 71 } else 72 _Chain_Extract_unprotected( &the_thread->Object.Node ); 67 _Scheduler_priority_Ready_queue_extract( the_thread); 73 68 } 74 69 75 70 _ISR_Enable( level ); -
cpukit/score/src/threadsuspend.c
RCS file: /usr1/CVS/rtems/cpukit/score/src/threadsuspend.c,v retrieving revision 1.9 diff -u -p -r1.9 threadsuspend.c
23 23 #include <rtems/score/isr.h> 24 24 #include <rtems/score/object.h> 25 25 #include <rtems/score/priority.h> 26 #include <rtems/score/scheduler.h> 26 27 #include <rtems/score/states.h> 27 28 #include <rtems/score/sysstate.h> 28 29 #include <rtems/score/thread.h> … … void _Thread_Suspend( 52 53 ) 53 54 { 54 55 ISR_Level level; 55 Chain_Control *ready; 56 57 ready = the_thread->ready; 56 58 57 _ISR_Disable( level ); 59 58 if ( !_States_Is_ready( the_thread->current_state ) ) { 60 59 the_thread->current_state = … … void _Thread_Suspend( 65 64 66 65 the_thread->current_state = STATES_SUSPENDED; 67 66 68 if ( _Chain_Has_only_one_node( ready ) ) { 69 70 _Chain_Initialize_empty( ready ); 71 _Priority_bit_map_Remove( &the_thread->Priority_map ); 72 73 } else 74 _Chain_Extract_unprotected( &the_thread->Object.Node ); 75 76 _ISR_Flash( level ); 77 78 if ( _Thread_Is_heir( the_thread ) ) 79 _Thread_Calculate_heir(); 80 81 if ( _Thread_Is_executing( the_thread ) ) 82 _Thread_Dispatch_necessary = true; 67 _Scheduler_Block(&_Scheduler, the_thread); 83 68 84 69 _ISR_Enable( level ); 85 70 } -
cpukit/score/src/threadtickletimeslice.c
RCS file: /usr1/CVS/rtems/cpukit/score/src/threadtickletimeslice.c,v retrieving revision 1.12 diff -u -p -r1.12 threadtickletimeslice.c
23 23 #include <rtems/score/isr.h> 24 24 #include <rtems/score/object.h> 25 25 #include <rtems/score/priority.h> 26 #include <rtems/score/scheduler.h> 26 27 #include <rtems/score/states.h> 27 28 #include <rtems/score/sysstate.h> 28 29 #include <rtems/score/thread.h> … … void _Thread_Tickle_timeslice( void ) 89 90 * currently executing thread is placed at the rear of the 90 91 * FIFO for this priority and a new heir is selected. 91 92 */ 92 _ Thread_Yield_processor();93 _Scheduler_Yield( ); 93 94 executing->cpu_time_budget = _Thread_Ticks_per_timeslice; 94 95 } 95 96 break; -
testsuites/sptests/spsize/size.c
RCS file: /usr1/CVS/rtems/testsuites/sptests/spsize/size.c,v retrieving revision 1.68 diff -u -p -r1.68 size.c
37 37 #include <rtems/rtems/region.h> 38 38 #include <rtems/rtems/sem.h> 39 39 #include <rtems/rtems/signal.h> 40 #include <rtems/score/scheduler.h> 40 41 #include <rtems/score/sysstate.h> 41 42 #include <rtems/score/thread.h> 42 43 #include <rtems/rtems/timer.h> … … 49 50 #include <unistd.h> 50 51 #include <tmacros.h> 51 52 53 #include "system.h" 54 52 55 /* external function prototypes */ 53 56 int getint( void ); 54 57 void size_rtems(int mode); … … void print_formula(void); 64 67 */ 65 68 #define HEAP_OVHD 16 /* wasted heap space per task stack */ 66 69 #define NAME_PTR_SIZE 8 /* size of name and pointer table entries */ 67 #define READYCHAINS_SIZE \ 70 71 #if CONFIGURE_SCHEDULER_POLICY == _Scheduler_PRIORITY 72 #include <rtems/score/prioritybitmap.h> 73 74 /* Priority scheduling uninitialized (globals) consumption */ 75 #define SCHEDULER_OVHD ((sizeof _Scheduler) + \ 76 (sizeof _Priority_Major_bit_map) + \ 77 (sizeof _Priority_Bit_map)) 78 79 /* Priority scheduling per-thread consumption. Gets 80 * included in the PER_TASK consumption. */ 81 #define SCHEDULER_TASK_WKSP (sizeof(Scheduler_priority_Per_thread)) 82 83 /* Priority scheduling workspace consumption 84 * 85 * Include allocation of ready queue. Pointers are already counted by 86 * including _Scheduler in SCHEDULER_OVHD. 87 */ 88 #define SCHEDULER_WKSP_SIZE \ 68 89 ((RTEMS_MAXIMUM_PRIORITY + 1) * sizeof(Chain_Control )) 90 #endif 69 91 70 92 #define PER_TASK \ 71 93 (long) (sizeof (Thread_Control) + \ 72 NAME_PTR_SIZE + HEAP_OVHD + sizeof( RTEMS_API_Control )) 94 NAME_PTR_SIZE + HEAP_OVHD + sizeof( RTEMS_API_Control ) + \ 95 SCHEDULER_TASK_WKSP ) 73 96 #define PER_SEMAPHORE \ 74 97 (long) (sizeof (Semaphore_Control) + NAME_PTR_SIZE) 75 98 #define PER_TIMER \ … … int initialized = 0; 159 182 * 160 183 * + Object MP 161 184 * - Global Object CB's 162 * + Thread163 * - Ready Chain164 185 * + Thread MP 165 186 * - Proxies Chain 187 * + Scheduler 188 * - Ready queue 166 189 * + Interrupt Manager 167 190 * - Interrupt Stack 168 191 * + Timer Manager … … int initialized = 0; 195 218 * The following calculates the overhead needed by RTEMS from the 196 219 * Workspace Area. 197 220 */ 198 sys_req = SYSTEM_TASKS + /* MPCI Receive Server and IDLE */199 NAME_PTR_SIZE + /* Task Overhead */200 READYCHAINS_SIZE + /* Ready Chains*/201 NAME_PTR_SIZE + /* Timer Overhead */202 NAME_PTR_SIZE + /* Semaphore Overhead */203 NAME_PTR_SIZE + /* Message Queue Overhead */204 NAME_PTR_SIZE + /* Region Overhead */205 NAME_PTR_SIZE + /* Partition Overhead */206 NAME_PTR_SIZE + /* Dual-Ported Memory Overhead */207 NAME_PTR_SIZE + /* Rate Monotonic Overhead */208 NAME_PTR_SIZE + /* Extension Overhead */209 PER_NODE; /* Extra Gobject Table */221 sys_req = SYSTEM_TASKS + /* MPCI Receive Server and IDLE */ 222 NAME_PTR_SIZE + /* Task Overhead */ 223 SCHEDULER_WKSP_SIZE + /* Scheduler Overhead */ 224 NAME_PTR_SIZE + /* Timer Overhead */ 225 NAME_PTR_SIZE + /* Semaphore Overhead */ 226 NAME_PTR_SIZE + /* Message Queue Overhead */ 227 NAME_PTR_SIZE + /* Region Overhead */ 228 NAME_PTR_SIZE + /* Partition Overhead */ 229 NAME_PTR_SIZE + /* Dual-Ported Memory Overhead */ 230 NAME_PTR_SIZE + /* Rate Monotonic Overhead */ 231 NAME_PTR_SIZE + /* Extension Overhead */ 232 PER_NODE; /* Extra Gobject Table */ 210 233 211 234 uninitialized = 212 235 /*address.h*/ 0 + … … uninitialized = 311 334 312 335 /*percpu.h*/ (sizeof _Per_CPU_Information) + 313 336 314 /*priority.h*/ (sizeof _Priority_Major_bit_map) +315 (sizeof _Priority_Bit_map) +316 317 337 /*ratemon.h*/ (sizeof _Rate_monotonic_Information) + 318 338 319 339 /*region.h*/ (sizeof _Region_Information) + … … uninitialized = 324 344 325 345 /*rtems.h*/ /* Not applicable */ 326 346 347 /*scheduler.h*/ SCHEDULER_OVHD + 348 327 349 /*sem.h*/ (sizeof _Semaphore_Information) + 328 350 329 351 #if defined(RTEMS_MULTIPROCESSING) … … uninitialized = 355 377 (sizeof _Thread_Dispatch_disable_level) + 356 378 (sizeof _Thread_Maximum_extensions) + 357 379 (sizeof _Thread_Ticks_per_timeslice) + 358 (sizeof _Thread_Ready_chain) +359 380 (sizeof _Thread_Executing) + 360 381 (sizeof _Thread_Heir) + 361 382 #if (CPU_HARDWARE_FP == 1) || (CPU_SOFTWARE_FP == 1) -
testsuites/tmtests/tm26/task1.c
RCS file: /usr1/CVS/rtems/testsuites/tmtests/tm26/task1.c,v retrieving revision 1.32 diff -u -p -r1.32 task1.c
rtems_task Middle_task( 242 242 Middle_tcb = _Thread_Executing; 243 243 244 244 _Thread_Executing = 245 (Thread_Control *) _Chain_First(&_Thread_Ready_chain[LOW_PRIORITY]); 245 (Thread_Control *) 246 _Chain_First(&_Scheduler.ready_queues.Priority[LOW_PRIORITY]); 246 247 247 248 /* do not force context switch */ 248 249 … … rtems_task Low_task( 279 280 context_switch_another_task_time = benchmark_timer_read(); 280 281 281 282 _Thread_Executing = 282 (Thread_Control *) _Chain_First(&_Thread_Ready_chain[FP1_PRIORITY]); 283 (Thread_Control *) 284 _Chain_First(&_Scheduler.ready_queues.Priority[FP1_PRIORITY]); 283 285 284 286 /* do not force context switch */ 285 287 … … rtems_task Floating_point_task_1( 306 308 executing = _Thread_Executing; 307 309 308 310 _Thread_Executing = 309 (Thread_Control *) _Chain_First(&_Thread_Ready_chain[FP2_PRIORITY]); 311 (Thread_Control *) 312 _Chain_First(&_Scheduler.ready_queues.Priority[FP2_PRIORITY]); 310 313 311 314 /* do not force context switch */ 312 315 … … rtems_task Floating_point_task_1( 329 332 executing = _Thread_Executing; 330 333 331 334 _Thread_Executing = 332 (Thread_Control *) _Chain_First(&_Thread_Ready_chain[FP2_PRIORITY]); 335 (Thread_Control *) 336 _Chain_First(&_Scheduler.ready_queues.Priority[FP2_PRIORITY]); 333 337 334 338 /* do not force context switch */ 335 339 … … rtems_task Floating_point_task_2( 358 362 executing = _Thread_Executing; 359 363 360 364 _Thread_Executing = 361 (Thread_Control *) _Chain_First(&_Thread_Ready_chain[FP1_PRIORITY]); 365 (Thread_Control *) 366 _Chain_First(&_Scheduler.ready_queues.Priority[FP1_PRIORITY]); 362 367 363 368 FP_LOAD( 1.0 ); 364 369 -
testsuites/tmtests/tm27/task1.c
RCS file: /usr1/CVS/rtems/testsuites/tmtests/tm27/task1.c,v retrieving revision 1.29 diff -u -p -r1.29 task1.c
rtems_task Task_1( 170 170 171 171 _Thread_Dispatch_disable_level = 0; 172 172 173 _Thread_Heir = (rtems_tcb *) _Chain_Last(&_Thread_Ready_chain[LOW_PRIORITY]); 173 _Thread_Heir = (rtems_tcb *) 174 _Chain_Last(&_Scheduler.ready_queues.Priority[LOW_PRIORITY]); 174 175 175 176 _Thread_Dispatch_necessary = 1; 176 177 … … rtems_task Task_2( 227 228 228 229 _Thread_Dispatch_disable_level = 0; 229 230 230 _Thread_Heir = (rtems_tcb *) _Chain_First(&_Thread_Ready_chain[LOW_PRIORITY]); 231 _Thread_Heir = (rtems_tcb *) 232 _Chain_First(&_Scheduler.ready_queues.Priority[LOW_PRIORITY]); 231 233 232 234 _Thread_Dispatch_necessary = 1; 233 235