void accept_mutex_off() { if (usunsetlock(uslock) == -1) { perror("usunsetlock"); exit(-1); } }
void qlock_unlock( qlockh_t qlockh ) { #ifdef HIDDEN qlock_t *qlockp = ( qlock_t * )qlockh; pid_t pid; ordmap_t *ordmapp; /* REFERENCED */ intgen_t rval; #endif /* sanity checks */ ASSERT( qlock_inited ); /* bypass if miniroot */ if ( ! qlock_usp ) { return; } #ifdef HIDDEN /* get the caller's pid */ pid = get_pid(); /* get the ordmap for this thread */ ordmapp = qlock_ordmapp_get( pid ); /* verify lock is held by this thread */ ASSERT( QLOCK_ORDMAP_GET( *ordmapp, qlockp->ql_ord )); ASSERT( qlockp->ql_owner == pid ); /* clear lock owner */ qlockp->ql_owner = 0; /* clear lock's ord from thread's ord map */ QLOCK_ORDMAP_CLR( *ordmapp, qlockp->ql_ord ); /* release the us lock */ rval = usunsetlock( qlockp->ql_uslockh ); ASSERT( ! rval ); #endif /* HIDDEN */ }
// 0 on success, -1 fail int vrpn_Semaphore::v() { #ifdef sgi if (fUsingLock) { if (usunsetlock(l)) { perror("vrpn_Semaphore::v: usunsetlock:"); return -1; } } else { if (usvsema(ps)) { perror("vrpn_Semaphore::v: uspsema:"); return -1; } } #elif defined(_WIN32) if (!ReleaseSemaphore(hSemaphore, 1, NULL)) { // get error info from windows (from FormatMessage help page) LPVOID lpMsgBuf; FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language (LPTSTR)&lpMsgBuf, 0, NULL); fprintf(stderr, "vrpn_Semaphore::v: error v'ing semaphore, " "WIN32 ReleaseSemaphore call caused the following error: %s", (LPTSTR)lpMsgBuf); // Free the buffer. LocalFree(lpMsgBuf); return -1; } #else // Posix by default if (sem_post(semaphore) != 0) { perror("vrpn_Semaphore::p: "); return -1; } #endif return 0; }