Commit Graph

56 Commits

Author SHA1 Message Date
Sebastian Huber
9278f3d04f score: Canonicalize Doxygen @file comments
Use common phrases for the file brief descriptions.

Update #3706.
2020-12-02 07:45:53 +01:00
Sebastian Huber
80cf60efec Canonicalize config.h include
Use the following variant which was already used by most source files:

  #ifdef HAVE_CONFIG_H
  #include "config.h"
  #endif
2020-04-16 07:30:00 +02:00
Sebastian Huber
4c20da4be4 doxygen: Rename Score* groups in RTEMSScore*
Update #3706
2019-04-04 09:18:55 +02:00
Sebastian Huber
7f7424329e score: Delete Thread_Scheduler_control::own_node
Update #2556.
2016-11-02 10:05:45 +01:00
Sebastian Huber
3a27248054 score: First part of new MrsP implementation
Update #2556.
2016-11-02 10:05:43 +01:00
Sebastian Huber
70c22d9395 score: Add _Thread_Scheduler_remove_wait_node()
Update #2556.
2016-11-02 10:05:41 +01:00
Sebastian Huber
36d7abad13 score: Add _Thread_Scheduler_add_wait_node()
Update #2556.
2016-11-02 10:05:41 +01:00
Sebastian Huber
f6142c19f1 score: Scheduler node awareness for thread queues
Maintain the priority of a thread for each scheduler instance via the
thread queue enqueue, extract, priority actions and surrender
operations.  This replaces the primitive priority boosting.

Update #2556.
2016-09-21 08:59:33 +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
b20b736382 score: Introduce _Thread_Get_priority()
Avoid direct access to thread internal data fields.
2016-09-08 09:55:28 +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
3a58dc8631 score: Priority inherit thread queue operations
Move the priority change due to priority interitance to the thread queue
enqueue operation to simplify the locking on SMP configurations.

Update #2412.
Update #2556.
Update #2765.
2016-07-27 10:55:30 +02:00
Sebastian Huber
f4d1f30792 score: Split _Thread_Change_priority()
Update #2412.
Update #2556.
Update #2765.
2016-07-27 10:55:30 +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
bd12dda405 score: Use thread state lock for current state
In addition protect scheduler of thread by thread state lock.  Enables
use of scheduler per-instance locks.

Update #2555.
2016-05-12 13:24:41 +02:00
Sebastian Huber
dafa5d8843 score: Implement priority boosting 2015-09-04 13:26:17 +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
4054c91646 score: Add scheduler acquire/release
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.
2015-03-24 14:35:05 +01: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
b8a5abf3fa score: Update _Thread_Heir only if necessary
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.
2015-03-05 11:36:19 +01:00
Joel Sherrill
3250664700 Thread Queue: Merge discipline subroutines into main methods
There was a lot of duplication between the discipline subroutines.
With the transition to RBTrees for priority discipline, there were
only a few lines of source code manipulating the data structure
for FIFO and priority. Thus is made sense to fold these back
into the main methods.

As part of doing this all of the tests for discipline were changed
to be in the same order.
2014-07-15 13:42:30 -05:00
Sebastian Huber
92635cb36d score: Remove scheduler parameter from most ops
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.
2014-06-23 09:13:00 +02:00
Sebastian Huber
4d1f5008db score: Rename _Scheduler_Update()
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.
2014-06-04 09:47:11 +02:00
Sebastian Huber
b4bdbcfe27 score: Make _Thread_queue_Requeue() static
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().
2014-05-15 12:18:49 +02:00
Sebastian Huber
f39f667a69 score: Simplify _Thread_Change_priority()
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.
2014-05-15 12:18:44 +02:00
Sebastian Huber
e1598a616d score: Static scheduler configuration
Do not allocate the scheduler control structures from the workspace.
This is a preparation step for configuration of clustered/partitioned
schedulers on SMP.
2014-04-15 08:37:11 +02:00
Sebastian Huber
24934e36e2 score: Add scheduler control to scheduler ops
Scheduler operations must be free of a global scheduler context to
enable partitioned/clustered scheduling.
2014-04-04 11:01:18 +02:00
Chris Johns
c49985691f Change all references of rtems.com to rtems.org. 2014-03-21 08:10:47 +11:00
Sebastian Huber
e5ca54c996 score: PR2136: Fix _Thread_Change_priority()
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().
2013-08-20 10:14:02 +02:00
Sebastian Huber
a1123646ac score: Create threadq implementation header
Move implementation specific parts of tqdata.h, threadq.h and
threadq.inl into new header file threadqimpl.h.  The threadq.h contains
now only the application visible API.

