summaryrefslogtreecommitdiff
path: root/src/cpu.c
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2018-01-05 16:12:25 +0100
committerRichard Braun <rbraun@sceen.net>2018-01-05 16:12:25 +0100
commit897447864c8e67203ceb0998f4d02e4aa41a635c (patch)
tree89b57ca21f08cd3d9525d277ce26c8c8d747c0ff /src/cpu.c
parent5ad6a354a9a5ba37a57a743ddf3c0659e73e29a9 (diff)
cpu: discuss the stack on interrupt handling
Diffstat (limited to 'src/cpu.c')
-rw-r--r--src/cpu.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/cpu.c b/src/cpu.c
index 3e00d61..1971e77 100644
--- a/src/cpu.c
+++ b/src/cpu.c
@@ -463,6 +463,30 @@ cpu_intr_main(const struct cpu_intr_frame *frame)
* because the interrupt handler has awaken a higher priority thread,
* in which case a context switch is triggerred. Such context switches
* are called involuntary.
+ *
+ * Here is what the stack looks like when such a context switch occurs :
+ *
+ * | | Stack grows down.
+ * | |
+ * | stack of the interrupted thread |
+ * | |
+ * +---------------------------------+ <- interrupt occurs
+ * | |
+ * | struct cpu_intr_frame |
+ * | |
+ * +---------------------------------+
+ * | |
+ * | cpu_intr_main stack frame |
+ * | |
+ * +---------------------------------+
+ * | |
+ * | thread function stack frames |
+ * | |
+ * +---------------------------------+
+ * | |
+ * | thread context on switch | See thread_switch_context in
+ * | | thread_asm.S.
+ * +---------------------------------+
*/
thread_preempt_enable();
}