Skip to content

Race · 6 min

A deadlock is not a race

The assumption

A pipe program that hangs sometimes will work under some other schedule.

#include <unistd.h>
#include <sys/wait.h>

int main(void) {
  int fds[2];
  char big[100000];
  pipe(fds);

  pid_t pid = fork();
  if (pid == 0) {
    close(fds[0]);
    write(fds[1], big, 100000);
    _exit(0);
  }

  close(fds[1]);
  int status;
  waitpid(pid, &status, 0);
  return 0;
}

Not explored

Read the assumption first. Then find out whether the scheduler agrees with it.

Everything you do here stays in this browser.Part of liter8.sh