Delete tqdata.h.
2013-07-26 11:55:45 +02:00
Sebastian Huber
5618c37a7a score: Create thread implementation header
Move implementation specific parts of thread.h and thread.inl into new
header file threadimpl.h.  The thread.h contains now only the
application visible API.

Remove superfluous header file includes from various files.
2013-07-26 11:55:44 +02:00
Sebastian Huber
c6e21ee18f score: Create scheduler implementation header
Move implementation specific parts of scheduler.h and scheduler.inl into
new header file schedulerimpl.h.  The scheduler.h contains now only the
application visible API.
2013-07-26 11:55:44 +02:00
Christopher Kerl
1b4758602f score misc: Score misc: Clean up Doxygen #6 (GCI 2012)
This patch is a task from GCI 2012 which improves the Doxygen
comments in the RTEMS source.

http://www.google-melange.com/gci/task/view/google/gci2012/7976215
2012-11-29 13:39:17 -06:00
Joel Sherrill
9b4422a251 Remove All CVS Id Strings Possible Using a Script
Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines
  next to each other after Id string line removed.
+ remove entire comment blocks which only exited to
  contain CVS Ids
+ If the processing left a blank line at the top of
  a file, it was removed.
2012-05-11 08:44:13 -05:00
Joel Sherrill
108c4b085c 2011-02-18 Joel Sherrill <joel.sherrill@oarcorp.com>
* sapi/include/confdefs.h, score/Makefile.am,
	score/include/rtems/score/scheduler.h,
	score/include/rtems/score/schedulerpriority.h,
	score/include/rtems/score/thread.h,
	score/inline/rtems/score/scheduler.inl,
	score/inline/rtems/score/schedulerpriority.inl,
	score/src/scheduler.c, score/src/schedulerpriority.c,
	score/src/schedulerpriorityblock.c,
	score/src/schedulerpriorityschedule.c,
	score/src/schedulerpriorityunblock.c,
	score/src/schedulerpriorityyield.c, score/src/threadchangepriority.c,
	score/src/threadclose.c, score/src/threadinitialize.c,
	score/src/threadsetpriority.c, score/src/threadsettransient.c:
	Significant clean up on Scheduler Plugin Interface. Names were
	shortened. Missing operations added. Many scheduler files had
	unneeded includes removed. Made pointer to scheduler information in
	Thread_Control and Scheduler_Control a void * pointer because the
	thread and scheduler wrapper should be unaware of scheduler types AND
	this is broken for user provided schedulers.
	* score/src/schedulerpriorityallocate.c,
	score/src/schedulerpriorityenqueue.c,
	score/src/schedulerpriorityenqueuefirst.c,
	score/src/schedulerpriorityextract.c,
	score/src/schedulerpriorityfree.c,
	score/src/schedulerpriorityupdate.c: New files.
	* score/src/schedulerprioritythreadschedulerallocate.c,
	score/src/schedulerprioritythreadschedulerfree.c,
	score/src/schedulerprioritythreadschedulerupdate.c: Removed.
2011-02-18 15:12:44 +00:00
Joel Sherrill
010192dd9f 2011-02-17 Joel Sherrill <joel.sherrill@oarcorp.com>
* sapi/include/confdefs.h, sapi/include/rtems/config.h,
	score/include/rtems/score/scheduler.h,
	score/include/rtems/score/schedulerpriority.h,
	score/inline/rtems/score/scheduler.inl,
	score/inline/rtems/score/schedulerpriority.inl,
	score/src/scheduler.c, score/src/schedulerpriority.c,
	score/src/schedulerpriorityblock.c,
	score/src/schedulerpriorityschedule.c,
	score/src/schedulerprioritythreadschedulerallocate.c,
	score/src/schedulerprioritythreadschedulerfree.c,
	score/src/schedulerprioritythreadschedulerupdate.c,
	score/src/schedulerpriorityunblock.c,
	score/src/schedulerpriorityyield.c, score/src/threadchangepriority.c,
	score/src/threadclearstate.c, score/src/threadclose.c,
	score/src/threadinitialize.c, score/src/threadready.c,
	score/src/threadresume.c, score/src/threadsetpriority.c,
	score/src/threadsetstate.c, score/src/threadsuspend.c: Simplify the
	pluggable scheduler interface. Its configuration made a table
	of available schedulers and set a pointer to one of the.
	This was heavy handed since you can only use one scheduler
	in an application. This configuration mechanism resulted in a
	scheduler pointer being passed around when you could put all
	scheduler configuration in an initialized structure.
