Skip to content
Permalink
Browse files

doc: scheduler: add diagrams illustrating scheduler

Add some diagrams showing the different scheduling algorithms we
support.

The diagrams were made using draw.io and can be edit using draw.io.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
  • Loading branch information...
nashif committed Jul 14, 2019
1 parent 9058ef1 commit 2a1682e7b383c17d21913108792ee7fdf3b78460
@@ -0,0 +1,2 @@
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" style="background-color: rgb(255, 255, 255);" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="750px" height="424px" viewBox="-0.5 -0.5 750 424" content="&lt;mxfile modified=&quot;2019-07-14T17:01:07.533Z&quot; host=&quot;www.draw.io&quot; agent=&quot;Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Firefox/68.0&quot; etag=&quot;fxvm2qi5s_Qm71g3l8nu&quot; version=&quot;10.9.6&quot; type=&quot;google&quot;&gt;&lt;diagram name=&quot;Cooperative Scheduling&quot; id=&quot;U13eHlzefOwCSCOGrLo0&quot;&gt;7Vpbk9o2FP41PCZjWbaBxw2bbZJJZ5iQTrd96QhbYM0aiwixQH59j2zZ2JKXW7DJpuUF6Vg+ks73nYsEPTxabH8TZBn/ziOa9Fwn2vbwfc91kee58KUkOy1x/CCXzAWLtGwvmLDvtBiopWsW0VVtoOQ8kWxZF4Y8TWkoazIiBN/Uh814Up91SebUEkxCktjSP1kk41w68J29/ANl87iYGTn6yYIUg7VgFZOIbyoi/L6HR4JzmbcW2xFNlPUKu7j4n78f8cRf07E/W34ae9vQfZMrezjnlXILgqbyuqo1us8kWWt76b3KXWFAmkZ3CgfoTRMePvXwu1guEugiaMLTB5YUvZUU/Km0MwZJro5GFkhH9oJKAwM1KV9QKXbw3mYPYYFgXEGvkAmaEMme63MSzaR5qa6cYcwZrMZ1NO0HWo3mvF8woNCw4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FqZOqPJyzo7v/nkw/f/10Kv/8X&lt;/diagram&gt;&lt;/mxfile&gt;"><defs/><g><path d="M 60 380 L 60 32.35" fill="none" stroke="#000000" stroke-width="3" stroke-miterlimit="10" pointer-events="none"/><path d="M 60 23.35 L 64.5 32.35 L 55.5 32.35 Z" fill="#000000" stroke="#000000" stroke-width="3" stroke-miterlimit="10" pointer-events="none"/><path d="M 60 380 L 727.65 380" fill="none" stroke="#000000" stroke-width="3" stroke-miterlimit="10" pointer-events="none"/><path d="M 736.65 380 L 727.65 384.5 L 727.65 375.5 Z" fill="#000000" stroke="#000000" stroke-width="3" stroke-miterlimit="10" pointer-events="none"/><g transform="translate(17.5,249.5)rotate(-90,0,0)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="85" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: &quot;Helvetica&quot;; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; white-space: nowrap; font-weight: bold; text-align: left;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;">Thread Priority</div></div></foreignObject><text x="43" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica" font-weight="bold">Thread Priority</text></switch></g><g transform="translate(361.5,405.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="28" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: &quot;Helvetica&quot;; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; white-space: nowrap; font-weight: bold; text-align: left;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;">Time</div></div></foreignObject><text x="14" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica" font-weight="bold">Time</text></switch></g><g transform="translate(1.5,376.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="22" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: &quot;Helvetica&quot;; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; white-space: nowrap; text-align: left;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;">Low</div></div></foreignObject><text x="11" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">Low</text></switch></g><g transform="translate(1.5,2.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="25" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: &quot;Helvetica&quot;; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; white-space: nowrap; text-align: left;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;">High</div></div></foreignObject><text x="13" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">High</text></switch></g><rect x="100" y="310" width="80" height="30" fill="#ffe6cc" stroke="#d79b00" pointer-events="none"/><g transform="translate(115.5,318.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="48" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: &quot;Helvetica&quot;; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 49px; white-space: nowrap; overflow-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;white-space:normal;">Thread 1</div></div></foreignObject><text x="24" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">Thread 1</text></switch></g><rect x="180" y="249" width="60" height="30" fill="#d5e8d4" stroke="#82b366" pointer-events="none"/><g transform="translate(199.5,257.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="20" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: &quot;Helvetica&quot;; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 21px; white-space: nowrap; overflow-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;white-space:normal;">ISR</div></div></foreignObject><text x="10" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">ISR</text></switch></g><path d="M 180 288.12 L 180 310" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><path d="M 180 281.12 L 183.5 288.12 L 176.5 288.12 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><rect x="240" y="140" width="410" height="30" fill="#ffe6cc" stroke="#d79b00" pointer-events="none"/><g transform="translate(420.5,148.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="48" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: &quot;Helvetica&quot;; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 49px; white-space: nowrap; overflow-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;white-space:normal;">Thread 2</div></div></foreignObject><text x="24" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">Thread 2</text></switch></g><rect x="240" y="310" width="140" height="30" fill="#ffe6cc" stroke="#d79b00" pointer-events="none"/><g transform="translate(285.5,318.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="48" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: &quot;Helvetica&quot;; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 49px; white-space: nowrap; overflow-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;white-space:normal;">Thread 1</div></div></foreignObject><text x="24" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">Thread 1</text></switch></g><path d="M 240 280 L 240 301.88" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><path d="M 240 308.88 L 236.5 301.88 L 243.5 301.88 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><path d="M 130 110 L 150 170 L 214.15 197.49" fill="none" stroke="#ff511c" stroke-miterlimit="10" stroke-dasharray="3 3" pointer-events="none"/><path d="M 218.97 199.56 L 211.16 200.02 L 214.15 197.49 L 213.92 193.59 Z" fill="#ff511c" stroke="#ff511c" stroke-miterlimit="10" pointer-events="none"/><g transform="translate(82.5,76.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="144" height="27" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: &quot;Helvetica&quot;; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; white-space: nowrap; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;">ISR makes the high priority<br />Thread ready</div></div></foreignObject><text x="72" y="20" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">ISR makes the high priority&lt;br&gt;Thread ready</text></switch></g><rect x="240" y="140" width="140" height="30" fill="#ffffff" stroke="none" pointer-events="none"/><g transform="translate(298.5,150.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="23" height="8" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 8px; font-family: &quot;Helvetica&quot;; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 24px; white-space: nowrap; overflow-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;white-space:normal;">Ready</div></div></foreignObject><text x="12" y="8" fill="#000000" text-anchor="middle" font-size="8px" font-family="Helvetica">Ready</text></switch></g><path d="M 380 180.12 L 380 310" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><path d="M 380 173.12 L 383.5 180.12 L 376.5 180.12 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><g transform="translate(443.5,265.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="152" height="24" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 11px; font-family: &quot;Helvetica&quot;; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; white-space: nowrap; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;">Low priority thread relinquishes<br />the CPU</div></div></foreignObject><text x="76" y="18" fill="#000000" text-anchor="middle" font-size="11px" font-family="Helvetica">Low priority thread relinquishes&lt;br/&gt;the CPU</text></switch></g><path d="M 491.43 259 L 458.19 235.73 Q 450 230 440.14 228.36 L 396.28 221.05" fill="none" stroke="#ff511c" stroke-miterlimit="10" stroke-dasharray="3 3" pointer-events="none"/><path d="M 391.1 220.18 L 398.58 217.88 L 396.28 221.05 L 397.43 224.79 Z" fill="#ff511c" stroke="#ff511c" stroke-miterlimit="10" pointer-events="none"/><path d="M 241 249 L 240.07 169.37" fill="none" stroke="#000000" stroke-miterlimit="10" stroke-dasharray="3 3" pointer-events="none"/><path d="M 240.01 164.12 L 243.59 171.08 L 240.07 169.37 L 236.59 171.16 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/></g></svg>
@@ -52,11 +52,17 @@ based on each thread's priority.
Once it becomes the current thread, a cooperative thread remains
the current thread until it performs an action that makes it unready.

