summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAustin Clements <[email protected]>2009-11-23 17:27:26 -0500
committerAustin Clements <[email protected]>2009-11-23 17:27:26 -0500
commitf4c12f116d328c0b56eabac327a9cc4882c57128 (patch)
treee6b9845f4014a005323a7f46dd62d041352e276a
parentd6cd7d0804c774ddafed204f577e274ad6d81aa3 (diff)
downloadxv6-labs-f4c12f116d328c0b56eabac327a9cc4882c57128.tar.gz
xv6-labs-f4c12f116d328c0b56eabac327a9cc4882c57128.tar.bz2
xv6-labs-f4c12f116d328c0b56eabac327a9cc4882c57128.zip
Add the test we used in lecture to creash the IDE system when the
locks were moved around.
-rw-r--r--Makefile1
-rw-r--r--stressfs.c38
2 files changed, 39 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index 24ba05e..3cab47a 100644
--- a/Makefile
+++ b/Makefile
@@ -107,6 +107,7 @@ UPROGS=\
_mkdir\
_rm\
_sh\
+ _stressfs\
_usertests\
_wc\
_zombie\
diff --git a/stressfs.c b/stressfs.c
new file mode 100644
index 0000000..21a5d16
--- /dev/null
+++ b/stressfs.c
@@ -0,0 +1,38 @@
+// Demonstrate that moving the "acquire" in iderw after the loop that
+// appends to the idequeue results in a race.
+
+// For this to work, you should also add a spin within iderw's
+// idequeue traversal loop. Spinning 40000 times demonstrated the bug
+// after about 5 runs of stressfs in QEMU on a 2.1GHz CPU.
+
+#include "types.h"
+#include "stat.h"
+#include "user.h"
+#include "fs.h"
+#include "fcntl.h"
+
+int
+main(int argc, char *argv[])
+{
+ int i;
+ printf(1, "stressfs starting\n");
+
+ for (i = 0; i < 4; i++) {
+ if (fork() > 0) {
+ break;
+ }
+ }
+
+ printf(1, "%d\n", i);
+
+ char path[] = "stressfs0";
+ path[8] += i;
+ int fd = open(path, O_CREATE | O_RDWR);
+ for (i = 0; i < 100; i++)
+ printf(fd, "%d\n", i);
+ close(fd);
+
+ wait();
+
+ exit();
+}