2011-02-17 22:21:44 +00:00
Joel Sherrill
dcf368747f 2011-01-28 Joel Sherrill <joel.sherrilL@OARcorp.com>
* include/rtems/bspIo.h, include/rtems/concat.h, include/rtems/irq.h,
	score/cpu/i386/rtems/score/idtr.h,
	score/cpu/powerpc/rtems/powerpc/registers.h,
	score/src/objectidtoname.c, score/src/schedulerpriorityblock.c,
	score/src/schedulerpriorityschedule.c,
	score/src/schedulerpriorityunblock.c,
	score/src/schedulerpriorityyield.c, score/src/thread.c,
	score/src/threadchangepriority.c, score/src/threadclearstate.c,
	score/src/threadclose.c, score/src/threadcreateidle.c,
	score/src/threaddelayended.c, score/src/threaddispatch.c,
	score/src/threadget.c, score/src/threadhandler.c,
	score/src/threadinitialize.c, score/src/threadloadenv.c,
	score/src/threadready.c, score/src/threadreset.c,
	score/src/threadrestart.c, score/src/threadresume.c,
	score/src/threadsetpriority.c, score/src/threadsetstate.c,
	score/src/threadsettransient.c, score/src/threadstackallocate.c,
	score/src/threadstackfree.c, score/src/threadstart.c,
	score/src/threadstartmultitasking.c, score/src/threadsuspend.c,
	score/src/threadtickletimeslice.c, score/src/threadyieldprocessor.c:
	Fix typo where license said found in found in.
2011-01-28 20:24:54 +00:00
Joel Sherrill
0faa9dad07 2010-11-24 Gedare Bloom <giddyup44@yahoo.com>
PR 1647/cpukit
	* posix/src/nanosleep.c, posix/src/sched_yield.c,
	rtems/src/taskwakeafter.c, sapi/include/confdefs.h,
	sapi/include/rtems/config.h, sapi/src/exinit.c, score/Makefile.am,
	score/preinstall.am, score/include/rtems/score/prioritybitmap.h,
	score/include/rtems/score/thread.h,
	score/inline/rtems/score/thread.inl, score/src/thread.c,
	score/src/threadchangepriority.c, score/src/threadclearstate.c,
	score/src/threadclose.c, score/src/threadinitialize.c,
	score/src/threadready.c, score/src/threadresume.c,
	score/src/threadsetpriority.c, score/src/threadsetstate.c,
	score/src/threadsettransient.c,	score/src/threadsuspend.c,
	score/src/threadtickletimeslice.c: Refactor scheduler out of thread
	handler to facilitate alternate scheduler implementations.
	* score/src/threadyieldprocessor.c: Removed.
	* score/src/schedulerprioritythreadschedulerupdate.c,
	score/src/schedulerprioritythreadschedulerfree.c,
	score/src/schedulerpriorityblock.c, score/src/scheduler.c,
	score/src/schedulerprioritythreadschedulerallocate.c,
	score/src/schedulerpriorityunblock.c,
	score/src/schedulerpriority.c, score/src/schedulerpriorityyield.c,
	score/include/rtems/score/schedulerpriority.h,
	score/include/rtems/score/scheduler.h,
	score/inline/rtems/score/scheduler.inl,
	score/inline/rtems/score/schedulerpriority.inl: New files.
