Semaphore with single key

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?

In reply to mayankmehta_83:

SystemVerilog describes a built-in counting semaphore class that can be extended into providing a binary semaphore or mutex class. It’s up to the class writer to define how the keys get allocated managed, as well as defining the protocol for how put()/get() are used.