Initializes a semaphore.
#include <synch.h> int sema_init ( sema_t *sp, unsigned int count, int type, void *arg );
(IN) Points to the semaphore to initialize.
(IN) Specifies the number of resources that the semaphore will protect and control.
(IN) Specifies the type of mutex with one of the following flags:
(IN) Reserved for future use. Set to NULL.
If successful, returns zero; otherwise, returns a nonzero error code:
Semaphores can be used to control access to a set of resources. Once initialized, the semaphore can be used any number of times without being reinitialized.
UI semaphores are not recursive. A thread can block itself if it attempts to reacquire a semaphore that it has already acquired.