kern

view src/proc.h @ 54:4eaecb14fe31

bringing the task switching thing into shape with proper per-process kernel stacks and shit
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 14 Aug 2011 16:57:23 +0300
parents 23abbeea4d5f
children 88a6c4e192f9
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 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 user_stack_pg;
35 /* first page of the kernel stack, (KERN_STACK_SIZE) */
36 int kern_stack_pg;
38 struct context ctx;
40 struct process *next, *prev; /* for the scheduler queues */
41 };
43 void init_proc(void);
45 void context_switch(int pid);
47 int get_current_pid(void);
48 struct process *get_current_proc(void);
49 struct process *get_process(int pid);
51 #endif /* PROC_H_ */