예제 #1
0
BOOL fnRemoveThreadCtx(long lTLSIndex)
{
        ThreadContext* tip = NULL;
        ThreadContext* prevt = NULL;

        if (g_tCtxSem)
        {
                #ifdef MPK_ON
                        kSemaphoreWait(g_tCtxSem);
                #else
                        WaitOnLocalSemaphore(g_tCtxSem);
                #endif	//MPK_ON
        }

        #ifdef MPK_ON
                lTLSIndex = labs(kCurrentThread());
        #else
                lTLSIndex = GetThreadID();
        #endif	//MPK_ON

        tip = g_ThreadCtx;
        while(tip) {
                if (tip->tid == lTLSIndex) {
                        if (prevt == NULL)
                                g_ThreadCtx = tip->next;
                        else
                                prevt->next = tip->next;

                        free(tip);
                        tip=NULL;
                        if (g_tCtxSem)
                        {
                                #ifdef MPK_ON
                                        kSemaphoreSignal(g_tCtxSem);
                                #else
                                        SignalLocalSemaphore(g_tCtxSem);
                                #endif	//MPK_ON
                        }
                        return TRUE;
                }
                prevt = tip;
                tip = tip->next;
        }

        if (g_tCtxSem)
        {
                #ifdef MPK_ON
                        kSemaphoreSignal(g_tCtxSem);
                #else
                        SignalLocalSemaphore(g_tCtxSem);
                #endif	//MPK_ON
        }

        return FALSE;       // entry not found
}
예제 #2
0
BOOL fnGetHashListAddrs(void **addrs, BOOL *dontTouchHashList)
{
        ThreadInfo*  tip;   
        int index,tid;   

        if (g_tinfoSem) 
        {
                #ifdef MPK_ON
                        kSemaphoreWait(g_tinfoSem);
                #else
                        WaitOnLocalSemaphore(g_tinfoSem);
                #endif	//MPK_ON
        }

        #ifdef MPK_ON
                tid=index = abs(kCurrentThread());
        #else
                tid=index = GetThreadID();
        #endif	//MPK_ON

        index = INDEXOF(index);     // just take the bottom five bits 

        // see if this is already in the table at the index'th offset
        //
        for (tip = g_ThreadInfo[index]; tip != NULL; tip = tip->next)
        {
                if (tip->tid == tid)
                {
                        if (g_tinfoSem)
                        {
                                #ifdef MPK_ON
                                        kSemaphoreSignal(g_tinfoSem);
                                #else
                                        SignalLocalSemaphore(g_tinfoSem);
                                #endif	//MPK_ON
                        }
                        *addrs = tip->m_allocList;
                        *dontTouchHashList = tip->m_dontTouchHashLists;
                        return TRUE;
                }
        }

        if (g_tinfoSem)
        {
                #ifdef MPK_ON
                        kSemaphoreSignal(g_tinfoSem);
                #else
                        SignalLocalSemaphore(g_tinfoSem);
                #endif	//MPK_ON
        }

        return FALSE;
}
예제 #3
0
BOOL fnRemoveThreadInfo(int tid)
{
        ThreadInfo* tip = NULL;
        ThreadInfo* prevt = NULL;
        int index = INDEXOF(tid);     // just take the bottom five bits

        if (g_tinfoSem)
        {
                #ifdef MPK_ON
                        kSemaphoreWait(g_tinfoSem);
                #else
                        WaitOnLocalSemaphore(g_tinfoSem);
                #endif	//MPK_ON
        }

        for (tip = g_ThreadInfo[index]; tip != NULL; tip = tip->next)
        {
                if (tip->tid == tid)
                {
                        if (prevt == NULL)
                                g_ThreadInfo[index] = tip->next;
                        else
                                prevt->next = tip->next;

                        free(tip);
                        tip=NULL;
                        if (g_tinfoSem)
                        {
                                #ifdef MPK_ON
                                        kSemaphoreSignal(g_tinfoSem);
                                #else
                                        SignalLocalSemaphore(g_tinfoSem);
                                #endif	//MPK_ON
                        }

                        return TRUE;
                }
                prevt = tip;
        }

        if (g_tinfoSem)
        {
                #ifdef MPK_ON
                        kSemaphoreSignal(g_tinfoSem);
                #else
                        SignalLocalSemaphore(g_tinfoSem);
                #endif	//MPK_ON
        }

        return FALSE;       // entry not found
}
void SynchronizeStart( void)
{
	if (gv_lFlmSyncSem)
	{
		(void)kSemaphoreSignal( gv_lFlmSyncSem);
	}
}
예제 #5
0
BOOL fnTerminateThreadInfo(void)
{
        int index = 0;

        if (g_tinfoSem)
        {
                #ifdef MPK_ON
                        kSemaphoreWait(g_tinfoSem);
                #else
                        WaitOnLocalSemaphore(g_tinfoSem);
                #endif	//MPK_ON
                for (index = 0; index < NUM_ENTRIES; index++)
                {
                        if (g_ThreadInfo[index] != NULL)
                        {
                                #ifdef MPK_ON
                                        kSemaphoreSignal(g_tinfoSem);
                                #else
                                        SignalLocalSemaphore(g_tinfoSem);
                                #endif	//MPK_ON
                                return FALSE;
                        }
                }
                #ifdef MPK_ON
                        kSemaphoreFree(g_tinfoSem);
                        g_tinfoSem = NULL;
                #else
                        CloseLocalSemaphore(g_tinfoSem);
                        g_tinfoSem = 0;
                #endif	//MPK_ON
        }

        return TRUE;
}
예제 #6
0
ThreadInfo* fnAddThreadInfo(int tid)
{
        ThreadInfo* tip = NULL;
        int index = 0;

        if (g_tinfoSem)
        {
                #ifdef MPK_ON
                        kSemaphoreWait(g_tinfoSem);
                #else
                        WaitOnLocalSemaphore(g_tinfoSem);
                #endif	//MPK_ON
        }

        // Add a new one to the beginning of the hash entry
        //
        tip = (ThreadInfo *) malloc(sizeof(ThreadInfo));
        if (tip == NULL)
        {  
                if (g_tinfoSem)
                {
                        #ifdef MPK_ON
                                kSemaphoreSignal(g_tinfoSem);
                        #else
                                SignalLocalSemaphore(g_tinfoSem);
                        #endif	//MPK_ON
                }
                return NULL;
        }
        index = INDEXOF(tid);     // just take the bottom five bits
        tip->next            =  g_ThreadInfo[index];
        tip->tid             =  tid;
        tip->m_dontTouchHashLists = FALSE;
        tip->m_allocList = NULL;

        g_ThreadInfo [index] =  tip;
        if (g_tinfoSem)
        {
                #ifdef MPK_ON
                        kSemaphoreSignal(g_tinfoSem);
                #else
                        SignalLocalSemaphore(g_tinfoSem);
                #endif	//MPK_ON
        }

        return tip;
}
예제 #7
0
void* fnGetThreadCtx(long lTLSIndex)
{
        ThreadContext*  tip;   

        if (g_tCtxSem) 
        {
                #ifdef MPK_ON
                        kSemaphoreWait(g_tCtxSem);
                #else
                        WaitOnLocalSemaphore(g_tCtxSem);
                #endif	//MPK_ON
        }

        #ifdef MPK_ON
                lTLSIndex = labs(kCurrentThread());
        #else
                lTLSIndex = GetThreadID();
        #endif	//MPK_ON

        tip = g_ThreadCtx;
        while(tip) {
                if (tip->tid == lTLSIndex) {
                        if (g_tCtxSem)
                        {
                                #ifdef MPK_ON
                                        kSemaphoreSignal(g_tCtxSem);
                                #else
                                        SignalLocalSemaphore(g_tCtxSem);
                                #endif	//MPK_ON
                        }
                        return (tip->tInfo);
                }
                tip=tip->next;
        }

        if (g_tCtxSem)
        {
                #ifdef MPK_ON
                        kSemaphoreSignal(g_tCtxSem);
                #else
                        SignalLocalSemaphore(g_tCtxSem);
                #endif	//MPK_ON
        }

        return NULL;
}
예제 #8
0
ThreadInfo* fnGetThreadInfo(int tid)
{
        ThreadInfo*  tip;   
        int index = INDEXOF(tid);     // just take the bottom five bits

        if (g_tinfoSem) {
                #ifdef MPK_ON
                        kSemaphoreWait(g_tinfoSem);
                #else
                        WaitOnLocalSemaphore(g_tinfoSem);
                #endif	//MPK_ON
        }

        // see if this is already in the table at the index'th offset
        //
        for (tip = g_ThreadInfo[index]; tip != NULL; tip = tip->next)
        {
                if (tip->tid == tid)
                {
                        if (g_tinfoSem)
                        {
                                #ifdef MPK_ON
                                        kSemaphoreSignal(g_tinfoSem);
                                #else
                                        SignalLocalSemaphore(g_tinfoSem);
                                #endif	//MPK_ON
                        }
                        return tip;
                }
        }

        if (g_tinfoSem)
        {
                #ifdef MPK_ON
                        kSemaphoreSignal(g_tinfoSem);
                #else
                        SignalLocalSemaphore(g_tinfoSem);
                #endif	//MPK_ON
        }

        return NULL;
}
예제 #9
0
void FLMAPI f_semSignal(
	F_SEM			hSem)
{
	(void)kSemaphoreSignal( (SEMAPHORE)hSem);
}
예제 #10
0
ThreadContext* fnAddThreadCtx(long lTLSIndex, void *t)
{
        ThreadContext* tip = NULL;
        ThreadContext* temp = NULL;

        if (g_tCtxSem)
        {
                #ifdef MPK_ON
                        kSemaphoreWait(g_tCtxSem);
                #else
                        WaitOnLocalSemaphore(g_tCtxSem);
                #endif	//MPK_ON
        }

        // add a new one to the beginning of the list
        //
        tip = (ThreadContext *) malloc(sizeof(ThreadContext));
        if (tip == NULL)
        {  
                if (g_tCtxSem)
                {
                        #ifdef MPK_ON
                                kSemaphoreSignal(g_tCtxSem);
                        #else
                                SignalLocalSemaphore(g_tCtxSem);
                        #endif	//MPK_ON
                }
                return NULL;
        }

        #ifdef MPK_ON
                lTLSIndex = labs(kCurrentThread());
        #else
                lTLSIndex = GetThreadID();
        #endif	//MPK_ON

        tip->next            =  NULL;
        tip->tid             =  lTLSIndex;
        tip->tInfo			 =  t;

        if(g_ThreadCtx==NULL) {
                g_ThreadCtx = tip;
        } else {
                int count=0;
                //Traverse to the end
                temp = g_ThreadCtx;
                while(temp->next != NULL)
                {
                        temp = temp->next;
                        count++;
                }
                temp->next = tip;
        }

        if (g_tCtxSem)
        {
                #ifdef MPK_ON
                        kSemaphoreSignal(g_tCtxSem);
                #else
                        SignalLocalSemaphore(g_tCtxSem);
                #endif	//MPK_ON
        }
        return tip;
}