aboutsummaryrefslogtreecommitdiffstats
path: root/src/threads/switch.h
diff options
context:
space:
mode:
authorklaar36 <klas.arvidsson@liu.se>2015-03-20 17:30:24 +0100
committerklaar36 <klas.arvidsson@liu.se>2015-03-20 17:30:24 +0100
commite7bc50ca8ffcaa6ed68ebd2315f78b0f5a7d10ad (patch)
tree4de97af7207676b69cb6a9aba8cb443cc134855d /src/threads/switch.h
parentb0418a24e709f0632d2ede5b0f327c422931939b (diff)
downloadpintos-rs-e7bc50ca8ffcaa6ed68ebd2315f78b0f5a7d10ad.tar.gz
Initial Pintos
Diffstat (limited to 'src/threads/switch.h')
-rw-r--r--src/threads/switch.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/threads/switch.h b/src/threads/switch.h
new file mode 100644
index 0000000..cc156b6
--- /dev/null
+++ b/src/threads/switch.h
@@ -0,0 +1,39 @@
+#ifndef THREADS_SWITCH_H
+#define THREADS_SWITCH_H
+
+#ifndef __ASSEMBLER__
+/* switch_thread()'s stack frame. */
+struct switch_threads_frame
+ {
+ uint32_t edi; /* 0: Saved %edi. */
+ uint32_t esi; /* 4: Saved %esi. */
+ uint32_t ebp; /* 8: Saved %ebp. */
+ uint32_t ebx; /* 12: Saved %ebx. */
+ void (*eip) (void); /* 16: Return address. */
+ struct thread *cur; /* 20: switch_threads()'s CUR argument. */
+ struct thread *next; /* 24: switch_threads()'s NEXT argument. */
+ };
+
+/* Switches from CUR, which must be the running thread, to NEXT,
+ which must also be running switch_threads(), returning CUR in
+ NEXT's context. */
+struct thread *switch_threads (struct thread *cur, struct thread *next);
+
+/* Stack frame for switch_entry(). */
+struct switch_entry_frame
+ {
+ void (*eip) (void);
+ };
+
+void switch_entry (void);
+
+/* Pops the CUR and NEXT arguments off the stack, for use in
+ initializing threads. */
+void switch_thunk (void);
+#endif
+
+/* Offsets used by switch.S. */
+#define SWITCH_CUR 20
+#define SWITCH_NEXT 24
+
+#endif /* threads/switch.h */