resource CS()
  const int N = 20      # number of processes
  op mutex() {send}  # mutual exclusion for x
  send mutex()       # initialize mutex
  int x = 0         # shared variable
  process p [ i = 1 to N ] {
    # non-critical section
    # critical section
    receive mutex()  # enter critical section
    write(i," has CS")
    x = x+1
    send mutex()     # exit critical section
    # non-critical section
  }
end
