📄 sched.h
字号:
#ifndef _SCHED_H
#define _SCHED_H
#define NR_TASK 3 /* Max tasks */
#define FIRST_TSS_ENTRY 4 /* The first tss descriptor is 4th in GDT. */
#define FIRST_LDT_ENDTY 5 /* The first ldt descriptor is 5th in GDT. */
#define _TSS(n) ((((unsigned long)n)<<4)+0x20) /* Get the tss selector as the task number. */
#define _LDT(n) ((((unsigned long)n)<<4)+0x28) /* Get the ldt selcctor as the task number. */
#define cli() asm("cli;"::) /* clear interrupt mark. */
#define sti() asm("sti;"::) /* set interrupt mark. */
/* Load tr register. */
#define ltr(n) asm(\
"ltr %%ax;"\
::"a"(_TSS(n)))
/* Load ldt register. */
#define lldt(n) asm(\
"lldt %%ax;"\
::"a"(_LDT(n)))
#define cl_nt() asm("pushfl;"\
"andl $0xffffbfff,(%esp);"\
"popfl;")
/*system pointer*/
extern char *_gdt; /*base address of GDT*/
extern char *_idt; /*base address of IDT*/
extern char *_stack_ptr; /*system stack top pointer*/
extern char *_tss0; /*tss0 base address*/
extern char *_ldt0; /*ldt0 base address*/
struct gate_struct{ /*trap descriptor struct*/
unsigned short addrL; /*base address low 16bits*/
unsigned short segsel; /*default is 0x08*/
unsigned char sitems; /*call gate stack items*/
unsigned char type; /*gate descriptor type*/
unsigned short addrH; /*base address high 16bits*/
};
struct desc_struct{ /*descriptor struct,gdt or ldt*/
unsigned short limit; /*segment limit*/
unsigned short baseL; /*base address low 16bits*/
unsigned char baseM; /*base address middle 8bits*/
unsigned char access; /*access type*/
unsigned char gran; /*gran*/
unsigned char baseH; /*address high 8bits*/
};
#define GDT_ADDR ((struct desc_struct*)_gdt) /* GDT base address. */
#define IDT_ADDR ((struct gate_struct*)_idt) /* IDT base address. */
struct i387_struct{
long cwd;
long swd;
long twd;
long fip;
long fcs;
long foo;
long fos;
long st_space[20]; //8*10 bytes for each FP-reg=80 bytes
};
//task state segment struct
struct tss_struct{
long back_link;
long esp0;
long ss0;
long esp1;
long ss1;
long esp2;
long ss2;
long cr3;
long eip;
long eflags;
long eax;
long ecx;
long edx;
long ebx;
long esp;
long ebp;
long esi;
long edi;
long es;
long cs;
long ss;
long ds;
long fs;
long gs;
long ldt;
long trace_bitmap;
//struct i387_struct i387;
};
/*
struct task_struct{
//these are hardcoded -don't touch
long state;
long couter;
long priority;
long signal;
//struct sigaction sigaction[32];
long blocked;
//various fields
int exit_code;
unsigned long start_code,end_code,end_data,brk,start_stack;
long pid,father,pgrp,session,leader;
unsigned short uid,euid,suid;
unsigned short gid,egid,sgid;
long alarm;
long utime,stime,cutime,cstime,start_time;
unsigned short used_math;
//file system information
int tty;
unsigned short umask;
//ldt for this task 0-zero1 -cs 2- ds&ss
struct desc_struct ldt[3];
//tss for this task;
struct tss_struct tss;
};*/
struct task_struct{
long pid; //4B
char pname[16]; //16B
long priority; //4B
long counter; //4B
long ldt_sel; //4B
long tss_sel; //4B
struct desc_struct ldt[4]; //32B
struct tss_struct tss; //68B
struct task_struct *next; //4B
char stack_krn[116]; // kernel mode stack area.
char stack_user[256]; // user mode stck area.
};
struct desc_struct *desc[252];
struct task_struct task[NR_TASK];
unsigned long process_id;
struct task_struct *p_current; /* Point to current task that is running. */
struct task_struct *p_previous; /* Point to previous task. */
struct task_struct *p_ready; /* Point to ready task. */
struct task_struct *p_head; /* Point to task linked list head. */
void sched_init(); /* Initialize task 0 */
void set_trap(int,char *); /* Set trap gate. */
void do_timer(); /* Timer interrupt function. */
void task_init(void *); /* Initialize a new task, make it ready. */
void schedule(); /* System schedule function. */
char *get_com(); /* no use */
void exec_com(char *); /* no use */
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -