xv6-65oo2/sysproc.c

76 lines
847 B
C
Raw Normal View History

#include "types.h"
2009-05-31 00:31:20 +00:00
#include "x86.h"
2007-08-27 23:26:33 +00:00
#include "defs.h"
#include "param.h"
#include "mmu.h"
#include "proc.h"
int
sys_fork(void)
{
2009-05-31 00:38:51 +00:00
return fork();
}
int
sys_exit(void)
{
exit();
return 0; // not reached
}
int
sys_wait(void)
{
return wait();
}
int
sys_kill(void)
{
int pid;
2006-09-07 14:13:26 +00:00
if(argint(0, &pid) < 0)
return -1;
return kill(pid);
}
int
sys_getpid(void)
{
return proc->pid;
}
int
sys_sbrk(void)
{
2006-09-07 14:13:26 +00:00
int addr;
int n;
2006-09-07 14:13:26 +00:00
if(argint(0, &n) < 0)
return -1;
addr = proc->sz;
2009-05-31 00:31:20 +00:00
if(growproc(n) < 0)
return -1;
return addr;
}
int
2007-08-27 13:34:35 +00:00
sys_sleep(void)
{
2007-08-27 13:34:35 +00:00
int n, ticks0;
if(argint(0, &n) < 0)
return -1;
acquire(&tickslock);
ticks0 = ticks;
while(ticks - ticks0 < n){
if(proc->killed){
2007-08-27 13:34:35 +00:00
release(&tickslock);
return -1;
}
sleep(&ticks, &tickslock);
}
release(&tickslock);
return 0;
}