added base src
[xv6-db.git] / stressfs.c
blob5d4fee2112e09886e09858b188b62e3efa9934fc
1 // Demonstrate that moving the "acquire" in iderw after the loop that
2 // appends to the idequeue results in a race.
4 // For this to work, you should also add a spin within iderw's
5 // idequeue traversal loop. Spinning 40000 times demonstrated the bug
6 // after about 5 runs of stressfs in QEMU on a 2.1GHz CPU.
8 #include "types.h"
9 #include "stat.h"
10 #include "user.h"
11 #include "fs.h"
12 #include "fcntl.h"
14 int
15 main(int argc, char *argv[])
17 int fd, i;
18 char path[] = "stressfs0";
20 printf(1, "stressfs starting\n");
22 for(i = 0; i < 4; i++)
23 if(fork() > 0)
24 break;
26 printf(1, "%d\n", i);
28 path[8] += i;
29 fd = open(path, O_CREATE | O_RDWR);
30 for(i = 0; i < 100; i++)
31 printf(fd, "%d\n", i);
32 close(fd);
34 wait();
36 exit();