taskc/sem_mutex/{sem_mutex_given.pseudo → sem_mutex.pseudo} RENAMED
@@ -1,13 +1,18 @@
1
  procedure main()
 
2
  shared count := 0
3
  create_thread(thread_a)
4
  create_thread(thread_b)
5
  end procedure
6
 
7
  procedure thread_a()
 
8
  count := count + 1
 
9
  end procedure
10
 
11
  procedure thread_b()
 
12
  count := count + 1
 
13
  end procedure
1
  procedure main()
2
+ shared can_access_count := create_semaphore(1)
3
  shared count := 0
4
  create_thread(thread_a)
5
  create_thread(thread_b)
6
  end procedure
7
 
8
  procedure thread_a()
9
+ wait(can_access_count)
10
  count := count + 1
11
+ signal(can_access_count)
12
  end procedure
13
 
14
  procedure thread_b()
15
+ wait(can_access_count)
16
  count := count + 1
17
+ signal(can_access_count)
18
  end procedure