Of course you can !
But look, That depends on the exact operating system you´re using. I mean, you can do it anyway, but as you know the system calls are different (from Slackware version to Redhat version), so I can´t give you the exact system call you need. Basically, there are always system calls that disband or remove a specific semaphore from a set. So please - write down the OS and I´ll give you the code you need. Good luck ! Zack