Commit Graph

126 Commits

Author SHA1 Message Date
Sebastian Huber
7a462cc60d score: Fix warning 2017-02-15 11:09:32 +01:00
Sebastian Huber
e366f774a7 score: Add _Thread_queue_Object_name
Add the special thread queue name _Thread_queue_Object_name to mark
thread queues embedded in an object with identifier.  Using the special
thread state STATES_THREAD_QUEUE_WITH_IDENTIFIER is not reliable for
this purpose since the thread wait information and thread state are
protected by different SMP locks in separate critical sections.  Remove
STATES_THREAD_QUEUE_WITH_IDENTIFIER.

Add and use _Thread_queue_Object_initialize().

Update #2858.
2017-01-31 09:38:07 +01:00
Sebastian Huber
70488f5655 score: Fix _Thread_Initialize() 2017-01-31 09:38:07 +01:00
Sebastian Huber
27bfcd88f7 score: Delete _CPU_Context_Fp_start()
Since the FP area pointer is passed by reference in
_CPU_Context_Initialize_fp() the optional FP area adjustment via
_CPU_Context_Fp_start() is superfluous.  It is also wrong with respect
to memory management, e.g. pointer passed to _Workspace_Free() may be
not the one returned by _Workspace_Allocate().

Close #1400.
2017-01-26 07:31:09 +01:00
Sebastian Huber
537f00ebe8 score: Restrict task interrupt level to 0 on SMP
Update #2811.
2016-11-18 07:30:35 +01:00
Sebastian Huber
05ca53ddf6 rtems: Add scheduler processor add/remove
Update #2797.
2016-11-10 09:22:09 +01:00
Sebastian Huber
2dd098a635 score: Introduce Thread_Scheduler_control::home
Replace Thread_Scheduler_control::control and
Thread_Scheduler_control::own_control with new
Thread_Scheduler_control::home.

Update #2556.
2016-11-02 10:05:45 +01:00
Sebastian Huber
7f7424329e score: Delete Thread_Scheduler_control::own_node
Update #2556.
2016-11-02 10:05:45 +01:00
Sebastian Huber
c0f1f52763 score: Delete Thread_Scheduler_control::node
Update #2556.
2016-11-02 10:05:45 +01:00
Sebastian Huber
97f7dac660 score: Delete _Scheduler_Ask_for_help_if_necessary
Delete Thread_Control::Resource_node.

Update #2556.
2016-11-02 10:05:44 +01:00
Sebastian Huber
ebdd2a3431 score: Add scheduler node requests
Add the ability to add/remove scheduler nodes to/from the set of
scheduler nodes available to the schedulers for a particular thread.

Update #2556.
2016-11-02 10:05:42 +01:00
Sebastian Huber
07a32d1932 score: Add thread scheduler lock
Update #2556.
2016-11-02 10:05:42 +01:00
Sebastian Huber
4e02681b2f score: Simplify ISR lock name 2016-09-27 07:39:22 +02:00
Sebastian Huber
266d3835d8 score: Manage scheduler nodes via thread queues
Update #2556.
2016-09-21 08:59:32 +02:00
Sebastian Huber
5d6b211981 score: Add scheduler node table for each thread
Update #2556.
2016-09-21 08:59:32 +02:00
Sebastian Huber
300f6a481a score: Rework thread priority management
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.
2016-09-21 08:59:26 +02:00
Sebastian Huber
29594b4dbc score: Remove superfluous SMP debug support
This information turned out to be useless in the last couple of months.
2016-09-07 09:27:59 +02:00
Sebastian Huber
aaaf9610db score: Add debug support to red-black trees
This helps to detect double insert and extract errors.
2016-08-08 09:34:29 +02:00
Sebastian Huber
ff2e6c647d score: Fix and simplify thread wait locks
There was a subtile race condition in _Thread_queue_Do_extract_locked().
It must first update the thread wait flags and then restore the default
thread wait state.  In the previous implementation this could lead under
rare timing conditions to an ineffective _Thread_Wait_tranquilize()
resulting to a corrupt system state.

Update #2556.
2016-08-03 13:57:30 +02:00
Sebastian Huber
1fcac5adc5 score: Turn thread lock into thread wait lock
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.
2016-07-27 10:55:30 +02:00
Sebastian Huber
df2177ab5e score: Change scheduler node init and destroy
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.
2016-07-01 14:47:07 +02:00
Sebastian Huber
b6b25a9e68 score: Fix thread lock on SMP configurations 2016-06-30 07:57:33 +02:00
Sebastian Huber
9bfad8cd51 score: Add thread priority to scheduler nodes
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.
2016-06-22 14:44:56 +02:00
Sebastian Huber
29e1ecab87 score: Simplify _Thread_Life_action_handler()
Use _Thread_Change_life_locked() to avoid duplicated code.  Avoid Giant
lock in _Thread_Life_action_handler().

