diff options
author | Frans Kaashoek <[email protected]> | 2017-01-31 20:21:14 -0500 |
---|---|---|
committer | Frans Kaashoek <[email protected]> | 2017-01-31 20:21:14 -0500 |
commit | fbb4c0944422f860484142010bb9f366f3e87bf8 (patch) | |
tree | 5e339842d43d09a4d23f1a2165391f00af30e308 /proc.h | |
parent | abf847a083888bbed4260ecacf849ea19f23e810 (diff) | |
download | xv6-labs-fbb4c0944422f860484142010bb9f366f3e87bf8.tar.gz xv6-labs-fbb4c0944422f860484142010bb9f366f3e87bf8.tar.bz2 xv6-labs-fbb4c0944422f860484142010bb9f366f3e87bf8.zip |
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.
Diffstat (limited to 'proc.h')
-rw-r--r-- | proc.h | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -30,12 +30,14 @@ mycpu(void) { return cpu; } +#if 0 static inline struct proc* myproc(void) { struct proc *proc; asm("movl %%gs:4, %0" : "=r"(proc)); return proc; } +#endif //PAGEBREAK: 17 @@ -74,6 +76,7 @@ struct proc { struct file *ofile[NOFILE]; // Open files struct inode *cwd; // Current directory char name[16]; // Process name (debugging) + struct cpu *cpu; // If running, which cpu. }; // Process memory is laid out contiguously, low addresses first: |