From abf847a083888bbed4260ecacf849ea19f23e810 Mon Sep 17 00:00:00 2001 From: Frans Kaashoek Date: Tue, 31 Jan 2017 17:47:16 -0500 Subject: Start of an experiment to remove the use of gs for cpu local variables. --- exec.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'exec.c') diff --git a/exec.c b/exec.c index 4d7d97c..14d673f 100644 --- a/exec.c +++ b/exec.c @@ -22,6 +22,7 @@ exec(char *path, char **argv) if((ip = namei(path)) == 0){ end_op(); + cprintf("exec: fail\n"); return -1; } ilock(ip); @@ -89,15 +90,15 @@ exec(char *path, char **argv) for(last=s=path; *s; s++) if(*s == '/') last = s+1; - safestrcpy(proc->name, last, sizeof(proc->name)); + safestrcpy(myproc()->name, last, sizeof(myproc()->name)); // Commit to the user image. - oldpgdir = proc->pgdir; - proc->pgdir = pgdir; - proc->sz = sz; - proc->tf->eip = elf.entry; // main - proc->tf->esp = sp; - switchuvm(proc); + oldpgdir = myproc()->pgdir; + myproc()->pgdir = pgdir; + myproc()->sz = sz; + myproc()->tf->eip = elf.entry; // main + myproc()->tf->esp = sp; + switchuvm(myproc()); freevm(oldpgdir); return 0; -- cgit v1.2.3 From fbb4c0944422f860484142010bb9f366f3e87bf8 Mon Sep 17 00:00:00 2001 From: Frans Kaashoek Date: Tue, 31 Jan 2017 20:21:14 -0500 Subject: Read curproc from cpu structure, but be careful because after a schedule event myproc() points to a different thread. myproc(); sched(); myproc(); // this proc maybe different than the one before sched Thus, in a function that operates on one thread better to retrieve the current process once at the start of the function. --- exec.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'exec.c') diff --git a/exec.c b/exec.c index 14d673f..b40134f 100644 --- a/exec.c +++ b/exec.c @@ -17,6 +17,7 @@ exec(char *path, char **argv) struct inode *ip; struct proghdr ph; pde_t *pgdir, *oldpgdir; + struct proc *curproc = myproc(); begin_op(); @@ -90,15 +91,15 @@ exec(char *path, char **argv) for(last=s=path; *s; s++) if(*s == '/') last = s+1; - safestrcpy(myproc()->name, last, sizeof(myproc()->name)); + safestrcpy(curproc->name, last, sizeof(curproc->name)); // Commit to the user image. - oldpgdir = myproc()->pgdir; - myproc()->pgdir = pgdir; - myproc()->sz = sz; - myproc()->tf->eip = elf.entry; // main - myproc()->tf->esp = sp; - switchuvm(myproc()); + oldpgdir = curproc->pgdir; + curproc->pgdir = pgdir; + curproc->sz = sz; + curproc->tf->eip = elf.entry; // main + curproc->tf->esp = sp; + switchuvm(curproc); freevm(oldpgdir); return 0; -- cgit v1.2.3