2010-11-24 15:51:28 +00:00
Joel Sherrill
4b1d26142c 2010-07-30 Gedare Bloom <giddyup44@yahoo.com>
PR 1599/cpukit
	* posix/src/psignalunblockthread.c, posix/src/pthreadkill.c,
	rtems/src/signalsend.c, score/include/rtems/score/percpu.h,
	score/inline/rtems/score/thread.inl, score/src/thread.c,
	score/src/threadchangepriority.c, score/src/threadclearstate.c,
	score/src/threaddispatch.c, score/src/threadready.c,
	score/src/threadresume.c, score/src/threadsetstate.c,
	score/src/threadstartmultitasking.c, score/src/threadsuspend.c,
	score/src/threadyieldprocessor.c: Rename _Context_Switch_necessary to
	_Thread_Dispatch_necessary to more properly reflect the intent.
2010-07-30 18:53:06 +00:00
Joel Sherrill
a55e305ed3 2010-07-29 Gedare Bloom <giddyup44@yahoo.com>
PR 1635/cpukit
	* sapi/src/exinit.c, score/Makefile.am, score/preinstall.am,
	score/include/rtems/score/bitfield.h,
	score/include/rtems/score/priority.h,
	score/include/rtems/score/thread.h,
	score/inline/rtems/score/priority.inl,
	score/inline/rtems/score/thread.inl,
	score/src/threadchangepriority.c, score/src/threadclearstate.c,
	score/src/threadready.c, score/src/threadresume.c,
	score/src/threadsetpriority.c, score/src/threadsetstate.c,
	score/src/threadsettransient.c, score/src/threadsuspend.c:
	Refactoring of priority handling, to isolate the bitmap
	implementation of priorities in the supercore so that priority
	management is a little more modular. This change is in anticipation
	of scheduler implementations that can select how they manage tracking
	priority levels / finding the highest priority ready task. Note that
	most of the changes here are simple renaming, to clarify the use of
	the bitmap-based priority management.
	* score/include/rtems/score/prioritybitmap.h,
	score/inline/rtems/score/prioritybitmap.inl: New files.
2010-07-29 17:52:10 +00:00
Ralf Corsepius
aae7f1a12b Eliminate TRUE/FALSE. 2008-12-22 05:52:32 +00:00
Ralf Corsepius
484a76996e Convert to "bool". 2008-09-04 17:46:39 +00:00
Joel Sherrill
d9aca5f537 2008-05-16 Till Straumann <strauman@slac.stanford.edu>
* score/src/threadchangepriority.c: Just in case the transient
	state was set when we entered, ensure that it is still set when
	we exit.
	* score/src/threadclose.c: When a thread is being deleted, it should
	go into the dormant state -- not the transient state.
2008-05-16 21:51:40 +00:00
Joel Sherrill
45d406f8e9 2007-05-10 Joel Sherrill <joel.sherrill@OARcorp.com>
PR 1241/rtems
	* score/src/threadchangepriority.c, score/src/threadqrequeue.c: Close
	critical section window added with requeueing support.
2007-05-10 18:47:35 +00:00
Joel Sherrill
96d0b64c62 2007-03-05 Joel Sherrill <joel@OARcorp.com>
PR 1222/cpukit
	* score/Makefile.am, score/include/rtems/score/coremutex.h,
	score/include/rtems/score/threadq.h,
	score/inline/rtems/score/coremutex.inl, score/src/coremsgsubmit.c,
	score/src/coremutexsurrender.c, score/src/threadchangepriority.c,
	score/src/threadclearstate.c, score/src/threadhandler.c,
	score/src/threadinitialize.c, score/src/threadqdequeuefifo.c,
	score/src/threadqdequeuepriority.c, score/src/threadqenqueue.c,
	score/src/threadqenqueuefifo.c, score/src/threadqenqueuepriority.c,
	score/src/threadqextractfifo.c, score/src/threadqextractpriority.c,
	score/src/threadsetstate.c: Enhance so that when the prioirity of a
	thread that is blocked on a priority based thread queue is changed,
	that its placement in the queue is reevaluated based upon the new
	priority. This enhancement includes modifications to the SuperCore as
	well as new test cases.
	* score/src/threadqrequeue.c: New file.
2007-03-05 21:01:40 +00:00
Ralf Corsepius
a8eed2387c Include config.h. 2005-01-27 05:57:05 +00:00