Last time, I was asked to solve a concurrency problem involving 100 similar processes constrained to fit into 5 buffers. (I'm talking about the Dining Savages problem.) I thought that it was alright to use a semaphore with value 5 (Semaphore x=5) for constraining the 100 proceses. As it turned out, the solution given uses a semaphore with value 1 and then an int was used to check whether the number of entries in the buffer is less than 5. Are there general pointers to remember when to use int x=5 instead of semaphore x=5?
(semaphore y=1; int x=5) vs (semaphore x=5)?
concurrency;synchronization