-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
sched.h
81 lines (65 loc) · 1.63 KB
/
sched.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#ifndef _SCHED_H
#define _SCHED_H
#define THREAD_CPU_CONTEXT 0 // offset of cpu_context in task_struct
#ifndef __ASSEMBLER__
#define THREAD_SIZE 4096
#define NR_TASKS 64
#define FIRST_TASK task[0]
#define LAST_TASK task[NR_TASKS-1]
#define TASK_RUNNING 0
#define TASK_ZOMBIE 1
#define PF_KTHREAD 0x00000002
extern struct task_struct *current;
extern struct task_struct * task[NR_TASKS];
extern int nr_tasks;
struct cpu_context {
unsigned long x19;
unsigned long x20;
unsigned long x21;
unsigned long x22;
unsigned long x23;
unsigned long x24;
unsigned long x25;
unsigned long x26;
unsigned long x27;
unsigned long x28;
unsigned long fp;
unsigned long sp;
unsigned long pc;
};
#define MAX_PROCESS_PAGES 16
struct user_page {
unsigned long phys_addr;
unsigned long virt_addr;
};
struct mm_struct {
unsigned long pgd;
int user_pages_count;
struct user_page user_pages[MAX_PROCESS_PAGES];
int kernel_pages_count;
unsigned long kernel_pages[MAX_PROCESS_PAGES];
};
struct task_struct {
struct cpu_context cpu_context;
long state;
long counter;
long priority;
long preempt_count;
unsigned long flags;
struct mm_struct mm;
};
extern void sched_init(void);
extern void schedule(void);
extern void timer_tick(void);
extern void preempt_disable(void);
extern void preempt_enable(void);
extern void switch_to(struct task_struct* next);
extern void cpu_switch_to(struct task_struct* prev, struct task_struct* next);
extern void exit_process(void);
#define INIT_TASK \
/*cpu_context*/ { { 0,0,0,0,0,0,0,0,0,0,0,0,0}, \
/* state etc */ 0,0,15, 0, PF_KTHREAD, \
/* mm */ { 0, 0, {{0}}, 0, {0}} \
}
#endif
#endif