The “new” definition says:
semaphore smTx; smTx = new(1); //create the semaphore with 1 keys.
But if I create a semaphore as above, and 2 threads “put” a key back without any get, it ends up returning 2 keys to semaphore. This leads to following threads grab 2 keys. Why does the definition of “new” says “create semaphore with 1 key”, if “put” is going to allow more numbers of keys to be returned to it?
There is a concept of “binary” semaphore but not able to find syntax of declaring same in SV. Does SV support binary semaphores?