kern

view src/proc.h @ 53:23abbeea4d5f

llalallalala
author John Tsiombikas <nuclear@member.fsf.org>
date Mon, 08 Aug 2011 09:53:10 +0300
parents fa65b4f45366
children 4eaecb14fe31
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 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_ */