Mercurial > hg > Members > tobaru > CbC_xv6
comparison src/proc.h @ 0:83c23a36980d
Init
author | Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 26 May 2017 23:11:05 +0900 |
parents | |
children | a5ccbc210ff8 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:83c23a36980d |
---|---|
1 #ifndef PROC_INCLUDE_ | |
2 #define PROC_INCLUDE_ | |
3 | |
4 // Per-CPU state, now we only support one CPU | |
5 struct cpu { | |
6 uchar id; // index into cpus[] below | |
7 struct context* scheduler; // swtch() here to enter scheduler | |
8 volatile uint started; // Has the CPU started? | |
9 | |
10 int ncli; // Depth of pushcli nesting. | |
11 int intena; // Were interrupts enabled before pushcli? | |
12 | |
13 // Cpu-local storage variables; see below | |
14 struct cpu* cpu; | |
15 struct proc* proc; // The currently-running process. | |
16 }; | |
17 | |
18 extern struct cpu cpus[NCPU]; | |
19 extern int ncpu; | |
20 | |
21 | |
22 extern struct cpu* cpu; | |
23 extern struct proc* proc; | |
24 | |
25 //PAGEBREAK: 17 | |
26 // Saved registers for kernel context switches. The context switcher | |
27 // needs to save the callee save register, as usually. For ARM, it is | |
28 // also necessary to save the banked sp (r13) and lr (r14) registers. | |
29 // There is, however, no need to save the user space pc (r15) because | |
30 // pc has been saved on the stack somewhere. We only include it here | |
31 // for debugging purpose. It will not be restored for the next process. | |
32 // According to ARM calling convension, r0-r3 is caller saved. We do | |
33 // not need to save sp_svc, as it will be saved in the pcb, neither | |
34 // pc_svc, as it will be always be the same value. | |
35 // | |
36 // Keep it in sync with swtch.S | |
37 // | |
38 struct context { | |
39 // svc mode registers | |
40 uint r4; | |
41 uint r5; | |
42 uint r6; | |
43 uint r7; | |
44 uint r8; | |
45 uint r9; | |
46 uint r10; | |
47 uint r11; | |
48 uint r12; | |
49 uint lr; | |
50 }; | |
51 | |
52 | |
53 enum procstate { UNUSED, EMBRYO, SLEEPING, RUNNABLE, RUNNING, ZOMBIE }; | |
54 | |
55 // Per-process state | |
56 struct proc { | |
57 uint sz; // Size of process memory (bytes) | |
58 pde_t* pgdir; // Page table | |
59 char* kstack; // Bottom of kernel stack for this process | |
60 enum procstate state; // Process state | |
61 volatile int pid; // Process ID | |
62 struct proc* parent; // Parent process | |
63 struct trapframe* tf; // Trap frame for current syscall | |
64 struct context* context; // swtch() here to run process | |
65 void* chan; // If non-zero, sleeping on chan | |
66 int killed; // If non-zero, have been killed | |
67 struct file* ofile[NOFILE]; // Open files | |
68 struct inode* cwd; // Current directory | |
69 char name[16]; // Process name (debugging) | |
70 }; | |
71 | |
72 // Process memory is laid out contiguously, low addresses first: | |
73 // text | |
74 // original data and bss | |
75 // fixed-size stack | |
76 // expandable heap | |
77 #endif |