diff options
author | Frans Kaashoek <[email protected]> | 2019-07-17 05:53:47 -0400 |
---|---|---|
committer | Frans Kaashoek <[email protected]> | 2019-07-17 05:53:47 -0400 |
commit | b924e44f06c9c0882a2cffe6c9215b12c5aee2e6 (patch) | |
tree | b1204b01142d7a5b41988b87a4c06b0aabe8b5c9 /user | |
parent | ce53416f4970ebb137c8e66dc75488cfefaf084d (diff) | |
parent | ebc39372096280a4a5957d3e3836c859e5d78a79 (diff) | |
download | xv6-labs-b924e44f06c9c0882a2cffe6c9215b12c5aee2e6.tar.gz xv6-labs-b924e44f06c9c0882a2cffe6c9215b12c5aee2e6.tar.bz2 xv6-labs-b924e44f06c9c0882a2cffe6c9215b12c5aee2e6.zip |
Merge branch 'riscv' of g.csail.mit.edu:xv6-dev into riscv
Diffstat (limited to 'user')
-rw-r--r-- | user/usertests.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/user/usertests.c b/user/usertests.c index 9d46b1a..5cc5099 100644 --- a/user/usertests.c +++ b/user/usertests.c @@ -506,6 +506,44 @@ twochildren(void) printf(1, "twochildren ok\n"); } +// concurrent forks to try to expose locking bugs. +void +forkfork(void) +{ + int ppid = getpid(); + + printf(1, "forkfork test\n"); + + for(int i = 0; i < 2; i++){ + int pid = fork(); + if(pid < 0){ + printf(1, "fork failed"); + exit(); + } + if(pid == 0){ + for(int j = 0; j < 200; j++){ + int pid1 = fork(); + if(pid1 < 0){ + printf(1, "fork failed\n"); + kill(ppid); + exit(); + } + if(pid1 == 0){ + exit(); + } + wait(); + } + exit(); + } + } + + for(int i = 0; i < 2; i++){ + wait(); + } + + printf(1, "forkfork ok\n"); +} + void forkforkfork(void) { @@ -1858,6 +1896,7 @@ main(int argc, char *argv[]) reparent(); twochildren(); + forkfork(); forkforkfork(); argptest(); |