user/usertests.c
void
linkunlink()
{
  int pid, i;

  printf("linkunlink test\n");

  unlink("x");
  pid = fork();
  if(pid < 0){
    printf("fork failed\n");
    exit(1);
  }

  unsigned int x = (pid ? 1 : 97);
  for(i = 0; i < 100; i++){
    x = x * 1103515245 + 12345;
    if((x % 3) == 0){
      close(open("x", O_RDWR | O_CREATE));
    } else if((x % 3) == 1){
      link("cat", "x");
    } else {
      unlink("x");
    }
  }

  if(pid)
    wait(0);
  else
    exit(0);

  printf("linkunlink ok\n");
}
// another concurrent link/unlink/create test,
// to look for deadlocks.
another concurrent link/unlink/create test,
to look for deadlocks.
another concurrent link / unlink / create test to look for deadlocks .
void
linkunlink()
{
  int pid, i;
  printf("linkunlink test\n");
  unlink("x");
  pid = fork();
  if(pid < 0){
    printf("fork failed\n");
    exit(1);
  }
  unsigned int x = (pid ? 1 : 97);
  for(i = 0; i < 100; i++){
    x = x * 1103515245 + 12345;
    if((x % 3) == 0){
      close(open("x", O_RDWR | O_CREATE));
    } else if((x % 3) == 1){
      link("cat", "x");
    } else {
      unlink("x");
    }
  }
  if(pid)
    wait(0);
  else
    exit(0);
  printf("linkunlink ok\n");
}
void linkunlink ( ) { int pid , i ; printf ( " \n " ) ; unlink ( " " ) ; pid = fork ( ) ; if ( pid < 0 ) { printf ( " \n " ) ; exit ( 1 ) ; } unsigned int x = ( pid ? 1 : 97 ) ; for ( i = 0 ; i < 100 ; i ++ ) { x = x * 1103515245 + 12345 ; if ( ( x % 3 ) == 0 ) { close ( open ( " " , O_RDWR | O_CREATE ) ) ; } else if ( ( x % 3 ) == 1 ) { link ( " " , " " ) ; } else { unlink ( " " ) ; } } if ( pid ) wait ( 0 ) ; else exit ( 0 ) ; printf ( " \n " ) ; }
another concurrent link/unlink/create test,
to look for deadlocks.
another concurrent link / unlink / create test to look for deadlocks .