Unlock semaphore Arguments: None Returns: None

Return TypeFunction nameArguments
voidhzSysLock::Unlock(void)

Declared in file: hzProcess.h
Defined in file : hzLock.cpp

Function Logic:

0:START 1:tid 2:unknown 3: No text 4:unknown 5:items 6:unknown 7:items 8:items 9:unknown 10:items 11:unknown 12:m_lockval lockbuf - lockbuf lockbuf items 13:unknown 14:items 15: No text

Function body:

void hzSysLock::Unlock (void)
{
   //  Unlock semaphore
   //  
   //  Arguments: None
   //  Returns: None
   _hzfunc("hzSysLock::Unlock") ;
   sembuf  lockbuf ;   //  Semaphore operation buffer
   int32_t tid ;       //  Caller thread id
   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) ;
   }
}