Add yield system call, for zombie test program (bad idea?).

This commit is contained in:
rsc 2007-08-24 20:04:53 +00:00
parent 1b789e1d50
commit 4bcd0f6a77
5 changed files with 16 additions and 1 deletions

View file

@ -105,6 +105,7 @@ extern int sys_sbrk(void);
extern int sys_unlink(void); extern int sys_unlink(void);
extern int sys_wait(void); extern int sys_wait(void);
extern int sys_write(void); extern int sys_write(void);
extern int sys_yield(void);
static int (*syscalls[])(void) = { static int (*syscalls[])(void) = {
[SYS_chdir] sys_chdir, [SYS_chdir] sys_chdir,
@ -126,6 +127,7 @@ static int (*syscalls[])(void) = {
[SYS_unlink] sys_unlink, [SYS_unlink] sys_unlink,
[SYS_wait] sys_wait, [SYS_wait] sys_wait,
[SYS_write] sys_write, [SYS_write] sys_write,
[SYS_yield] sys_yield,
}; };
void void

View file

@ -18,3 +18,4 @@
#define SYS_dup 17 #define SYS_dup 17
#define SYS_getpid 18 #define SYS_getpid 18
#define SYS_sbrk 19 #define SYS_sbrk 19
#define SYS_yield 20

View file

@ -68,3 +68,10 @@ sys_sbrk(void)
setupsegs(cp); setupsegs(cp);
return addr; return addr;
} }
int
sys_yield(void)
{
yield();
return 0;
}

1
usys.S
View file

@ -27,3 +27,4 @@ STUB(chdir)
STUB(dup) STUB(dup)
STUB(getpid) STUB(getpid)
STUB(sbrk) STUB(sbrk)
STUB(yield)

View file

@ -7,6 +7,10 @@
int int
main(void) main(void)
{ {
fork(); int i;
if(fork() > 0)
for(i=0; i<10; i++)
yield();
exit(); exit();
} }