#include <thread.h> int sema_init(sema_t *sp, unsigned int count, int type, void *arg);
type 可以是以下值之一:
多个线程决不能同时初始化同一个信号。不得对其他线程正在使用的信号重新初始化。
#include <thread.h> sema_t sp; int ret; int count; count = 4; /* to be used within this process only */ ret = sema_init(&sp, count, USYNC_THREAD, 0);
#include <thread.h> sema_t sp; int ret; int count; count = 4; /* to be used among all the processes */ ret = sema_init (&sp, count, USYNC_PROCESS, 0);