Return TypeFunction nameArguments
voidhzSysLock::Unlock(void)

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

Function Logic:

0:START 1:pthread_self tid 2:m_nSemId==-1 3: No text 4:!m_lockval 5:hzexit 6:m_lockval!=tid 7:hzexit 8:items 9:m_count>0 10:fprintf 11:m_count==0 12:m_lockval lockbuf lockbuf lockbuf fprintf 13:semop(m_nSemId,&lockbuf,1)==-1 14: No text

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) ;
   }
}