Improvements to the concepts article.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2181 35acf78f-673a-0410-8e92-d51de3d6d3f4master
parent
6c3bddd257
commit
fd9d0b74ca
|
@ -36,7 +36,7 @@
|
||||||
* @a Mtx, @a Cond, @a Evt, @a Msg, @a SequentialStream, @a IO, @a IQ, @a OQ,
|
* @a Mtx, @a Cond, @a Evt, @a Msg, @a SequentialStream, @a IO, @a IQ, @a OQ,
|
||||||
* @a Dbg, @a Core, @a Heap, @a Pool.
|
* @a Dbg, @a Core, @a Heap, @a Pool.
|
||||||
*
|
*
|
||||||
* @section api_suffixes API Names Suffixes
|
* @section api_suffixes API Name Suffixes
|
||||||
* The suffix can be one of the following:
|
* The suffix can be one of the following:
|
||||||
* - <b>None</b>, APIs without any suffix can be invoked only from the user
|
* - <b>None</b>, APIs without any suffix can be invoked only from the user
|
||||||
* code in the <b>Normal</b> state unless differently specified. See
|
* code in the <b>Normal</b> state unless differently specified. See
|
||||||
|
@ -112,58 +112,104 @@
|
||||||
* real associated machine state on some architectures. The following diagram
|
* real associated machine state on some architectures. The following diagram
|
||||||
* shows the possible transitions between the states:
|
* shows the possible transitions between the states:
|
||||||
*
|
*
|
||||||
|
* @if LATEX_PDF
|
||||||
* @dot
|
* @dot
|
||||||
digraph example {
|
digraph example {
|
||||||
rankdir="LR";
|
size="5, 7";
|
||||||
node [shape=circle, fontname=Helvetica, fontsize=8, fixedsize="true", width="0.75", height="0.75"];
|
rankdir="LR";
|
||||||
edge [fontname=Helvetica, fontsize=8];
|
node [shape=circle, fontname=Helvetica, fontsize=8, fixedsize="true", width="0.75", height="0.75"];
|
||||||
init [label="Init", style="bold"];
|
edge [fontname=Helvetica, fontsize=8];
|
||||||
norm [label="Normal", shape=doublecircle];
|
init [label="Init", style="bold"];
|
||||||
susp [label="Suspended"];
|
norm [label="Normal", shape=doublecircle];
|
||||||
disab [label="Disabled"];
|
susp [label="Suspended"];
|
||||||
slock [label="S-Locked"];
|
disab [label="Disabled"];
|
||||||
ilock [label="I-Locked"];
|
slock [label="S-Locked"];
|
||||||
slock [label="S-Locked"];
|
ilock [label="I-Locked"];
|
||||||
sleep [label="Sleep"];
|
slock [label="S-Locked"];
|
||||||
sri [label="SRI"];
|
sleep [label="Sleep"];
|
||||||
init -> norm [label="chSysInit()"];
|
sri [label="SRI"];
|
||||||
norm -> slock [label="chSysLock()", constraint=false];
|
init -> norm [label="chSysInit()"];
|
||||||
slock -> norm [label="chSysUnlock()"];
|
norm -> slock [label="chSysLock()", constraint=false];
|
||||||
norm -> susp [label="chSysSuspend()"];
|
slock -> norm [label="chSysUnlock()"];
|
||||||
susp -> disab [label="chSysDisable()"];
|
norm -> susp [label="chSysSuspend()"];
|
||||||
norm -> disab [label="chSysDisable()"];
|
susp -> disab [label="chSysDisable()"];
|
||||||
susp -> norm [label="chSysEnable()"];
|
norm -> disab [label="chSysDisable()"];
|
||||||
disab -> norm [label="chSysEnable()"];
|
susp -> norm [label="chSysEnable()"];
|
||||||
slock -> ilock [label="Context Switch", dir="both"];
|
disab -> norm [label="chSysEnable()"];
|
||||||
norm -> sri [label="Regular IRQ", style="dotted"];
|
disab -> susp [label="chSysSuspend()"];
|
||||||
sri -> norm [label="Regular IRQ return", fontname=Helvetica, fontsize=8];
|
slock -> ilock [label="Context Switch", dir="both"];
|
||||||
sri -> ilock [label="chSysLockFromIsr()", constraint=false];
|
norm -> sri [label="Regular IRQ", style="dotted"];
|
||||||
ilock -> sri [label="chSysUnlockFromIsr()", fontsize=8];
|
sri -> norm [label="Regular IRQ return", fontname=Helvetica, fontsize=8];
|
||||||
norm -> sleep [label="Idle Thread"];
|
sri -> ilock [label="chSysLockFromIsr()", constraint=false];
|
||||||
sleep -> sri [label="Regular IRQ", style="dotted"];
|
ilock -> sri [label="chSysUnlockFromIsr()", fontsize=8];
|
||||||
|
norm -> sleep [label="Idle Thread"];
|
||||||
|
sleep -> sri [label="Regular IRQ", style="dotted"];
|
||||||
}
|
}
|
||||||
* @enddot
|
* @enddot
|
||||||
|
* @else
|
||||||
|
* @dot
|
||||||
|
digraph example {
|
||||||
|
rankdir="LR";
|
||||||
|
node [shape=circle, fontname=Helvetica, fontsize=8, fixedsize="true", width="0.75", height="0.75"];
|
||||||
|
edge [fontname=Helvetica, fontsize=8];
|
||||||
|
init [label="Init", style="bold"];
|
||||||
|
norm [label="Normal", shape=doublecircle];
|
||||||
|
susp [label="Suspended"];
|
||||||
|
disab [label="Disabled"];
|
||||||
|
slock [label="S-Locked"];
|
||||||
|
ilock [label="I-Locked"];
|
||||||
|
slock [label="S-Locked"];
|
||||||
|
sleep [label="Sleep"];
|
||||||
|
sri [label="SRI"];
|
||||||
|
init -> norm [label="chSysInit()"];
|
||||||
|
norm -> slock [label="chSysLock()", constraint=false];
|
||||||
|
slock -> norm [label="chSysUnlock()"];
|
||||||
|
norm -> susp [label="chSysSuspend()"];
|
||||||
|
susp -> disab [label="chSysDisable()"];
|
||||||
|
norm -> disab [label="chSysDisable()"];
|
||||||
|
susp -> norm [label="chSysEnable()"];
|
||||||
|
disab -> norm [label="chSysEnable()"];
|
||||||
|
disab -> susp [label="chSysSuspend()"];
|
||||||
|
slock -> ilock [label="Context Switch", dir="both"];
|
||||||
|
norm -> sri [label="Regular IRQ", style="dotted"];
|
||||||
|
sri -> norm [label="Regular IRQ return", fontname=Helvetica, fontsize=8];
|
||||||
|
sri -> ilock [label="chSysLockFromIsr()", constraint=false];
|
||||||
|
ilock -> sri [label="chSysUnlockFromIsr()", fontsize=8];
|
||||||
|
norm -> sleep [label="Idle Thread"];
|
||||||
|
sleep -> sri [label="Regular IRQ", style="dotted"];
|
||||||
|
}
|
||||||
|
* @enddot
|
||||||
|
* @endif
|
||||||
* Note, the <b>SFI</b>, <b>Halted</b> and <b>SNMI</b> states were not shown
|
* Note, the <b>SFI</b>, <b>Halted</b> and <b>SNMI</b> states were not shown
|
||||||
* because those are reachable from most states:
|
* because those are reachable from most states:
|
||||||
*
|
*
|
||||||
* @dot
|
* @dot
|
||||||
digraph example {
|
digraph example {
|
||||||
rankdir="LR";
|
size="5, 7";
|
||||||
node [shape=circle, fontname=Helvetica, fontsize=8, fixedsize="true", width="0.75", height="0.75"];
|
rankdir="LR";
|
||||||
edge [fontname=Helvetica, fontsize=8];
|
node [shape=circle, fontname=Helvetica, fontsize=8, fixedsize="true", width="0.75", height="0.75"];
|
||||||
any1 [label="Any State\nexcept *"];
|
edge [fontname=Helvetica, fontsize=8];
|
||||||
any2 [label="Any State"];
|
any1 [label="Any State\nexcept *"];
|
||||||
sfi [label="SFI"];
|
sfi [label="SFI"];
|
||||||
halt [label="Halted"];
|
any1 -> sfi [style="dotted", label="Fast IRQ"];
|
||||||
SNMI [label="SNMI"];
|
sfi -> any1 [label="Fast IRQ return"];
|
||||||
any1 -> sfi [style="dotted", label="Fast IRQ"];
|
}
|
||||||
sfi -> any1 [label="Fast IRQ return"];
|
* @enddot
|
||||||
any2 -> halt [label="chSysHalt()"];
|
* @dot
|
||||||
any2 -> SNMI [label="Synchronous NMI"];
|
digraph example {
|
||||||
any2 -> SNMI [label="Asynchronous NMI", style="dotted"];
|
size="5, 7";
|
||||||
SNMI -> any2 [label="NMI return"];
|
rankdir="LR";
|
||||||
halt -> SNMI [label="Asynchronous NMI", style="dotted"];
|
node [shape=circle, fontname=Helvetica, fontsize=8, fixedsize="true", width="0.75", height="0.75"];
|
||||||
SNMI -> halt [label="NMI return"];
|
edge [fontname=Helvetica, fontsize=8];
|
||||||
|
any2 [label="Any State"];
|
||||||
|
halt [label="Halted"];
|
||||||
|
SNMI [label="SNMI"];
|
||||||
|
any2 -> halt [label="chSysHalt()"];
|
||||||
|
any2 -> SNMI [label="Synchronous NMI"];
|
||||||
|
any2 -> SNMI [label="Asynchronous NMI", style="dotted"];
|
||||||
|
SNMI -> any2 [label="NMI return"];
|
||||||
|
halt -> SNMI [label="Asynchronous NMI", style="dotted"];
|
||||||
|
SNMI -> halt [label="NMI return"];
|
||||||
}
|
}
|
||||||
* @enddot
|
* @enddot
|
||||||
* @attention * except: <b>Init</b>, <b>Halt</b>, <b>SNMI</b>, <b>Disabled</b>.
|
* @attention * except: <b>Init</b>, <b>Halt</b>, <b>SNMI</b>, <b>Disabled</b>.
|
||||||
|
@ -174,6 +220,44 @@
|
||||||
* eligible for execution then they are executed in a round-robin way, the
|
* eligible for execution then they are executed in a round-robin way, the
|
||||||
* CPU time slice constant is configurable. The ready list is a double linked
|
* CPU time slice constant is configurable. The ready list is a double linked
|
||||||
* list of threads ordered by priority.<br><br>
|
* list of threads ordered by priority.<br><br>
|
||||||
|
* @if LATEX_PDF
|
||||||
|
* @dot
|
||||||
|
digraph example {
|
||||||
|
size="5, 7";
|
||||||
|
rankdir="LR";
|
||||||
|
|
||||||
|
node [shape=square, fontname=Helvetica, fontsize=8,
|
||||||
|
fixedsize="true", width="0.6", height="0.5"];
|
||||||
|
edge [fontname=Helvetica, fontsize=8];
|
||||||
|
|
||||||
|
subgraph cluster_running {
|
||||||
|
node [shape=square, fontname=Helvetica, fontsize=8,
|
||||||
|
fixedsize="true", width="0.6", height="0.5"];
|
||||||
|
currp [label="'currp'\npointer", style="bold"];
|
||||||
|
T4 [label="Tuser(4)\nprio=100"];
|
||||||
|
label = "Currently Running Thread";
|
||||||
|
penwidth = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
subgraph cluster_rlist {
|
||||||
|
node [shape=square, fontname=Helvetica, fontsize=8,
|
||||||
|
fixedsize="true", width="0.6", height="0.5"];
|
||||||
|
rh [label="ready list\nheader\nprio=0", style="bold"];
|
||||||
|
Ti [label="Tidle\nprio=1"];
|
||||||
|
Tm [label="Tmain\nprio=64"];
|
||||||
|
T1 [label="Tuser(1)\nprio=32"];
|
||||||
|
T2 [label="Tuser(2)\nprio=32"];
|
||||||
|
T3 [label="Tuser(3)\nprio=80"];
|
||||||
|
label = "Threads Ready for Execution";
|
||||||
|
penwidth = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
currp -> T4
|
||||||
|
rh -> Ti -> T1 -> T2 -> Tm -> T3 -> rh [label="p_next"];
|
||||||
|
rh -> T3 -> Tm -> T2 -> T1 -> Ti -> rh [label="p_prev"];
|
||||||
|
}
|
||||||
|
* @enddot
|
||||||
|
* @else
|
||||||
* @dot
|
* @dot
|
||||||
digraph example {
|
digraph example {
|
||||||
rankdir="LR";
|
rankdir="LR";
|
||||||
|
@ -209,35 +293,63 @@
|
||||||
rh -> T3 -> Tm -> T2 -> T1 -> Ti -> rh [label="p_prev"];
|
rh -> T3 -> Tm -> T2 -> T1 -> Ti -> rh [label="p_prev"];
|
||||||
}
|
}
|
||||||
* @enddot
|
* @enddot
|
||||||
|
* @endif
|
||||||
* <br>
|
* <br>
|
||||||
* Note that the currently running thread is not in the ready list, the list
|
* Note that the currently running thread is not in the ready list, the list
|
||||||
* only contains the threads ready to be executed but still actually waiting.
|
* only contains the threads ready to be executed but still actually waiting.
|
||||||
*
|
*
|
||||||
* @section thread_states Threads States
|
* @section thread_states Thread States
|
||||||
* The image shows how threads can change their state in ChibiOS/RT.<br>
|
* The image shows how threads can change their state in ChibiOS/RT.<br>
|
||||||
|
* @if LATEX_PDF
|
||||||
* @dot
|
* @dot
|
||||||
digraph example {
|
digraph example {
|
||||||
/*rankdir="LR";*/
|
size="5, 7";
|
||||||
node [shape=circle, fontname=Helvetica, fontsize=8, fixedsize="true", width="0.75", height="0.75"];
|
rankdir="LR";
|
||||||
edge [fontname=Helvetica, fontsize=8];
|
node [shape=circle, fontname=Helvetica, fontsize=8, fixedsize="true", width="0.75", height="0.75"];
|
||||||
start [label="Start", style="bold"];
|
edge [fontname=Helvetica, fontsize=8];
|
||||||
run [label="Running"];
|
start [label="Start", style="bold"];
|
||||||
ready [label="Ready"];
|
run [label="Running"];
|
||||||
suspend [label="Suspended"];
|
ready [label="Ready"];
|
||||||
sleep [label="Sleeping"];
|
suspend [label="Suspended"];
|
||||||
stop [label="Stop", style="bold"];
|
sleep [label="Sleeping"];
|
||||||
start -> suspend [label="chThdInit()", constraint=false];
|
stop [label="Stop", style="bold"];
|
||||||
start -> run [label="chThdCreate()"];
|
start -> suspend [label="chThdInit()", constraint=false];
|
||||||
start -> ready [label="chThdCreate()"];
|
start -> run [label="chThdCreate()"];
|
||||||
run -> ready [label="Reschedule", dir="both"];
|
start -> ready [label="chThdCreate()"];
|
||||||
suspend -> run [label="chThdResume()"];
|
run -> ready [label="Reschedule", dir="both"];
|
||||||
suspend -> ready [label="chThdResume()"];
|
suspend -> run [label="chThdResume()"];
|
||||||
run -> sleep [label="chSchGoSleepS()"];
|
suspend -> ready [label="chThdResume()"];
|
||||||
sleep -> run [label="chSchWakepS()"];
|
run -> sleep [label="chSchGoSleepS()"];
|
||||||
sleep -> ready [label="chSchWakepS()"];
|
sleep -> run [label="chSchWakepuS()"];
|
||||||
run -> stop [label="chThdExit()"];
|
sleep -> ready [label="chSchWakepuS()"];
|
||||||
|
run -> stop [label="chThdExit()"];
|
||||||
}
|
}
|
||||||
* @enddot
|
* @enddot
|
||||||
|
* @else
|
||||||
|
* @dot
|
||||||
|
digraph example {
|
||||||
|
rankdir="LR";
|
||||||
|
node [shape=circle, fontname=Helvetica, fontsize=8, fixedsize="true", width="0.75", height="0.75"];
|
||||||
|
edge [fontname=Helvetica, fontsize=8];
|
||||||
|
start [label="Start", style="bold"];
|
||||||
|
run [label="Running"];
|
||||||
|
ready [label="Ready"];
|
||||||
|
suspend [label="Suspended"];
|
||||||
|
sleep [label="Sleeping"];
|
||||||
|
stop [label="Stop", style="bold"];
|
||||||
|
start -> suspend [label="chThdInit()", constraint=false];
|
||||||
|
start -> run [label="chThdCreate()"];
|
||||||
|
start -> ready [label="chThdCreate()"];
|
||||||
|
run -> ready [label="Reschedule", dir="both"];
|
||||||
|
suspend -> run [label="chThdResume()"];
|
||||||
|
suspend -> ready [label="chThdResume()"];
|
||||||
|
run -> sleep [label="chSchGoSleepS()"];
|
||||||
|
sleep -> run [label="chSchWakepuS()"];
|
||||||
|
sleep -> ready [label="chSchWakepuS()"];
|
||||||
|
run -> stop [label="chThdExit()"];
|
||||||
|
}
|
||||||
|
* @enddot
|
||||||
|
* @endif
|
||||||
*
|
*
|
||||||
* @section priority Priority Levels
|
* @section priority Priority Levels
|
||||||
* Priorities in ChibiOS/RT are a contiguous numerical range but the initial
|
* Priorities in ChibiOS/RT are a contiguous numerical range but the initial
|
||||||
|
@ -261,13 +373,17 @@
|
||||||
* (inclusive) are reserved. This is the highest numerical value of the
|
* (inclusive) are reserved. This is the highest numerical value of the
|
||||||
* priorities space.
|
* priorities space.
|
||||||
* .
|
* .
|
||||||
* @section warea Threads Working Area
|
* @section warea Thread Working Area
|
||||||
* Each thread has its own stack, a Thread structure and some preemption
|
* Each thread has its own stack, a Thread structure and some preemption
|
||||||
* areas. All the structures are allocated into a "Thread Working Area",
|
* areas. All the structures are allocated into a "Thread Working Area",
|
||||||
* a thread private heap, usually statically declared in your code.
|
* a thread private heap, usually statically declared in your code.
|
||||||
* Threads do not use any memory outside the allocated working area
|
* Threads do not use any memory outside the allocated working area
|
||||||
* except when accessing static shared data.<br><br>
|
* except when accessing static shared data.<br><br>
|
||||||
|
* @if LATEX_PDF
|
||||||
|
* @image latex workspace.eps
|
||||||
|
* @else
|
||||||
* @image html workspace.png
|
* @image html workspace.png
|
||||||
|
* @endif
|
||||||
* <br>
|
* <br>
|
||||||
* Note that the preemption area is only present when the thread is not
|
* Note that the preemption area is only present when the thread is not
|
||||||
* running (switched out), the context switching is done by pushing the
|
* running (switched out), the context switching is done by pushing the
|
||||||
|
|
Loading…
Reference in New Issue