Created
January 12, 2011 08:50
-
-
Save oraccha/775892 to your computer and use it in GitHub Desktop.
Linux 0.01: *p = *current;
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
include/linux/sched.h: | |
: | |
extern struct task_struct *current; | |
: | |
kernel/sched.c: | |
: | |
union task_union { | |
struct task_struct task; | |
char stack[PAGE_SIZE]; | |
}; | |
static union task_union init_task = {INIT_TASK,}; | |
long volatile jiffies=0; | |
long startup_time=0; | |
struct task_struct *current = &(init_task.task), *last_task_used_math = NULL; | |
struct task_struct * task[NR_TASKS] = {&(init_task.task), }; | |
: | |
kernel/fork.c: | |
/* | |
* Ok, this is the main fork-routine. It copies the system process | |
* information (task[nr]) and sets up the necessary registers. It | |
* also copies the data segment in it's entirety. | |
*/ | |
int copy_process(int nr,long ebp,long edi,long esi,long gs,long none, | |
long ebx,long ecx,long edx, | |
long fs,long es,long ds, | |
long eip,long cs,long eflags,long esp,long ss) | |
{ | |
struct task_struct *p; | |
int i; | |
struct file *f; | |
p = (struct task_struct *) get_free_page(); | |
if (!p) | |
return -EAGAIN; | |
*p = *current; /* NOTE! this doesn't copy the supervisor stack */ | |
p->state = TASK_RUNNING; | |
p->pid = last_pid; | |
p->father = current->pid; | |
p->counter = p->priority; | |
p->signal = 0; | |
p->alarm = 0; | |
: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment