summaryrefslogtreecommitdiff
path: root/stressfs.c
blob: 43f312be4433221e8e36a09265dfa912b7feff8e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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();
}