Skip to content

Commit 0f0714a

Browse files
arighihtejun
authored andcommitted
sched_ext: Documentation: add task lifecycle summary
Understanding the lifecycle of a task in sched_ext can be not trivial, therefore add a section to the main documentation that summarizes the entire workflow of a task using pseudo-code. Signed-off-by: Andrea Righi <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
1 parent b214b04 commit 0f0714a

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

Documentation/scheduler/sched-ext.rst

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,42 @@ dispatching, and must be dispatched to with ``scx_bpf_dsq_insert()``. See
294294
the function documentation and usage in ``tools/sched_ext/scx_simple.bpf.c``
295295
for more information.
296296

297+
Task Lifecycle
298+
--------------
299+
300+
The following pseudo-code summarizes the entire lifecycle of a task managed
301+
by a sched_ext scheduler:
302+
303+
.. code-block:: c
304+
305+
ops.init_task(); /* A new task is created */
306+
ops.enable(); /* Enable BPF scheduling for the task */
307+
308+
while (task in SCHED_EXT) {
309+
if (task can migrate)
310+
ops.select_cpu(); /* Called on wakeup (optimization) */
311+
312+
ops.runnable(); /* Task becomes ready to run */
313+
314+
while (task is runnable) {
315+
if (task is not in a DSQ) {
316+
ops.enqueue(); /* Task can be added to a DSQ */
317+
318+
/* A CPU becomes available */
319+
320+
ops.dispatch(); /* Task is moved to a local DSQ */
321+
}
322+
ops.running(); /* Task starts running on its assigned CPU */
323+
ops.tick(); /* Called every 1/HZ seconds */
324+
ops.stopping(); /* Task stops running (time slice expires or wait) */
325+
}
326+
327+
ops.quiescent(); /* Task releases its assigned CPU (wait) */
328+
}
329+
330+
ops.disable(); /* Disable BPF scheduling for the task */
331+
ops.exit_task(); /* Task is destroyed */
332+
297333
Where to Look
298334
=============
299335

0 commit comments

Comments
 (0)