comparison src/usr/stressfs.c @ 0:83c23a36980d

Init
author Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
date Fri, 26 May 2017 23:11:05 +0900
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:83c23a36980d
1 // Demonstrate that moving the "acquire" in iderw after the loop that
2 // appends to the idequeue results in a race.
3
4 // For this to work, you should also add a spin within iderw's
5 // idequeue traversal loop. Adding the following demonstrated a panic
6 // after about 5 runs of stressfs in QEMU on a 2.1GHz CPU:
7 // for (i = 0; i < 40000; i++)
8 // asm volatile("");
9
10 #include "types.h"
11 #include "stat.h"
12 #include "user.h"
13 #include "fs.h"
14 #include "fcntl.h"
15
16 int
17 main(int argc, char *argv[])
18 {
19 int fd, i;
20 char path[] = "stressfs0";
21 char data[512];
22
23 printf(1, "stressfs starting\n");
24 memset(data, 'a', sizeof(data));
25
26 for(i = 0; i < 4; i++)
27 if(fork() > 0)
28 break;
29
30 printf(1, "write %d\n", i);
31
32 path[8] += i;
33 fd = open(path, O_CREATE | O_RDWR);
34 for(i = 0; i < 20; i++)
35 // printf(fd, "%d\n", i);
36 write(fd, data, sizeof(data));
37 close(fd);
38
39 printf(1, "read\n");
40
41 fd = open(path, O_RDONLY);
42 for (i = 0; i < 20; i++)
43 read(fd, data, sizeof(data));
44 close(fd);
45
46 wait();
47
48 exit();
49 }