kern
view src/proc.h @ 55:88a6c4e192f9
Fixed most important task switching bugs.
Now it seems that I can switch in and out of user space reliably.
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Mon, 15 Aug 2011 04:03:39 +0300 |
parents | 4eaecb14fe31 |
children | 0be4615594df |
line source
1 #ifndef PROC_H_
2 #define PROC_H_
4 #include <inttypes.h>
5 #include "asmops.h"
7 #define MAX_PROC 128
9 struct context {
10 /*struct registers regs;*/ /* saved general purpose registers */
11 /*uint32_t instr_ptr;*/ /* saved eip */
12 uint32_t stack_ptr; /* saved esp */
13 /*uint32_t flags;*/ /* saved eflags */
14 uint32_t pgtbl_paddr; /* physical address of the page table */
15 /* TODO add FPU state */
16 };
18 enum proc_state {
19 STATE_RUNNABLE,
20 STATE_BLOCKED,
21 STATE_ZOMBIE
22 };
25 struct process {
26 int id, parent;
27 enum proc_state state;
29 /* when blocked it's waiting for a wakeup on this address */
30 void *wait_addr;
32 int ticks_left;
34 /* extends of the process heap, increased by sbrk */
36 /* first page of the user stack, extends up to KMEM_START */
37 int user_stack_pg;
38 /* first page of the kernel stack, (KERN_STACK_SIZE) */
39 int kern_stack_pg;
41 struct context ctx;
43 struct process *next, *prev; /* for the scheduler queues */
44 };
46 void init_proc(void);
48 void context_switch(int pid);
50 int get_current_pid(void);
51 struct process *get_current_proc(void);
52 struct process *get_process(int pid);
54 #endif /* PROC_H_ */