summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* score: Need for help indicator for scheduler opsSebastian Huber2014-07-0813-76/+121
| | | | | | | | | | | | | 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-0818-25/+25
| | | | | | 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-083-21/+16
| | | | Avoid copy and paste and set the scheduler node state in one place.
* score: Rename _Scheduler_SMP_Update_heir()Sebastian Huber2014-07-081-1/+1
| | | | | | Rename and move _Scheduler_SMP_Update_heir() to _Thread_Dispatch_update_heir() since this function is not scheduler specific.
* score: Add PER_CPU_OFFSET_EXECUTINGSebastian Huber2014-07-011-0/+10
| | | | | Add PER_CPU_OFFSET_HEIR. Move Per_CPU_Control::executing and Per_CPU_Control::heir for easy offset calculation.
* score: Fix _Thread_Start_multitasking() on SMPSebastian Huber2014-06-241-0/+13
| | | | | | | | | | The _CPU_Context_Restart_self() implementations usually assume that self context is executing. FIXME: We have a race condition in _Thread_Start_multitasking() in case another thread already performed scheduler operations and moved the heir thread to another processor. The time frame for this is likely too small to be practically relevant.
* score: Fix thread deletion on SMPSebastian Huber2014-06-231-5/+5
| | | | | | Close the thread object in _Thread_Make_zombie() so that all blocking operations that use _Thread_Get() in the corresponding release directive can find a terminating thread and can complete the operation.
* score: Decouple thread and scheduler nodes on SMPSebastian Huber2014-06-234-147/+171
| | | | | | | 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: Use chain nodes for ready queue supportSebastian Huber2014-06-233-5/+5
| | | | | This reduces the API to the minimum data structures to maximize the re-usability.
* score: Collect scheduler related fields in TCBSebastian Huber2014-06-231-3/+2
| | | | | Add Thread_Scheduler_control to collect scheduler related fields of the TCB.
* score: Remove scheduler parameter from most opsSebastian Huber2014-06-237-17/+10
| | | | | | | | | | | | | 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: Fix statement with no effectSebastian Huber2014-06-201-1/+1
|
* score: Fix _Thread_Delay_ended() on SMPSebastian Huber2014-06-201-20/+10
| | | | | | | | | | | | | | | | Suppose we have two tasks A and B and two processors. Task A is about to delete task B. Now task B calls rtems_task_wake_after(1) on the other processor. Task B will block on the Giant lock. Task A progresses with the task B deletion until it has to wait for termination. Now task B obtains the Giant lock, sets its state to STATES_DELAYING, initializes its watchdog timer and waits. Eventually _Thread_Delay_ended() is called, but now _Thread_Get() returned NULL since the thread is already marked as deleted. Thus task B remained forever in the STATES_DELAYING state. Instead of passing the thread identifier use the thread control block directly via the watchdog user argument. This makes _Thread_Delay_ended() also a bit more efficient.
* score: PR2181: Add _Thread_Yield()Sebastian Huber2014-06-127-48/+70
| | | | | | | | | | | | | | | | | | | 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.
* score: Make functions inlineSebastian Huber2014-06-121-132/+0
| | | | | | These functions are used only via the function pointers in the generic SMP scheduler implementation. Provide them as static inline so that the compiler can optimize more easily.
* score: Move NULL pointer check to order functionSebastian Huber2014-06-121-2/+26
| | | | This helps to avoid untestable code for the normal SMP schedulers.
* score: Fix warningsSebastian Huber2014-06-121-2/+1
|
* Add SMP Priority Scheduler with AffinityJoel Sherrill2014-06-113-32/+520
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: _Per_CPU_State_wait_for_non_initial_state()Sebastian Huber2014-06-051-0/+56
| | | | | Replace _Per_CPU_State_wait_for_ready_to_start_multitasking() with _Per_CPU_State_wait_for_non_initial_state(). Implement this function.
* score: Rename _Scheduler_Update()Sebastian Huber2014-06-046-14/+24
| | | | | | 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-049-39/+47
| | | | | | | | 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: Add resource node to thread control blockSebastian Huber2014-06-031-0/+2
|
* score: Add and use _Thread_Owns_resources()Sebastian Huber2014-06-032-2/+2
|
* score: Add Resource HandlerSebastian Huber2014-06-031-0/+106
| | | | | | | | | | A resource is something that has at most one owner at a time and may have multiple rivals in case an owner is present. The owner and rivals are impersonated via resource nodes. A resource is represented via the resource control structure. The resource controls and nodes are organized as trees. It is possible to detect deadlocks via such a resource tree. The _Resource_Iterate() function can be used to iterate through such a resource tree starting at a top node.
* score: _Scheduler_Set_affinity()Sebastian Huber2014-06-021-35/+17
| | | | | Do not change the scheduler with this function. Documentation. Coding style.
* score: _Scheduler_Get_affinity()Sebastian Huber2014-06-021-23/+21
| | | | Drop scheduler parameter. Coding style.
* score: Fix race condition in SMP startupSebastian Huber2014-05-261-1/+8
| | | | | | | | | | | | | | Do not use the Per_CPU_Control::started in _SMP_Start_multitasking_on_secondary_processor() since this field may be not up to date when a secondary processor reads it. Use the read-only scheduler assignment instead. Add a new fatal error SMP_FATAL_MULTITASKING_START_ON_INVALID_PROCESSOR. This prevents out-of-bounds access. It is currently not possible to test these fatal errors. One option would be to fake values of the _CPU_SMP_Get_current_processor(), but unfortunately this function is inline on some architectures.
* score: PR2179: Fix initially locked PCP mutexesSebastian Huber2014-05-231-3/+16
| | | | | Elevate the priority of the creating task to the ceiling priority in case a semaphore is created as initially locked.
* cpuset.c: Fix formattingJoel Sherrill2014-05-221-3/+3
|
* score: _Thread_Set_life_protection()Sebastian Huber2014-05-211-4/+0
| | | | | | | Enable usage of _Thread_Set_life_protection() in thread dispatch critical sections. This can be used to enable the thread life-protection with thread dispatching disabled and then enable thread dispatching.
* score: Add comment regarding TLS workspace sizeSebastian Huber2014-05-211-0/+8
|
* score: Split SMP scheduler enqueue functionSebastian Huber2014-05-152-26/+116
| | | | | | | | 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: Make _Thread_queue_Requeue() staticSebastian Huber2014-05-152-58/+47
| | | | | | This function is only used by _Thread_Change_priority(). Make it static to avoid the function call overhead in the performance critical function _Thread_Change_priority().
* score: Add and use _Scheduler_SMP_Start_idle()Sebastian Huber2014-05-153-22/+29
|
* score: Add and use _Scheduler_default_Schedule()Sebastian Huber2014-05-153-18/+22
|
* score: Simplify _Thread_Change_priority()Sebastian Huber2014-05-1522-550/+264
| | | | | | | | | | | | | | | | | | | | | | | | 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-143-5/+6
|
* score: Add STATES_RESTARTINGSebastian Huber2014-05-141-1/+1
| | | | Use separate state for thread restart.
* score: Use Scheduler_Context for SMP schedulerSebastian Huber2014-05-142-47/+47
| | | | | | 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-1422-112/+202
| | | | | | | | | | | | 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: Fix CPU context usage on SMPSebastian Huber2014-05-081-0/+1
| | | | | | | | | | We must not alter the is executing indicator in _CPU_Context_Initialize() since this would cause an invalid state during a self restart. The is executing indicator must be valid at creation time since otherwise _Thread_Kill_zombies() uses an undefined value for not started threads. This could result in a system life lock.
* score: Fix SMP startupSebastian Huber2014-05-071-1/+3
|
* score: Implement forced thread migrationSebastian Huber2014-05-076-50/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* score: Delete _SMP_Test_message_default_handlerSebastian Huber2014-05-071-7/+1
| | | | | A default handler is not necessary. The test message sender must ensure that a handler is installed.
* score: Use atomic operations for SMP messagesSebastian Huber2014-05-051-5/+2
|
* score: Add SMP test message handlerSebastian Huber2014-05-051-0/+8
| | | | | This handler can be used to test the inter-processor interrupt implementation.
* score: SMP_FATAL_SCHEDULER_WITHOUT_PROCESSORSSebastian Huber2014-05-051-16/+0
| | | | | Avoid the SMP_FATAL_SCHEDULER_WITHOUT_PROCESSORS fatal error and make it a run-time error in rtems_scheduler_ident() and _Scheduler_Get_by_id().
* score: Fix TLS size usageSebastian Huber2014-05-052-7/+2
|
* score: Statically initialize _ISR_Vector_tableSebastian Huber2014-04-291-4/+8
|