summaryrefslogtreecommitdiffstats
path: root/cpukit/score/include/rtems/score/schedulerimpl.h (follow)
Commit message (Collapse)AuthorAgeFilesLines
* score: Rework thread priority managementSebastian Huber2016-09-211-35/+51
| | | | | | | | | | | | | | | | | | | | | | | | | 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: Add scheduler node implementation headerSebastian Huber2016-09-081-100/+0
| | | | Update #2556.
* score: Move thread wait node to scheduler nodeSebastian Huber2016-09-081-8/+9
| | | | Update #2556.
* score: Fix a release/cancel job race conditionSebastian Huber2016-08-041-4/+12
| | | | | | | | Split up the potential thread priority change in the scheduler release/cancel job operation. Protect the rate monotonic period state with a dedicated SMP lock. This avoids a race condition during _Rate_monotonic_Timeout() while _Rate_monotonic_Cancel() is called on another processor.
* score: Indroduce cancel job scheduler operationSebastian Huber2016-08-041-0/+14
| | | | | Do not use a deadline value of zero to indicate a job cancellation. Use a dedicated scheduler operation for this.
* score: Turn thread lock into thread wait lockSebastian Huber2016-07-271-0/+14
| | | | | | | | | The _Thread_Lock_acquire() function had a potentially infinite run-time due to the lack of fairness at atomic operations level. Update #2412. Update #2556. Update #2765.
* score: Change scheduler node init and destroySebastian Huber2016-07-011-6/+14
| | | | | | 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.
* rtems: Fix rtems_task_set_scheduler() APISebastian Huber2016-07-011-45/+56
| | | | | | | | | | | Task priorities are only valid within a scheduler instance. The rtems_task_set_scheduler() directive moves a task from one scheduler instance to another using the current priority of the thread. However, the current task priority of the source scheduler instance is undefined in the target scheduler instance. Add a third parameter to specify the priority. Close #2749.
* score: Silence integer conversion warningsSebastian Huber2016-06-241-1/+1
|
* score: Add thread priority to scheduler nodesSebastian Huber2016-06-221-55/+78
| | | | | | | | | | | | | | | | | | 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: Modify release job scheduler operationSebastian Huber2016-06-221-3/+3
| | | | | | Pass the deadline in watchdog ticks to the scheduler. Update #2173.
* score: Introduce map priority scheduler operationSebastian Huber2016-06-221-0/+37
| | | | | | | | | | | Introduce map/unmap priority scheduler operations to map thread priority values from/to the user domain to/from the scheduler domain. Use the map priority operation to validate the thread priority. The EDF schedulers use this new operation to distinguish between normal priorities and priorities obtain through a job release. Update #2173. Update #2556.
* score: Delete unused _Scheduler_Priority_compare()Sebastian Huber2016-06-221-51/+0
| | | | | By convention, thread priorities must be integers in RTEMS. Smaller values represent more important threads.
* score: Avoid Giant lock for scheduler set/getSebastian Huber2016-05-121-11/+31
| | | | Update #2555.
* score: Avoid Giant lock _Scheduler_Set_affinity()Sebastian Huber2016-05-121-3/+3
| | | | Update #2555.
* score: Use thread state lock for current stateSebastian Huber2016-05-121-44/+90
| | | | | | | In addition protect scheduler of thread by thread state lock. Enables use of scheduler per-instance locks. Update #2555.
* score: Fix for RTEMS_DEBUGSebastian Huber2016-03-221-3/+8
| | | | Update #2627.
* score: Fix CPU time used by executing threadsSebastian Huber2016-03-171-13/+19
| | | | | | | | | | | | | | The CPU time used of a thread was previously maintained per-processor mostly during _Thread_Dispatch(). However, on SMP configurations the actual processor of a thread is difficult to figure out since thread dispatching is a highly asynchronous process (e.g. via inter-processor interrupts). Only the intended processor of a thread is known to the scheduler easily. Do the CPU usage accounting during thread heir updates in the context of the scheduler operations. Provide the function _Thread_Get_CPU_time_used() to get the CPU usage of a thread using proper locks to get a consistent value. Close #2627.
* score: Replace watchdog handler implementationSebastian Huber2016-03-041-11/+5
| | | | | | | | | Use a red-black tree instead of delta chains. Close #2344. Update #2554. Update #2555. Close #2606.
* score: Rework _Thread_Change_priority()Sebastian Huber2015-05-191-48/+0
| | | | | | | | | | | | | Move the writes to Thread_Control::current_priority and Thread_Control::real_priority into _Thread_Change_priority() under the protection of the thread lock. Add a filter function to _Thread_Change_priority() to enable specialized variants. Avoid race conditions during a thread priority restore with the new Thread_Control::priority_restore_hint for an important average case optimizations used by priority inheritance mutexes. Update #2273.
* score: Fix scheduler helping protocolSebastian Huber2015-05-111-25/+59
| | | | | | Account for priority changes of threads executing in a foreign partition. Exchange idle threads in case a victim node uses an idle thread and the new scheduled node needs an idle thread.
* score: Add scheduler acquire/releaseSebastian Huber2015-03-241-0/+32
| | | | | | | This is currently a global lock for all scheduler instances. It should get replaced with one lock per scheduler instance in the future. Update #2273.
* Fix even more Doxygen issuesJoel Sherrill2015-03-061-1/+2
|
* score: Update _Thread_Heir only if necessarySebastian Huber2015-03-051-6/+9
| | | | | | | | | | | | | | | | | | | | Previously, the _Thread_Heir was updated unconditionally in case a new heir was determined. The _Thread_Dispatch_necessary was only updated in case the executing thread was preemptible or an internal thread was unblocked. Change this to update the _Thread_Heir and _Thread_Dispatch_necessary only in case the currently selected heir thread is preemptible or a dispatch is forced. Move the schedule decision into the change priority operation and use the schedule operation only in rtems_task_mode() in case preemption is enabled or an ASR dispatch is necessary. This is a behaviour change. Previously, the RTEMS_NO_PREEMPT also prevented signal delivery in certain cases (not always). Now, signal delivery is no longer influenced by RTEMS_NO_PREEMPT. Since the currently selected heir thread is used to determine if a new heir is chosen, non-preemptible heir threads currently not executing now prevent a new heir. This may have an application impact, see change test tm04. Document this change in sp04. Update #2273.
* smp: Fix scheduler helping protocolSebastian Huber2014-11-271-34/+77
| | | | | | | Ensure that scheduler nodes in the SCHEDULER_HELP_ACTIVE_OWNER or SCHEDULER_HELP_ACTIVE_RIVAL helping state are always SCHEDULER_SMP_NODE_READY or SCHEDULER_SMP_NODE_SCHEDULED to ensure the MrsP protocol properties.
* smp: Fix scheduler helping protocolLuca Bonato2014-11-241-14/+14
| | | | | | | | | | | | New test case for smptests/smpmrsp01. Fix _Scheduler_Block_node() in case the node is in the SCHEDULER_HELP_ACTIVE_RIVAL helping state. For example a rtems_task_suspend() on a task waiting for a MrsP semaphore. Fix _Scheduler_Unblock_node() in case the node is in the SCHEDULER_SMP_NODE_READY state. For example a rtems_task_resume() on a task owning or waiting for a MrsP semaphore.
* Add and use RTEMS_CONTAINER_OF()Sebastian Huber2014-08-051-1/+1
|
* score: _Scheduler_Thread_get_own_node()Sebastian Huber2014-07-091-1/+5
| | | | Provide this function also for uni-processor configurations.
* score: Implement scheduler helping protocolSebastian Huber2014-07-091-10/+576
| | | | | | | | | | | | | | | | | | | | | | | | | 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-0/+42
| | | | | | | | | | | | | 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: Add _Scheduler_Help()Sebastian Huber2014-07-081-0/+41
| | | | Manage the help state of threads with respect to scheduling decisions.
* 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: Decouple thread and scheduler nodes on SMPSebastian Huber2014-06-231-0/+22
| | | | | | | 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: Collect scheduler related fields in TCBSebastian Huber2014-06-231-3/+3
| | | | | Add Thread_Scheduler_control to collect scheduler related fields of the TCB.
* score: Remove scheduler parameter from most opsSebastian Huber2014-06-231-47/+46
| | | | | | | | | | | | | Remove the scheduler parameter from most high level scheduler operations like - _Scheduler_Block(), - _Scheduler_Unblock(), - _Scheduler_Change_priority(), - _Scheduler_Update_priority(), - _Scheduler_Release_job(), and - _Scheduler_Yield(). This simplifies the scheduler operations usage.
* score: Avoid NULL pointer accessSebastian Huber2014-06-051-2/+3
| | | | | | Check that the executing thread is not NULL in _Scheduler_Tick(). It may be NULL in case the processor has an optional scheduler assigned and the system was not able to start the processor.
* score: Rename _Scheduler_Update()Sebastian Huber2014-06-041-6/+16
| | | | | | Rename _Scheduler_Update() to _Scheduler_Update_priority(). Add parameter for the new thread priority to avoid direct usage of Thread_Control::current_priority in the scheduler operation.
* score: Replace _Scheduler_Allocate/Free()Sebastian Huber2014-06-041-10/+20
| | | | | | | | 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: _Scheduler_Set_affinity()Sebastian Huber2014-06-021-9/+1
| | | | | Do not change the scheduler with this function. Documentation. Coding style.
* score: _Scheduler_Get_affinity()Sebastian Huber2014-06-021-4/+3
| | | | Drop scheduler parameter. Coding style.
* score: Multiprocessor Resource Sharing ProtocolSebastian Huber2014-05-281-0/+10
| | | | | | | | | | | | | | | | | | | | | | Add basic support for the Multiprocessor Resource Sharing Protocol (MrsP). The Multiprocessor Resource Sharing Protocol (MrsP) is defined in A. Burns and A.J. Wellings, A Schedulability Compatible Multiprocessor Resource Sharing Protocol - MrsP, Proceedings of the 25th Euromicro Conference on Real-Time Systems (ECRTS 2013), July 2013. It is a generalization of the Priority Ceiling Protocol to SMP systems. Each MrsP semaphore uses a ceiling priority per scheduler instance. These ceiling priorities can be specified with rtems_semaphore_set_priority(). A task obtaining or owning a MrsP semaphore will execute with the ceiling priority for its scheduler instance as specified by the MrsP semaphore object. Tasks waiting to get ownership of a MrsP semaphore will not relinquish the processor voluntarily. In case the owner of a MrsP semaphore gets preempted it can ask all tasks waiting for this semaphore to help out and temporarily borrow the right to execute on one of their assigned processors. The help out feature is not implemented with this patch.
* score: Add and use _Scheduler_Get_index_by_id()Sebastian Huber2014-05-211-2/+8
|
* score: Add const qualifierSebastian Huber2014-05-211-1/+1
|
* score: Simplify _Scheduler_Set()Sebastian Huber2014-05-211-1/+1
|
* score: Simplify _Thread_Change_priority()Sebastian Huber2014-05-151-41/+29
| | | | | | | | | | | | | | | | | | | | | | | | 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/+8
|
* score: Introduce scheduler nodesSebastian Huber2014-05-141-0/+7
| | | | | | | | | | | | 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: Scheduler documentationSebastian Huber2014-05-141-8/+21
|
* score: Move out of __RTEMS_HAVE_SYS_CPUSET_H__Sebastian Huber2014-05-121-34/+34
| | | | | Move _Scheduler_Get() and _Scheduler_Set() out of the #if defined(__RTEMS_HAVE_SYS_CPUSET_H__) block.
* score: Implement forced thread migrationSebastian Huber2014-05-071-15/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current implementation of task migration in RTEMS has some implications with respect to the interrupt latency. It is crucial to preserve the system invariant that a task can execute on at most one processor in the system at a time. This is accomplished with a boolean indicator in the task context. The processor architecture specific low-level task context switch code will mark that a task context is no longer executing and waits that the heir context stopped execution before it restores the heir context and resumes execution of the heir task. So there is one point in time in which a processor is without a task. This is essential to avoid cyclic dependencies in case multiple tasks migrate at once. Otherwise some supervising entity is necessary to prevent life-locks. Such a global supervisor would lead to scalability problems so this approach is not used. Currently the thread dispatch is performed with interrupts disabled. So in case the heir task is currently executing on another processor then this prolongs the time of disabled interrupts since one processor has to wait for another processor to make progress. It is difficult to avoid this issue with the interrupt latency since interrupts normally store the context of the interrupted task on its stack. In case a task is marked as not executing we must not use its task stack to store such an interrupt context. We cannot use the heir stack before it stopped execution on another processor. So if we enable interrupts during this transition we have to provide an alternative task independent stack for this time frame. This issue needs further investigation.