The simplest concurrency pattern
- by Ilya Kogan
Please, would you help me in reminding me of one of the simplest parallel programming techniques.
How do I do the following in C#:
Initial state:
semaphore counter = 0
Thread 1:
// Block until semaphore is signalled
semaphore.Wait(); // wait until semaphore counter is 1
Thread 2:
// Allow thread 1 to run:
semaphore.Signal(); // increments from 0 to 1
It's not a mutex because there is no critical section, or rather you can say there is an infinite critical section. So what is it?