kern

view src/proc.h @ 52:fa65b4f45366

picking this up again, let's fix it
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 07 Aug 2011 06:42:00 +0300
parents b1e8c8251884
children 23abbeea4d5f
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_RUNNING,
20 STATE_BLOCKED,
21 STATE_ZOMBIE
22 };
25 struct process {
26 int id, parent;
27 enum proc_state state;
29 int ticks_left;
31 /* extends of the process heap, increased by sbrk */
33 /* first page of the user stack, extends up to KMEM_START */
34 int stack_start_pg;
36 struct context ctx;
38 struct process *next, *prev; /* for the scheduler queues */
39 };
41 void init_proc(void);
43 void context_switch(int pid);
45 int get_current_pid(void);
46 struct process *get_current_proc(void);
47 struct process *get_process(int pid);
49 #endif /* PROC_H_ */