summaryrefslogtreecommitdiffstats
path: root/cpukit/score/include/rtems/score/thread.h (unfollow)
Commit message (Collapse)AuthorFilesLines
2016-04-06score: Rework MP thread queue callout supportSebastian Huber1-1/+13
The thread queue implementation was heavily reworked to support SMP. This broke the multiprocessing support of the thread queues. This is fixed by this patch. A thread proxy is unblocked due to three reasons 1) timeout, 2) request satisfaction, and 3) extraction. In case 1) no MPCI message must be sent. This is ensured via the _Thread_queue_MP_callout_do_nothing() callout set during _Thread_MP_Allocate_proxy(). In case 2) and 3) an MPCI message must be sent. In case we interrupt the blocking operation during _Thread_queue_Enqueue_critical(), then this message must be sent by the blocking thread. For this the new fields Thread_Proxy_control::thread_queue_callout and Thread_Proxy_control::thread_queue_id are used. Delete the individual API MP callout types and use Thread_queue_MP_callout throughout. This type is only defined in multiprocessing configurations. Prefix the multiprocessing parameters with mp_ to ease code review. Multiprocessing specific parameters are optional due to use of a similar macro pattern. There is no overhead for non-multiprocessing configurations.
2016-04-06score: Delete Thread_Wait_information::idSebastian Huber1-2/+7
This field was only by the monitor in non-multiprocessing configurations. Add new field Thread_Wait_information::remote_id in multiprocessing configurations and use it for the remote procedure call thread queue. Add _Thread_Wait_get_id() to obtain the object identifier for debug and system information tools. Ensure the object layout via static asserts. Add test cases to sptests/spthreadq01.
2016-03-29score: Fix multiprocessing thread proxiesSebastian Huber1-0/+9
We must provide thread queue heads for the thread wait information for each thread proxy (thread queue heads were introduced by d7665823b208daefb6855591d808e1f3075cedcb). The thread proxy must be allocated before the enqueue operation.
2016-03-18posix: Use per-thread lookup tree for POSIX KeysSebastian Huber1-6/+17
Yields higher performance on SMP systems. Close #2625.
2016-03-04score: Replace watchdog handler implementationSebastian Huber1-2/+11
Use a red-black tree instead of delta chains. Close #2344. Update #2554. Update #2555. Close #2606.
2016-03-01score: Delete Thread_CPU_usage_tSebastian Huber1-9/+2
This type is superfluous since all operations with it are done via the _Timestamp_*() functions.
2016-02-03Optional POSIX Cleanup initializationSebastian Huber1-0/+7
Update #2408.
2016-01-11score: Introduce Thread_Entry_informationSebastian Huber1-46/+44
This avoids potential dead code in _Thread_Handler(). It gets rid of the dangerous function pointer casts. Update #2514.
2015-12-24api: Remove deprecated NotepadsAun-Ali Zaidi1-3/+3
Notepads where a feature of RTEMS' tasks that simply functioned in the same way as POSIX keys or threaded local storage (TLS). They were introduced well before per task variables, which are also deprecated, and were barely used in favor of their POSIX alternatives. In addition to their scarce usage, Notepads took up unnecessary memory. For each task: - 16 32-bit integers were allocated. - A total of 64 bytes per task per thread. This is especially critical in low memory and safety-critical applications. They are also defined as uint32_t, and therefore are not guaranteed to hold a pointer. Lastly, they are not portable solutions for SMP and uniprocessor systems, like POSIX keys and TLS. updates #2493.
2015-07-30score: Use a plain ticket lock for thread locksSebastian Huber1-2/+18
This enables external libraries to use thread locks since they are independent of the actual RTEMS build configuration, e.g. profiling enabled or disabled.
2015-07-30score: Add potpourri lock statisticsSebastian Huber1-0/+12
These SMP lock statistics are used for all lock objects that lack a storage space for the statistics. Examples are lock objects used in external libraries which are independent of the actual RTEMS build configuration.
2015-07-30score: Rename struct Thread_ControlSebastian Huber1-1/+4
Add a leading underscore to the structure name to allow forward declarations in standard header files provided by Newlib and GCC.
2015-07-23score: Introduce Thread_queue_HeadsSebastian Huber1-0/+2
Move the storage for the thread queue heads to the threads. Each thread provides a set of thread queue heads allocated from a dedicated memory pool. In case a thread blocks on a queue, then it lends its heads to the queue. In case the thread unblocks, then it takes a free set of threads from the queue. Since a thread can block on at most one queue this works. This mechanism is used in FreeBSD. The motivation for this change is to reduce the memory demands of the synchronization objects. On a 32-bit uni-processor configuration the Thread_queue_Control size is now 8 bytes, compared to 64 bytes in RTEMS 4.10 (other changes reduced the size as well).
2015-07-23score: Introduce Thread_queue_QueueSebastian Huber1-1/+1
Separate the thread queue heads and lock from the operations. This enables the support for light weight objects which only support one queuing discipline.
2015-06-25score: Simplify <rtems/score/thread.h>Sebastian Huber1-36/+9
Avoid Thread_Control typedef in <rtems/score/percpu.h>. This helps to get rid of the <rtems/score/percpu.h> include in <rtems/score/thread.h> which exposes a lot of implementation details.
2015-06-15Remove use ticks for statistics configure option.Joel Sherrill1-6/+2
This was obsolete and broken based upon recent time keeping changes. Thie build option was previously enabled by adding USE_TICKS_FOR_STATISTICS=1 to the configure command line. This propagated into the code as preprocessor conditionals using the __RTEMS_USE_TICKS_FOR_STATISTICS__ conditional.
2015-06-09score: Add Thread_Control::is_fpSebastian Huber1-0/+2
Store the floating-point unit property in the thread control block regardless of the CPU_HARDWARE_FP and CPU_SOFTWARE_FP settings. Make sure the floating-point unit is only enabled for the corresponding multilibs. This helps targets which have a volatile only floating point context like SPARC for example.
2015-05-19score: Rework _Thread_Change_priority()Sebastian Huber1-4/+50
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.
2015-05-19score: More thread queue operationsSebastian Huber1-4/+15
Move thread queue discipline specific operations into Thread_queue_Operations. Use a separate node in the thread control block for the thread queue to make it independent of the scheduler data structures. Update #2273.
2015-05-19score: Add Thread_queue_OperationsSebastian Huber1-57/+29
Replace the Thread_Priority_control with more general Thread_queue_Operations which will be used for generic priority change, timeout, signal and wait queue operations in the future. Update #2273.
2015-05-19score: Generalize _Event_Timeout()Sebastian Huber1-0/+5
Add a thread wait timeout code. Replace _Event_Timeout() with a general purpose _Thread_Timeout() watchdog handler. Update #2273.
2015-05-19score: Reduce thread wait statesSebastian Huber1-5/+2
Merge THREAD_WAIT_STATE_SATISFIED, THREAD_WAIT_STATE_TIMEOUT, THREAD_WAIT_STATE_INTERRUPT_SATISFIED, and THREAD_WAIT_STATE_INTERRUPT_TIMEOUT into one state THREAD_WAIT_STATE_READY_AGAIN. This helps to write generic routines to block a thread. Update #2273.
2015-05-06score: Fix Thread_Control and Thread_Proxy_controlSebastian Huber1-59/+65
Fix layout of the common block of Thread_Control and Thread_Proxy_control. Ensure that the offsets match.
2015-04-21score: Delete object control block ISR lockSebastian Huber1-0/+1
The Objects_Control::Lock was a software layer violation. It worked only for the threads since they are somewhat special. Update #2273.
2015-03-24score: Add thread lockSebastian Huber1-0/+44
Update #2273.
2015-03-24score: Add thread priority change handlerSebastian Huber1-5/+52
Since the thread current priority change and thread queue requeue is performed in one critical section it is possible to simplify the thread queue requeue procedure. Add a thread queue agnostic thread priority change handler so that we are able to use alternative thread queue implementations. Update #2273.
2015-03-20score: Fix _Thread_Change_priority()Sebastian Huber1-0/+9
Atomically update the current priority of a thread and the wait queue. Serialize the scheduler update in a separate critical section with a generation number. New test sptests/spintrcritical23. Close #2310.
2015-03-16cpukit: add and use CPU_Uint32ptr typeGedare Bloom1-1/+1
2015-03-05score: Add thread wait flagsSebastian Huber1-0/+30
Update #2273.
2014-10-27score: Add capture data to tcb.Jennifer Averett1-0/+7
2014-09-23score: Delete Thread_Wait_information::Block2nSebastian Huber1-4/+0
This field is no longer used.
2014-07-15Thread Queue Priority Discipline Reimplemented with RBTreeJoel Sherrill1-0/+4
2014-07-09score: Implement scheduler helping protocolSebastian Huber1-2/+60
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.
2014-06-23score: Collect scheduler related fields in TCBSebastian Huber1-24/+35
Add Thread_Scheduler_control to collect scheduler related fields of the TCB.
2014-06-03score: Add resource node to thread control blockSebastian Huber1-0/+8
2014-05-28rtems/score/thread*.h: Really correct spelling errorJoel Sherrill1-2/+2
2014-05-28rtems/score/thread*.h: TERMINTING to TERMINATINGJoel Sherrill1-2/+2
2014-05-14score: Introduce scheduler nodesSebastian Huber1-27/+6
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.
2014-05-07score: Implement forced thread migrationSebastian Huber1-14/+11
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.
2014-04-16score: DocumentationSebastian Huber1-0/+5
2014-04-15score: Add clustered/partitioned schedulingSebastian Huber1-5/+9
Clustered/partitioned scheduling helps to control the worst-case latencies in the system. The goal is to reduce the amount of shared state in the system and thus prevention of lock contention. Modern multi-processor systems tend to have several layers of data and instruction caches. With clustered/partitioned scheduling it is possible to honour the cache topology of a system and thus avoid expensive cache synchronization traffic. We have clustered scheduling in case the set of processors of a system is partitioned into non-empty pairwise-disjoint subsets. These subsets are called clusters. Clusters with a cardinality of one are partitions. Each cluster is owned by exactly one scheduler instance.
2014-04-15score: Simplify thread control initializationSebastian Huber1-2/+58
The thread control block contains fields that point to application configuration dependent memory areas, like the scheduler information, the API control blocks, the user extension context table, the RTEMS notepads and the Newlib re-entrancy support. Account for these areas in the configuration and avoid extra workspace allocations for these areas. This helps also to avoid heap fragementation and reduces the per thread memory due to a reduced heap allocation overhead.
2014-04-04Disable per task variables when SMP is enabledJoel Sherrill1-0/+4
Per task variables are inherently unsafe in SMP systems. This patch disables them from the build and adds warnings in the appropriate documentation and configuration sections.
2014-04-03score: Remove affinity element from thread.Jennifer Averett1-10/+0
2014-03-31score: Thread life cycle re-implementationSebastian Huber1-2/+44
The thread deletion is now supported on SMP. This change fixes the following PRs: PR1814: SMP race condition between stack free and dispatch PR2035: psxcancel reveals NULL pointer access in _Thread_queue_Extract() The POSIX cleanup handler are now called in the right context (should be called in the context of the terminating thread). http://pubs.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_09.html Add a user extension the reflects a thread termination event. This is used to reclaim the Newlib reentrancy structure (may use file operations), the POSIX cleanup handlers and the POSIX key destructors.
2014-03-31score: Use thread action for thread restartSebastian Huber1-0/+5
The thread restart is now supported on SMP. New test smptests/smpthreadlife01.
2014-03-31score: Add thread actionsSebastian Huber1-0/+59
Thread actions are the building block for efficient implementation of - Classic signals delivery, - POSIX signals delivery, - thread restart notification, - thread delete notification, - forced thread migration on SMP configurations, and - the Multiprocessor Resource Sharing Protocol (MrsP).
2014-03-21Change all references of rtems.com to rtems.org.Chris Johns1-1/+1
2014-03-07POSIX keys now enabled in all configurations.Joel Sherrill1-1/+12
Formerly POSIX keys were only enabled when POSIX threads were enabled. Because they are a truly safe alternative to per-task variables in an SMP system, they are being enabled in all configurations.
2014-03-07Remove trailing whitespace in previous patchesJennifer Averett1-1/+1