int sysMonitorGetInfo(sys_mon_t *mid, sys_mon_info *info) { wait_info winfo; sysAssert(mid != SYS_MID_NULL); info->owner = mid->monitor_owner; if (mid->monitor_owner) { info->entry_count = mid->entry_count; } winfo.mid = mid; winfo.nwaiters = 0; winfo.waiters = info->monitor_waiters; winfo.sz = info->sz_monitor_waiters; sysThreadEnumerateOver(findWaitersHelper, (void *) &winfo); info->n_monitor_waiters = winfo.nwaiters; info->n_condvar_waiters = dumpWaitingQueue(&mid->mwait_queue, info->condvar_waiters, info->sz_condvar_waiters); return SYS_OK; }
/* * Wakes up each thread in active thread queue except for the calling * thread. The mechanism uses thread suspension, and will not wake a * thread that was already suspended. Must be matched 1-1 with calls * to sysThreadSingle(). Returns SYS_ERR if not all threads could be * woken up. */ void sysThreadMulti(void) { sysThreadEnumerateOver(threadMultiHelper, sysThreadSelf()); }
/* * Puts each thread in the active thread queue to sleep except for the * calling thread. The threads must be later woken up with a corresponding * call to 'sysThreadMulti'. Returns SYS_OK on success, or SYS_ERR if any * of the threads could not be suspended. */ int sysThreadSingle(void) { return sysThreadEnumerateOver(threadSingleHelper, sysThreadSelf()); }