summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src/schedulersimplesmp.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* score: Optimize scheduler priority updatesSebastian Huber2017-11-201-120/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Thread priority changes may append or prepend the thread to its priority group on the scheduler ready queue. Previously, a separate priority value and a prepend-it flag in the scheduler node were used to propagate a priority change to the scheduler. Now, use an append-it bit in the priority control and reduce the plain priority value to 63 bits. This change leads to a significant code size reduction (about 25%) of the SMP schedulers. The negligible increase of the standard priority scheduler is due to some additional shift operations (SCHEDULER_PRIORITY_MAP() and SCHEDULER_PRIORITY_UNMAP()). Before: text filename 136 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulersimpleblock.o 464 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulersimplechangepriority.o 24 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulersimple.o 108 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulersimpleschedule.o 292 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulersimpleunblock.o 264 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulersimpleyield.o text filename 280 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulerpriorityblock.o 488 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulerprioritychangepriority.o 200 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulerpriority.o 164 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulerpriorityschedule.o 328 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulerpriorityunblock.o 200 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulerpriorityyield.o text filename 24112 arm-rtems5/c/imx7/cpukit/score/src/libscore_a-scheduleredfsmp.o text filename 37204 sparc-rtems5/c/gr740/cpukit/score/src/libscore_a-scheduleredfsmp.o text filename 42236 powerpc-rtems5/c/qoriq_e6500_32/cpukit/score/src/libscore_a-scheduleredfsmp.o After: text filename 136 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulersimpleblock.o 272 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulersimplechangepriority.o 24 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulersimple.o 108 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulersimpleschedule.o 292 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulersimpleunblock.o 264 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulersimpleyield.o text filename 280 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulerpriorityblock.o 488 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulerprioritychangepriority.o 208 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulerpriority.o 164 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulerpriorityschedule.o 332 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulerpriorityunblock.o 200 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulerpriorityyield.o text filename 18860 arm-rtems5/c/imx7/cpukit/score/src/libscore_a-scheduleredfsmp.o text filename 28520 sparc-rtems5/c/gr740/cpukit/score/src/libscore_a-scheduleredfsmp.o text filename 32664 powerpc-rtems5/c/qoriq_e6500_32/cpukit/score/src/libscore_a-scheduleredfsmp.o
* score: _Chain_Insert_ordered_unprotected()Sebastian Huber2017-11-061-8/+24
| | | | | | Change the chain order relation to use a directly specified left hand side value. This is similar to _RBTree_Insert_inline() and helps the compiler to better optimize the code.
* score: Add simple affinity support to EDF SMPSebastian Huber2017-07-101-1/+2
| | | | Update #3059.
* score: Add red-black tree node to Scheduler_NodeSebastian Huber2017-06-291-8/+8
| | | | | | | In SMP configurations, add a red-black tree node to Scheduler_Node to enable an EDF scheduler implementation. Update #3056.
* score: Improve scheduler helping protocolSebastian Huber2017-02-031-4/+4
| | | | | | | | | | | Only register ask for help requests in the scheduler unblock and yield operations. The actual ask for help operation is carried out during _Thread_Do_dispatch() on a processor related to the thread. This yields a better separation of scheduler instances. A thread of one scheduler instance should not be forced to carry out too much work for threads on other scheduler instances. Update #2556.
* rtems: Add scheduler processor add/removeSebastian Huber2016-11-101-0/+38
| | | | Update #2797.
* score: Simplify yield and unblock scheduler opsSebastian Huber2016-11-021-16/+10
| | | | Update #2556.
* score: Delete unused scheduler ask for help X opSebastian Huber2016-11-021-16/+0
|
* score: Simplify update priority scheduler opSebastian Huber2016-11-021-2/+2
| | | | Remove unused return status.
* score: Add new SMP scheduler helping protocolSebastian Huber2016-11-021-8/+76
| | | | Update #2556.
* score: Pass scheduler node to unblock operationSebastian Huber2016-11-021-1/+3
| | | | | | Changed for consistency with other scheduler operations. Update #2556.
* score: Pass scheduler node to block operationSebastian Huber2016-11-021-1/+3
| | | | | | Changed for consistency with other scheduler operations. Update #2556.
* score: Pass scheduler node to yield operationSebastian Huber2016-11-021-1/+3
| | | | | | Changed for consistency with other scheduler operations. Update #2556.
* score: Pass scheduler node to update priority opSebastian Huber2016-11-021-1/+3
| | | | | | | This enables to call this scheduler operation for all scheduler nodes available to a thread. Update #2556.
* score: Rename scheduler ask for help stuffSebastian Huber2016-11-021-2/+2
| | | | | | | | Rename the scheduler ask for help stuff since this will be replaced step by step with a second generation of the scheduler helping protocol. Keep the old one for now in parallel to reduce the patch set sizes. Update #2556.
* score: Rework thread priority managementSebastian Huber2016-09-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Add priority nodes which contribute to the overall thread priority. The actual priority of a thread is now an aggregation of priority nodes. The thread priority aggregation for the home scheduler instance of a thread consists of at least one priority node, which is normally the real priority of the thread. The locking protocols (e.g. priority ceiling and priority inheritance), rate-monotonic period objects and the POSIX sporadic server add, change and remove priority nodes. A thread changes its priority now immediately, e.g. priority changes are not deferred until the thread releases its last resource. Replace the _Thread_Change_priority() function with * _Thread_Priority_perform_actions(), * _Thread_Priority_add(), * _Thread_Priority_remove(), * _Thread_Priority_change(), and * _Thread_Priority_update(). Update #2412. Update #2556.
* score: Change scheduler node init and destroySebastian Huber2016-07-011-5/+8
| | | | | | Provide the scheduler node to initialize or destroy to the corresponding operations. This makes it possible to have more than one scheduler node per thread.
* score: Add thread priority to scheduler nodesSebastian Huber2016-06-221-21/+7
| | | | | | | | | | | | | | | | | | The thread priority is manifest in two independent areas. One area is the user visible thread priority along with a potential thread queue. The other is the scheduler. Currently, a thread priority update via _Thread_Change_priority() first updates the user visble thread priority and the thread queue, then the scheduler is notified if necessary. The priority is passed to the scheduler via a local variable. A generation counter ensures that the scheduler discards out-of-date priorities. This use of a local variable ties the update in these two areas close together. For later enhancements and the OMIP locking protocol implementation we need more flexibility. Add a thread priority information block to Scheduler_Node and synchronize priority value updates via a sequence lock on SMP configurations. Update #2556.
* score: Fix scheduler helping implementationSebastian Huber2014-07-101-33/+5
| | | | | Do not extract the idle threads from the ready set so that there is always a thread available for comparison.
* score: Fix assertionsSebastian Huber2014-07-101-1/+4
|
* score: Implement scheduler helping protocolSebastian Huber2014-07-091-5/+50
| | | | | | | | | | | | | | | | | | | | | | | | | The following scheduler operations return a thread in need for help - unblock, - change priority, and - yield. A thread in need for help is a thread that encounters a scheduler state change from scheduled to ready or a thread that cannot be scheduled in an unblock operation. Such a thread can ask threads which depend on resources owned by this thread for help. Add a new ask for help scheduler operation. This operation is used by _Scheduler_Ask_for_help() to help threads in need for help returned by the operations mentioned above. This operation is also used by _Scheduler_Thread_change_resource_root() in case the root of a resource sub-tree changes. A use case is the ownership change of a resource. In case it is not possible to schedule a thread in need for help, then the corresponding scheduler node will be placed into the set of ready scheduler nodes of the scheduler instance. Once a state change from ready to scheduled happens for this scheduler node it may be used to schedule the thread in need for help.
* score: Need for help indicator for scheduler opsSebastian Huber2014-07-081-24/+30
| | | | | | | | | | | | | Return a thread in need for help for the following scheduler operations - unblock, - change priority, and - yield. A thread in need for help is a thread that encounters a scheduler state change from scheduled to ready or a thread that cannot be scheduled in an unblock operation. Such a thread can ask threads which depend on resources owned by this thread for help.
* score: Rename *_Node_get() to *_Thread_get_node()Sebastian Huber2014-07-081-2/+2
| | | | | | This emphasizes that the scheduler node of a thread is returned and this is not a function working with scheduler nodes like the other *_Node_*() functions.
* score: Simplify SMP processor allocationSebastian Huber2014-07-081-3/+3
| | | | Avoid copy and paste and set the scheduler node state in one place.
* score: Decouple thread and scheduler nodes on SMPSebastian Huber2014-06-231-41/+57
| | | | | | | Add a chain node to the scheduler node to decouple the thread and scheduler nodes. It is now possible to enqueue a thread in a thread wait queue and use its scheduler node at the same for other threads, e.g. a resouce owner.
* score: PR2181: Add _Thread_Yield()Sebastian Huber2014-06-121-7/+7
| | | | | | | | | | | | | | | | | | | The _Scheduler_Yield() was called by the executing thread with thread dispatching disabled and interrupts enabled. The rtems_task_suspend() is explicitly allowed in ISRs: http://rtems.org/onlinedocs/doc-current/share/rtems/html/c_user/Interrupt-Manager-Directives-Allowed-from-an-ISR.html#Interrupt-Manager-Directives-Allowed-from-an-ISR Unlike the other scheduler operations the locking was performed inside the operation. This lead to the following race condition. Suppose a ISR suspends the executing thread right before the yield scheduler operation. Now the executing thread is not longer in the set of ready threads. The typical scheduler operations did not check the thread state and will now extract the thread again and enqueue it. This corrupted data structures. Add _Thread_Yield() and do the scheduler yield operation with interrupts disabled. This has a negligible effect on the interrupt latency.
* Add SMP Priority Scheduler with AffinityJoel Sherrill2014-06-111-4/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This scheduler attempts to account for needed thread migrations caused as a side-effect of a thread state, affinity, or priority change operation. This scheduler has its own allocate_processor handler named _Scheduler_SMP_Allocate_processor_exact() because _Scheduler_SMP_Allocate_processor() attempts to prevent an executing thread from moving off its current CPU without considering affinity. Without this, the scheduler makes all the right decisions and then they are discarded at the end. ==Side Effects of Adding This Scheduler== Added Thread_Control * parameter to Scheduler_SMP_Get_highest_ready type so methods looking for the highest ready thread can filter by the processor on which the thread blocking resides. This allows affinity to be considered. Simple Priority SMP and Priority SMP ignore this parameter. + Added get_lowest_scheduled argument to _Scheduler_SMP_Enqueue_ordered(). + Added allocate_processor argument to the following methods: - _Scheduler_SMP_Block() - _Scheduler_SMP_Enqueue_scheduled_ordered() - _Scheduler_SMP_Enqueue_scheduled_ordered() + schedulerprioritysmpimpl.h is a new file with prototypes for methods which were formerly static in schedulerprioritysmp.c but now need to be public to be shared with this scheduler. NOTE: _Scheduler_SMP_Get_lowest_ready() appears to have a path which would allow it to return a NULL. Previously, _Scheduler_SMP_Enqueue_ordered() would have asserted on it. If it cannot return a NULL, _Scheduler_SMP_Get_lowest_ready() should have an assertions.
* score: Replace _Scheduler_Allocate/Free()Sebastian Huber2014-06-041-3/+1
| | | | | | | | Replace _Scheduler_Allocate() with _Scheduler_Node_initialize(). Remove the return status and thus the node initialization must be always successful. Rename _Scheduler_Free() to _Scheduler_Node_destroy().
* score: Split SMP scheduler enqueue functionSebastian Huber2014-05-151-13/+58
| | | | | | | | Extract code from _Scheduler_SMP_Enqueue_ordered() and move it to the new function _Scheduler_SMP_Enqueue_scheduled_ordered() to avoid untestable execution paths. Add and use function _Scheduler_SMP_Unblock().
* score: Add and use _Scheduler_SMP_Start_idle()Sebastian Huber2014-05-151-11/+0
|
* score: Add and use _Scheduler_default_Schedule()Sebastian Huber2014-05-151-9/+0
|
* score: Simplify _Thread_Change_priority()Sebastian Huber2014-05-151-55/+59
| | | | | | | | | | | | | | | | | | | | | | | | The function to change a thread priority was too complex. Simplify it with a new scheduler operation. This increases the average case performance due to the simplified logic. The interrupt disabled critical section is a bit prolonged since now the extract, update and enqueue steps are executed atomically. This should however not impact the worst-case interrupt latency since at least for the Deterministic Priority Scheduler this sequence can be carried out with a wee bit of instructions and no loops. Add _Scheduler_Change_priority() to replace the sequence of - _Thread_Set_transient(), - _Scheduler_Extract(), - _Scheduler_Enqueue(), and - _Scheduler_Enqueue_first(). Delete STATES_TRANSIENT, _States_Is_transient() and _Thread_Set_transient() since this state is now superfluous. With this change it is possible to get rid of the SCHEDULER_SMP_NODE_IN_THE_AIR state. This considerably simplifies the implementation of the new SMP locking protocols.
* score: Add and use _Scheduler_Get_context()Sebastian Huber2014-05-141-1/+1
|
* score: Use Scheduler_Context for SMP schedulerSebastian Huber2014-05-141-23/+25
| | | | | | Use the basic Scheduler_Context for the general SMP scheduler operations to avoid usage of structure offsets to get the specialized context variants.
* score: Capitalize SMP acronymSebastian Huber2014-05-141-31/+31
|
* score: Introduce scheduler nodesSebastian Huber2014-05-141-3/+20
| | | | | | | | | | | | Rename scheduler per-thread information into scheduler nodes using Scheduler_Node as the base type. Use inheritance for specialized schedulers. Move the scheduler specific states from the thread control block into the scheduler node structure. Validate the SMP scheduler node state transitions in case RTEMS_DEBUG is defined.
* score: Static scheduler configurationSebastian Huber2014-04-151-44/+42
| | | | | | Do not allocate the scheduler control structures from the workspace. This is a preparation step for configuration of clustered/partitioned schedulers on SMP.
* score: Add scheduler control to scheduler opsSebastian Huber2014-04-041-32/+58
| | | | | Scheduler operations must be free of a global scheduler context to enable partitioned/clustered scheduling.
* score: Move priority bit map to scheduler instanceSebastian Huber2014-04-031-28/+61
| | | | | | Delete global variables _Priority_Major_bit_map and _Priority_Bit_map. This makes it possible to use multiple priority scheduler instances for example with clustered/partitioned scheduling on SMP.
* Change all references of rtems.com to rtems.org.Chris Johns2014-03-211-1/+1
|
* smp: Generalize Simple SMP schedulerSebastian Huber2013-08-201-85/+75
|
* smp: Optimize Simple SMP schedulerSebastian Huber2013-08-201-33/+104
| | | | | | | | | | Add Thread_Control::is_in_the_air field if configured for SMP. This helps to simplify the extract operation and avoids superfluous inter-processor interrupts. Move the processor allocation step into the enqueue operation. Add and use _Scheduler_simple_smp_Get_highest_ready(). Add and use _Scheduler_SMP_Get_lowest_scheduled().
* smp: _Scheduler_simple_smp_Allocate_processor()Sebastian Huber2013-08-201-44/+2
| | | | | Rename _Scheduler_simple_smp_Allocate_processor() to _Scheduler_SMP_Allocate_processor().
* smp: Rename _Scheduler_simple_smp_Start_idle()Sebastian Huber2013-08-201-12/+0
| | | | | Rename _Scheduler_simple_smp_Start_idle() to _Scheduler_SMP_Start_idle().
* smp: Replace Scheduler_simple_smp_ControlSebastian Huber2013-08-201-13/+9
| | | | | Replace Scheduler_simple_smp_Control with Scheduler_SMP_Control. Rename _Scheduler_simple_smp_Instance() to _Scheduler_SMP_Instance().
* score: PR2136: Fix _Thread_Change_priority()Sebastian Huber2013-08-201-2/+2
| | | | | | | | | | | | | | | Add call to _Scheduler_Schedule() in missing path after _Thread_Set_transient() in _Thread_Change_priority(). See also sptests/spintrcritical19. Add thread parameter to _Scheduler_Schedule(). This parameter is currently unused but may be used in future SMP schedulers. Do heir selection in _Scheduler_Schedule(). Use _Scheduler_Update_heir() for this in the particular scheduler implementation. Add and use _Scheduler_Generic_block().
* score: Per-CPU thread dispatch disable levelSebastian Huber2013-08-091-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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).
* smp: Delete _SMP_Request_other_cores_to_dispatch()Sebastian Huber2013-07-301-0/+6
| | | | | Use an event triggered unicast to inform remote processors about a necessary thread dispatch instead.
* score: Create schedulerpriority impl headerSebastian Huber2013-07-261-0/+1
| | | | | | | | | | | | | Move implementation specific parts of schedulerpriority.h and schedulerpriority.inl into new header file schedulerpriorityimpl.h. The schedulerpriority.h contains now only the application visible API. Add missing includes. Remove superfluous includes. Move declaration of _Priority_Bit_map to prioritybitmap.inl since this variable is used only here. Remove second declaration of _Priority_Major_bit_map.
* score: Create schedulersimple impl headerSebastian Huber2013-07-261-0/+1
| | | | | | Move implementation specific parts of schedulersimple.h and schedulersimple.inl into new header file schedulersimpleimpl.h. The schedulersimple.h contains now only the application visible API.