diff options
author | rsc <rsc> | 2006-09-06 18:19:11 +0000 |
---|---|---|
committer | rsc <rsc> | 2006-09-06 18:19:11 +0000 |
commit | 2685309fb47a0f60d3b59138d8029c5d901fde91 (patch) | |
tree | cce8197ed0d7d31a4068297e58920bb3ef239164 /sysproc.c | |
parent | 61d03d0eeff3137a6453a773dfe8a51746804920 (diff) | |
download | xv6-labs-2685309fb47a0f60d3b59138d8029c5d901fde91.tar.gz xv6-labs-2685309fb47a0f60d3b59138d8029c5d901fde91.tar.bz2 xv6-labs-2685309fb47a0f60d3b59138d8029c5d901fde91.zip |
split syscall.c into sysfile.c and sysproc.c
Diffstat (limited to 'sysproc.c')
-rw-r--r-- | sysproc.c | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/sysproc.c b/sysproc.c new file mode 100644 index 0000000..f648c0e --- /dev/null +++ b/sysproc.c @@ -0,0 +1,72 @@ +#include "types.h" +#include "stat.h" +#include "param.h" +#include "mmu.h" +#include "proc.h" +#include "defs.h" +#include "x86.h" +#include "traps.h" +#include "syscall.h" +#include "spinlock.h" +#include "buf.h" +#include "fs.h" +#include "fsvar.h" +#include "elf.h" +#include "fd.h" +#include "fcntl.h" + +int +sys_fork(void) +{ + struct proc *np; + + if((np = copyproc(curproc[cpu()])) == 0) + return -1; + np->state = RUNNABLE; + return np->pid; +} + +int +sys_exit(void) +{ + proc_exit(); + return 0; // not reached +} + +int +sys_wait(void) +{ + return proc_wait(); +} + +int +sys_kill(void) +{ + int pid; + + if(fetcharg(0, &pid) < 0) + return -1; + return proc_kill(pid); +} + +int +sys_getpid(void) +{ + struct proc *cp = curproc[cpu()]; + return cp->pid; +} + +int +sys_sbrk(void) +{ + uint addr; + int n; + struct proc *cp = curproc[cpu()]; + + if(fetcharg(0, &n) < 0) + return -1; + if((addr = growproc(n)) == 0xffffffff) + return -1; + setupsegs(cp); + return addr; +} |