Return Type | Function name | Arguments |
---|---|---|
void | hzSysLock::Unlock | (void) |
Declared in file: hzProcess.h
Defined in file : hzLock.cpp
Function Logic:
Function body:
void hzSysLock::Unlock (void) { _hzfunc("hzSysLock::Unlock") ; sembuf lockbuf ; int32_t tid ; tid = pthread_self() ; if (m_nSemId == -1) return ; if (!m_lockval) hzexit(E_CORRUPT, "Attempting to unlock a semaphore that is not locked by any thread") ; if (m_lockval != tid) hzexit(E_CORRUPT, "Attempting to unlock a semaphore that is locked by another thread (%u)", m_lockval) ; m_count-- ; if (m_count > 0) fprintf(stderr, "thread %u unwinding sema %d:%d\n", tid, m_nResource + 1,m_nSemId) ; if (m_count == 0) { m_lockval = 0; lockbuf.sem_num = m_nResource ; lockbuf.sem_op = -1; lockbuf.sem_flg = 0; fprintf(stderr, "thread %u releasing sema %d:%d\n", tid, m_nResource + 1,m_nSemId) ; if (semop(m_nSemId, &lockbuf, 1)== -1) hzerr(E_RELEASE, "Unlocked sema %d [%d]\n", m_nResource, m_nSemId) ; } }