#include "usg_common.h" #include "sem_util.h" static int mem_pool_cond = SemUtil::get(0x2001, 0); void *run(void *varg) { sleep(5); // notify malloc SemUtil::set(mem_pool_cond, 1); } int main() { pthread_t tid; pthread_create(&tid, NULL, run, NULL); SemUtil::set(mem_pool_cond, 0); // wait for someone else to free space printf("waiting...\n"); SemUtil::dec(mem_pool_cond); printf("weak...\n"); }