.. image:: cooperative.svg
:align: center

* A :dfn:`preemptible thread` has a non-negative priority value.
Once it becomes the current thread, a preemptible thread may be supplanted
at any time if a cooperative thread, or a preemptible thread of higher
or equal priority, becomes ready.

.. image:: preemptive.svg
:align: center

A thread's initial priority value can be altered up or down after the thread
has been started. Thus it possible for a preemptible thread to become
a cooperative thread, and vice versa, by changing its priority.
@@ -70,6 +76,9 @@ ranges:
* cooperative threads: (-:option:`CONFIG_NUM_COOP_PRIORITIES`) to -1
* preemptive threads: 0 to (:option:`CONFIG_NUM_PREEMPT_PRIORITIES` - 1)

.. image:: priorities.svg
:align: center

For example, configuring 5 cooperative priorities and 10 preemptive priorities
results in the ranges -5 to -1 and 0 to 9, respectively.

@@ -126,6 +135,9 @@ To overcome such problems, a preemptive thread can perform cooperative
time slicing (as described above), or the scheduler's time slicing capability
can be used to allow other threads of the same priority to execute.

.. image:: timeslicing.svg
:align: center

The scheduler divides time into a series of **time slices**, where slices
are measured in system clock ticks. The time slice size is configurable,
but this size can be changed while the application is running.
@@ -194,7 +206,7 @@ in driver subsystems. The thread, once woken, will be guaranteed to
run before the current CPU returns into application code.

Unlike similar features in other OSes, meta-IRQ threads are true
threads and run on their own stack (which much be allocated normally),
threads and run on their own stack (which must be allocated normally),
not the per-CPU interrupt stack. Design work to enable the use of the
IRQ stack on supported architectures is pending.

0 comments on commit 2a1682e

Please sign in to comment.
You can’t perform that action at this time.