summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrsc <rsc>2007-08-24 20:04:53 +0000
committerrsc <rsc>2007-08-24 20:04:53 +0000
commit4bcd0f6a77e20c78632b64fe6ee57129556a531d (patch)
treef7cc23fb6d5b036a22fe9a16819a02883493ee48
parent1b789e1d50df4e7b98fa131fc29caf29a5f38bfa (diff)
downloadxv6-labs-4bcd0f6a77e20c78632b64fe6ee57129556a531d.tar.gz
xv6-labs-4bcd0f6a77e20c78632b64fe6ee57129556a531d.tar.bz2
xv6-labs-4bcd0f6a77e20c78632b64fe6ee57129556a531d.zip
Add yield system call, for zombie test program (bad idea?).
-rw-r--r--syscall.c2
-rw-r--r--syscall.h1
-rw-r--r--sysproc.c7
-rw-r--r--usys.S1
-rw-r--r--zombie.c6
5 files changed, 16 insertions, 1 deletions
diff --git a/syscall.c b/syscall.c
index eddf725..4853e35 100644
--- a/syscall.c
+++ b/syscall.c
@@ -105,6 +105,7 @@ extern int sys_sbrk(void);
extern int sys_unlink(void);
extern int sys_wait(void);
extern int sys_write(void);
+extern int sys_yield(void);
static int (*syscalls[])(void) = {
[SYS_chdir] sys_chdir,
@@ -126,6 +127,7 @@ static int (*syscalls[])(void) = {
[SYS_unlink] sys_unlink,
[SYS_wait] sys_wait,
[SYS_write] sys_write,
+[SYS_yield] sys_yield,
};
void
diff --git a/syscall.h b/syscall.h
index c4e90ab..85ea220 100644
--- a/syscall.h
+++ b/syscall.h
@@ -18,3 +18,4 @@
#define SYS_dup 17
#define SYS_getpid 18
#define SYS_sbrk 19
+#define SYS_yield 20
diff --git a/sysproc.c b/sysproc.c
index 9d599de..8cf3291 100644
--- a/sysproc.c
+++ b/sysproc.c
@@ -68,3 +68,10 @@ sys_sbrk(void)
setupsegs(cp);
return addr;
}
+
+int
+sys_yield(void)
+{
+ yield();
+ return 0;
+}
diff --git a/usys.S b/usys.S
index 2f6141d..210774d 100644
--- a/usys.S
+++ b/usys.S
@@ -27,3 +27,4 @@ STUB(chdir)
STUB(dup)
STUB(getpid)
STUB(sbrk)
+STUB(yield)
diff --git a/zombie.c b/zombie.c
index 952f77a..883ea75 100644
--- a/zombie.c
+++ b/zombie.c
@@ -7,6 +7,10 @@
int
main(void)
{
- fork();
+ int i;
+
+ if(fork() > 0)
+ for(i=0; i<10; i++)
+ yield();
exit();
}