1) A simple semaphore you can create with a global variable
2) CreateSemaphore details -
http://technology.niagarac.on.ca/courses/ctec1638/win32/CreateSemaphore.htm[
^]
3) Example (just sample flow)
MAX_USERS = 25;
HANDLE hSemaphore;
hSemaphore = CreateSemaphore(NULL, MAX_USERS,
MAX_USERS, "semkey");
..
WaitForSingleObject(hSemaphore, INFINITE);
...
ReleaseSemaphore(hSemaphore, 1);
...
4) you can use mutex in way too (OpenMutex) (note: Mutex is not semaphore)(A mutex is really a semaphore with value 1.)
(discouraged)
5) Check this for a implementation of semaphore code in unix
http://www.minek.com/files/unix_examples/semab.html
Hope this helps.