CS318 - Pintos
Pintos source browser for JHU CS318 course
switch.h
Go to the documentation of this file.
1 #ifndef THREADS_SWITCH_H
2 #define THREADS_SWITCH_H
3 
4 #ifndef __ASSEMBLER__
5 /** switch_thread()'s stack frame. */
7  {
8  uint32_t edi; /**< 0: Saved %edi. */
9  uint32_t esi; /**< 4: Saved %esi. */
10  uint32_t ebp; /**< 8: Saved %ebp. */
11  uint32_t ebx; /**< 12: Saved %ebx. */
12  void (*eip) (void); /**< 16: Return address. */
13  struct thread *cur; /**< 20: switch_threads()'s CUR argument. */
14  struct thread *next; /**< 24: switch_threads()'s NEXT argument. */
15  };
16 
17 /** Switches from CUR, which must be the running thread, to NEXT,
18  which must also be running switch_threads(), returning CUR in
19  NEXT's context. */
20 struct thread *switch_threads (struct thread *cur, struct thread *next);
21 
22 /** Stack frame for switch_entry(). */
24  {
25  void (*eip) (void);
26  };
27 
28 void switch_entry (void);
29 
30 /** Pops the CUR and NEXT arguments off the stack, for use in
31  initializing threads. */
32 void switch_thunk (void);
33 #endif
34 
35 /** Offsets used by switch.S. */
36 #define SWITCH_CUR 20
37 #define SWITCH_NEXT 24
38 
39 #endif /**< threads/switch.h */
switch_threads_frame::eip
void(* eip)(void)
16: Return address.
Definition: switch.h:12
switch_threads_frame::ebp
uint32_t ebp
8: Saved ebp.
Definition: switch.h:10
thread
A kernel thread or user process.
Definition: thread.h:83
next
static int next(int pos)
Returns the position after POS within an intq.
Definition: intq.c:79
uint32_t
unsigned int uint32_t
Definition: stdint.h:26
switch_threads_frame
switch_thread()'s stack frame.
Definition: switch.h:6
switch_threads_frame::esi
uint32_t esi
4: Saved esi.
Definition: switch.h:9
switch_entry
void switch_entry(void)
switch_threads_frame::cur
struct thread * cur
20: switch_threads()'s CUR argument.
Definition: switch.h:13
switch_threads_frame::ebx
uint32_t ebx
12: Saved ebx.
Definition: switch.h:11
switch_entry_frame
Stack frame for switch_entry().
Definition: switch.h:23
switch_entry_frame::eip
void(* eip)(void)
Definition: switch.h:25
switch_threads_frame::next
struct thread * next
24: switch_threads()'s NEXT argument.
Definition: switch.h:14
switch_thunk
void switch_thunk(void)
Pops the CUR and NEXT arguments off the stack, for use in initializing threads.
switch_threads_frame::edi
uint32_t edi
0: Saved edi.
Definition: switch.h:8
switch_threads
struct thread * switch_threads(struct thread *cur, struct thread *next)
Switches from CUR, which must be the running thread, to NEXT, which must also be running switch_threa...