xv6/sysproc.c

72 lines
908 B
C
Raw Normal View History

#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"
2006-09-06 18:40:28 +00:00
#include "file.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;
2006-09-07 14:13:26 +00:00
if(argint(0, &pid) < 0)
return -1;
return proc_kill(pid);
}
int
sys_getpid(void)
{
2006-09-07 14:13:26 +00:00
return curproc[cpu()]->pid;
}
int
sys_sbrk(void)
{
2006-09-07 14:13:26 +00:00
int addr;
int n;
struct proc *cp = curproc[cpu()];
2006-09-07 14:13:26 +00:00
if(argint(0, &n) < 0)
return -1;
2006-09-07 14:13:26 +00:00
if((addr = growproc(n)) < 0)
return -1;
setupsegs(cp);
return addr;
}