Update #2555.
Update #2626.
2016-05-20 07:49:39 +02:00
Sebastian Huber
6e4f929296 score: Introduce thread state lock
Update #2556.
2016-05-12 13:24:40 +02:00
Sebastian Huber
500a8e9c62 score: Delete __RTEMS_STRICT_ORDER_MUTEX__
Remove support for strict order mutexes.

Close #2124.
2016-05-02 07:46:16 +02:00
Sebastian Huber
16832b0d9e score: Fix multiprocessing thread proxies
We must provide thread queue heads for the thread wait information for
each thread proxy (thread queue heads were introduced by
d7665823b2).  The thread proxy must be
allocated before the enqueue operation.
2016-03-29 12:06:55 +02:00
Sebastian Huber
5eaf0e7458 posix: Use per-thread lookup tree for POSIX Keys
Yields higher performance on SMP systems.

Close #2625.
2016-03-18 07:43:46 +01:00
Sebastian Huber
03b900d3ed score: Replace watchdog handler implementation
Use a red-black tree instead of delta chains.

Close #2344.
Update #2554.
Update #2555.
Close #2606.
2016-03-04 13:36:10 +01:00
Sebastian Huber
54c3fbd63e score: Initialize thread control to zero
This reduces the code size of the thread initialization.
2015-12-15 07:41:34 +01:00
Sebastian Huber
df55d07f2e score: Untangle thread actions
Remove the thread action handler parameter from
_Thread_Action_initialize() and instead set it later in
_Thread_Add_post_switch_action().  This avoids a dependency on the
thread action handler via the thread initialization.
2015-12-11 08:20:48 +01:00
Sebastian Huber
3995e6d9c2 score: Implement SMP-specific priority queue 2015-09-04 13:25:03 +02:00
Sebastian Huber
0e3c59d65c score: Use a plain ticket lock for thread locks
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-30 09:11:13 +02:00
Sebastian Huber
10e32a2634 score: Add potpourri lock statistics
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-30 08:06:01 +02:00
Sebastian Huber
d7665823b2 score: Introduce Thread_queue_Heads
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-23 08:01:13 +02:00
Joel Sherrill
e6b31b27fb Remove use ticks for statistics configure option.
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-15 13:20:17 -05:00
Sebastian Huber
80fca28198 score: Add _Watchdog_Preinitialize()
Add an assert to ensure that the watchdog is the proper state for a
_Watchdog_Initialize().  This helps to detect invalid initializations
which may lead to a corrupt watchdog chain.
2015-06-13 15:51:21 +02:00
Sebastian Huber
335e5caa9a score: Add Thread_Control::is_fp
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-06-09 09:05:50 +02:00
Sebastian Huber
900d337f96 score: Rework _Thread_Change_priority()
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-19 12:00:47 +02:00
Sebastian Huber
568af83542 score: Add Thread_queue_Operations
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-19 12:00:45 +02:00
Sebastian Huber
57947f137c score: Add thread lock
Update #2273.
2015-03-24 14:35:04 +01:00
Sebastian Huber
2e9c3d5e29 score: Add thread priority change handler
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-24 14:35:04 +01:00
Sebastian Huber
6a941e3a99 score: Fix _Thread_Change_priority()
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-20 08:49:33 +01:00
Sebastian Huber
4c8a0acc3d score: Add thread wait flags
Update #2273.
2015-03-05 11:36:45 +01:00
Jennifer Averett
134a1811c1 score: Add capture data to tcb. 2014-10-27 13:24:27 -05:00
Sebastian Huber
5c3d250959 score: Implement scheduler helping protocol
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-07-09 10:05:17 +02:00
Sebastian Huber
2d36931823 score: Collect scheduler related fields in TCB
Add Thread_Scheduler_control to collect scheduler related fields of the
TCB.
2014-06-23 09:13:00 +02:00
Sebastian Huber
8e46738436 score: Replace _Scheduler_Allocate/Free()
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().
2014-06-04 08:37:06 +02:00
Sebastian Huber
3045738843 score: Add resource node to thread control block 2014-06-03 08:15:16 +02:00
Sebastian Huber
beab7329fc score: Introduce scheduler nodes
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-14 14:46:19 +02:00