Exemple #1
0
	void ThreadPool::Shutdown()
	{
		std::set<Thread*>::iterator itr;

		PoolMutex.Lock();
		for (itr = FreePool.begin(); itr != FreePool.end(); itr++) //Close the free pool threads.
		{
			DeleteThread(*itr);
		}

		for (itr = BusyPool.begin(); itr != BusyPool.end(); itr++) //Close the busy pool threads.
		{
			DeleteThread(*itr);
		}
		PoolMutex.UnLock();

		TaskCond.WakeAll();

		//Now we wait for all the threads to exit
		while (NumThreads > 0)
		{
			printf(TM_TEXT"Waiting for %i threads to exit...\n", NumThreads);
			WakeThreads();
			Sleep(0);
		}
		printf(TM_TEXT"Shutdown successful!\n");
	}
Exemple #2
0
NTSTATUS
BlkMovRemoveDevice(
    IN PDEVICE_OBJECT DeviceObject,
    IN PIRP Irp
    )
{
    NTSTATUS            status;
    PDEVICE_EXTENSION   deviceExtension;

    PAGED_CODE();

    deviceExtension = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension;

    status = BlkMovForwardIrpSynchronous(DeviceObject, Irp);

    IoDetachDevice(deviceExtension->TargetDeviceObject);
	DeleteThread(DeviceObject);
    IoDeleteDevice(DeviceObject);

    //
    // Complete the Irp
    //
    Irp->IoStatus.Status = status;
    IoCompleteRequest(Irp, IO_NO_INCREMENT);

    return status;
}
Exemple #3
0
int poweroffInit()
{
	int res;
	static int _init_count = -1;

	if(_init_count == _iop_reboot_count)
		return 0;
	_init_count = _iop_reboot_count;

	while(((res = SifBindRpc(&cd0, PWROFF_IRX, 0)) >= 0) && (cd0.server == NULL))
		nopdelay();

	ee_thread_t thread;
	ee_thread_status_t thisThread;

	ee_sema_t sema;

	// Terminate and delete any previously created threads
	if (powerOffThreadId >= 0) {
		TerminateThread(powerOffThreadId);
		DeleteThread(powerOffThreadId);
		powerOffThreadId = -1;
	}

	// Delete any previously created semaphores
	if (PowerOffSema >= 0)
	{
		DeleteSema(PowerOffSema);
		PowerOffSema = -1;
	}

	sema.init_count = 0;
	sema.max_count = 1;
	sema.option = 0;
	PowerOffSema = CreateSema(&sema);

	ReferThreadStatus(GetThreadId(), &thisThread);

	if (thisThread.current_priority == 0) {
		ChangeThreadPriority(GetThreadId(), 51);
		thread.initial_priority = 50;
	} else
		thread.initial_priority = thisThread.current_priority - 1;

	thread.stack_size = 512 * 16;
	thread.gp_reg = &_gp;
	thread.func = PowerOffThread;
	thread.stack = (void *)poffThreadStack;
	powerOffThreadId = CreateThread(&thread);
	StartThread(powerOffThreadId, NULL);
	
	DIntr();
	SifAddCmdHandler(POFF_SIF_CMD, _poff_intr_callback, NULL);
	EIntr();

	int autoShutdown = 0;
	SifCallRpc(&cd0, PWROFF_ENABLE_AUTO_SHUTOFF, 0, NULL, 0, &autoShutdown, sizeof(autoShutdown), 0, 0);
	
	return res;
}
Exemple #4
0
/*
 * ThreadFini
 * Called when every single thread ends
 * Delete the thread from BST
 */
VOID ThreadFini(THREADID threadIndex, const CONTEXT *ctxt, INT32 code, VOID *v)
{
	PIN_THREAD_UID threadid = PIN_ThreadUid();
	PIN_RWMutexWriteLock(&thread_lock);
	root_thread = DeleteThread(threadid, root_thread);
	PIN_RWMutexUnlock(&thread_lock);
}
Exemple #5
0
//Create a new thread.
sys_thread_t
sys_thread_new(void (*pFunction)(void* pvArg), void* pvArg, int iPrio)
{
	iop_thread_t thp;
	int tid, rv;

    thp.attr = TH_C;
    thp.option = 0;
    thp.thread = pFunction;
    thp.stacksize = 0x900; // why this magic number??
    thp.priority = iPrio + SYS_THREAD_PRIO_BASE;

	dbgprintf("sys_thread_new: Thread new (TID: %d)\n",GetThreadId());

	if((tid = CreateThread(&thp)) < 0)
    {
		dbgprintf("sys_thread_new: CreateThread failed, EC: %d\n", tid);
		return	-1;
	}

	if((rv = StartThread(tid, pvArg)) < 0)
	{
		dbgprintf("sys_thread_new: StartThread failed, EC: %d\n", rv);
	    DeleteThread(tid);
	    return(-1);
	}

	thread_count++;

	return((sys_thread_t) tid);
}
Exemple #6
0
// ɾ³ý
void CExplorerDlg::OnBnClickedButton1()
{
	int tabIndex = m_tab.GetCurSel(); 
	POSITION pos = m_pages[tabIndex]->m_list.GetFirstSelectedItemPosition();
	if (pos == NULL)
		return;
	int index = m_pages[tabIndex]->m_list.GetNextSelectedItem(pos);


	CString code;
	if (tabIndex == 0) // Ö÷Ìâ
	{
		ThreadInfo& thread = m_exploreThreadPage.m_threads[index];
		code = DeleteThread(thread.tid);
		if (code == _T("0"))
			g_deletedTID.insert(_ttoi64(thread.tid));
	}
	else if (tabIndex == 1) // Ìû×Ó
		code = DeletePost(m_explorePostPage.m_tid, m_explorePostPage.m_posts[index].pid);
	else // Â¥ÖÐÂ¥
		code = DeleteLZL(m_explorePostPage.m_tid, m_exploreLzlPage.m_lzls[index].pid);


	if (code != _T("0"))
		AfxMessageBox(_T("ɾ³ýʧ°Ü£¬´íÎó´úÂë" + code + _T("(") + GetTiebaErrorText(code) + _T(")")), MB_ICONERROR);
	else
		sndPlaySound(_T("ɾÌù.wav"), SND_ASYNC | SND_NODEFAULT);
}
Exemple #7
0
int poweroffInit(void)
{
	ee_thread_t thread;
	int res;
	static int _init_count = -1;

	if(_init_count == _iop_reboot_count)
		return 0;
	_init_count = _iop_reboot_count;

	while(((res = SifBindRpc(&cd0, PWROFF_IRX, 0)) >= 0) && (cd0.server == NULL))
		nopdelay();

	// Terminate and delete any previously created threads
	if (powerOffThreadId >= 0) {
		TerminateThread(powerOffThreadId);
		DeleteThread(powerOffThreadId);
		powerOffThreadId = -1;
	}

	thread.initial_priority = POWEROFF_THREAD_PRIORITY;
	thread.stack_size = sizeof(poffThreadStack);
	thread.gp_reg = &_gp;
	thread.func = PowerOffThread;
	thread.stack = (void *)poffThreadStack;
	thread.option = PWROFF_IRX;
	thread.attr = 0;
	powerOffThreadId = CreateThread(&thread);
	StartThread(powerOffThreadId, NULL);

	int autoShutdown = 0;
	SifCallRpc(&cd0, PWROFF_ENABLE_AUTO_SHUTOFF, 0, NULL, 0, &autoShutdown, sizeof(autoShutdown), NULL, NULL);

	return res;
}
	void SmtThreadPool::Run(SmtJob* pJob,void* pJobdata)
	{
		assert(pJob!=NULL); 
	
		if(GetBusyNum() == m_unMaxNum) 
			m_MaxNumCond.Wait(); 

		if(m_vIdleThreads.size()<m_unAvailIdleLow) 
		{ //负载过重
			if(GetAllNum()+m_unNormalIdleNum-m_vIdleThreads.size() < m_unMaxNum ) 
				CreateThread(m_unNormalIdleNum-m_vIdleThreads.size()); 
			else 
				CreateThread(m_unMaxNum-GetAllNum()); 
		}
		else if (m_vIdleThreads.size() > m_unAvailIdleHigh)
		{//负载过轻
			DeleteThread(m_vIdleThreads.size() - m_unNormalIdleNum); 
		}

		SmtWorkThread*  pIdleThread = GetIdleThread(); 

		if(pIdleThread !=NULL) 
		{ 
			pIdleThread->m_WorkCSLock.Lock(); 

			MoveToBusyList(pIdleThread); 

			pIdleThread->SetThreadPool(this); 

			pJob->SetWorkThread(pIdleThread); 
			pIdleThread->SetJob(pJob,pJobdata); 
		} 
	}
Exemple #9
0
/*! \brief Setup naplink compatible RPC handler.
 *  \ingroup fakehost 
 *
 *  \return Status.
 *
 *  return values:
 *    0 on success.
 *    -1 on error.
 */
int naplinkRpcInit(void)
{
    iop_thread_t th_attr;
    int ret;
    int pid;

    th_attr.attr = 0x02000000;
    th_attr.option = 0;
    th_attr.thread = napThread;
    th_attr.stacksize = 0x800;
    th_attr.priority = 0x4f;

    pid = CreateThread(&th_attr);
    if (pid < 0) {
        printf("IOP: napRpc createThread failed %d\n", pid);
        return -1;
    }

    ret = StartThread(pid, 0);
    if (ret < 0) {
        printf("IOP: napRpc startThread failed %d\n", ret);
        DeleteThread(pid);
        return -1;
    }
    return 0;
}
Exemple #10
0
void App::OnMeasure(wxCommandEvent& event)
{
	if(mMeasure)
	{
		DeleteThread();
		// stop measurement
		mMeasure = !mMeasure;
		
		if(mShowST)	// show sample time, if the option is enabled
				wxMessageBox(wxString::Format("The sample time [ms] is: %f",mDB.mMeasuredST),_("Sample Time"),wxOK|wxCENTER,this->GetTopWindow());
	}
	else
	{	// begin measurement
		//startThread;
		mDB.mlpThread = new Thread();
		if ( mDB.mlpThread->Run() == wxTHREAD_NO_ERROR )
		{
			mMeasure = !mMeasure;
		}
		else
		{
			wxMessageBox(_("Can't create a thread!"),_("Error"),wxOK|wxCENTER,this->GetTopWindow());
			delete mDB.mlpThread;
			mDB.mlpThread = nullptr;
		}
	}

}
Exemple #11
0
//Create a new thread.
sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread, void *arg, int stacksize, int prio)
{
	iop_thread_t thp;
	int tid, rv;

	thp.attr = TH_C;
	thp.option = 0;
	thp.thread = thread;
	thp.stacksize = stacksize;
	thp.priority = prio;

	dbgprintf("sys_thread_new: Thread new (TID: %d)\n", GetThreadId());

	if((tid = CreateThread(&thp)) < 0)
	{
		dbgprintf("sys_thread_new: CreateThread failed, EC: %d\n", tid);
		return ERR_MEM;
	}

	if((rv = StartThread(tid, arg)) < 0)
	{
		dbgprintf("sys_thread_new: StartThread failed, EC: %d\n", rv);
		DeleteThread(tid);
		return ERR_MEM;
	}

	return((sys_thread_t) tid);
}
Exemple #12
0
App::~App()
{
	DeleteThread();
	
	// write config file
	wxFileConfig::Write(wxT("max voltage"),mDB.mMaxVoltage);
	wxFileConfig::Write(wxT("steps"),mDB.mQuantaStep);
	wxFileConfig::Write(wxT("sample time"),mDB.mSampleTime);
	wxFileConfig::Write(wxT("show sample time"),mShowST);
}
Exemple #13
0
THREAD* DeleteThread(PIN_THREAD_UID threadid, THREAD*node)
{
	THREAD *temp;
	assert(node);
	if(threadid < node->tid)
	{
		node->left = DeleteThread(threadid, node->left);
	}
	else if(threadid > node->tid)
	{
		node->right = DeleteThread(threadid, node->right);
	}
	else
	{
		/* Now We can delete this node and replace with either minimum element
                   in the right sub tree or maximum element in the left subtree */
		while(node->stack != NULL)
			node->stack = DeleteAddress(node->stack, node->stack->address);
		if(node->right && node->left)
		{
			/* Here we will replace with minimum element in the right sub tree */
			temp = FindMinThread(node->right);
			node -> tid = temp->tid;
			node->stack = temp->stack;

			/* As we replaced it with some other node, we have to delete that node */
			node -> right = DeleteThread(temp->tid, node->right);
		}
		else
		{
			/* If there is only one or zero children then we can directly
                           remove it from the tree and connect its parent to its child */
			temp = node;
			if(node->left == NULL)
				node = node->right;
			else if(node->right == NULL)
				node = node->left;
			free(temp); /* temp is longer required */
		}
	}
	return node;
}
Exemple #14
0
void NetManDeinitRPCClient(void){
	WaitSema(NetManIOSemaID);

	SifCallRpc(&NETMAN_rpc_cd, NETMAN_IOP_RPC_FUNC_DEINIT, 0, NULL, 0, ReceiveBuffer, sizeof(struct NetManInitResult), NULL, NULL);
	TerminateThread(TxThreadID);
	DeleteThread(TxThreadID);
	DeleteSema(NetManIOSemaID);
	DeleteSema(NetManTxSemaID);

	IsInitialized=0;
}
Exemple #15
0
void
Model::SchedulingState::Clear()
{
	ThreadSchedulingState* state = fThreadStates.Clear(true);
	while (state != NULL) {
		ThreadSchedulingState* next = state->next;
		DeleteThread(state);
		state = next;
	}

	fLastEventTime = -1;
}
void Ps2SaveFileManager::quit(void) {
	_systemQuit = true;
	ee_thread_t statSave, statThis;
	ReferThreadStatus(GetThreadId(), &statThis);
	ChangeThreadPriority(_autoSaveTid, statThis.current_priority - 1);

	do {	// wait until thread called ExitThread()
		SignalSema(_autoSaveSignal);
		ReferThreadStatus(_autoSaveTid, &statSave);
	} while (statSave.status != 0x10);

	DeleteThread(_autoSaveTid);
    free(_autoSaveStack);
}
Exemple #17
0
wxThreadError wxThread::Kill()
{
    wxCHECK_MSG( This() != this, wxTHREAD_MISC_ERROR,
                 _T("a thread can't kill itself") );

    switch ( m_internal->GetState() )
    {
        case STATE_NEW:
        case STATE_EXITED:
            return wxTHREAD_NOT_RUNNING;

        case STATE_PAUSED:
            // resume the thread first
            Resume();

            // fall through

        default:
#ifdef HAVE_PTHREAD_CANCEL
            if ( pthread_cancel(m_internal->GetId()) != 0 )
#endif // HAVE_PTHREAD_CANCEL
            {
                wxLogError(_("Failed to terminate a thread."));

                return wxTHREAD_MISC_ERROR;
            }

#ifdef HAVE_PTHREAD_CANCEL
            if ( m_isDetached )
            {
                // if we use cleanup function, this will be done from
                // wxPthreadCleanup()
#ifndef wxHAVE_PTHREAD_CLEANUP
                ScheduleThreadForDeletion();

                // don't call OnExit() here, it can only be called in the
                // threads context and we're in the context of another thread

                DeleteThread(this);
#endif // wxHAVE_PTHREAD_CLEANUP
            }
            else
            {
                m_internal->SetExitCode(EXITCODE_CANCELLED);
            }

            return wxTHREAD_NO_ERROR;
#endif // HAVE_PTHREAD_CANCEL
    }
}
Exemple #18
0
int poweroffInit(void)
{
	ee_thread_t thread;
	ee_sema_t sema;
	int res;
	static int _init_count = -1;

	if(_init_count == _iop_reboot_count)
		return 0;
	_init_count = _iop_reboot_count;

	while(((res = SifBindRpc(&cd0, PWROFF_IRX, 0)) >= 0) && (cd0.server == NULL))
		nopdelay();

	// Terminate and delete any previously created threads
	if (powerOffThreadId >= 0) {
		TerminateThread(powerOffThreadId);
		DeleteThread(powerOffThreadId);
		powerOffThreadId = -1;
	}

	// Delete any previously created semaphores
	if (PowerOffSema >= 0)
	{
		DeleteSema(PowerOffSema);
		PowerOffSema = -1;
	}

	sema.init_count = 0;
	sema.max_count = 1;
	sema.option = 0;
	PowerOffSema = CreateSema(&sema);

	thread.initial_priority = POWEROFF_THREAD_PRIORITY;
	thread.stack_size = sizeof(poffThreadStack);
	thread.gp_reg = &_gp;
	thread.func = PowerOffThread;
	thread.stack = (void *)poffThreadStack;
	powerOffThreadId = CreateThread(&thread);
	StartThread(powerOffThreadId, NULL);

	DI();
	SifAddCmdHandler(POFF_SIF_CMD, _poff_intr_callback, NULL);
	EI();

	int autoShutdown = 0;
	SifCallRpc(&cd0, PWROFF_ENABLE_AUTO_SHUTOFF, 0, NULL, 0, &autoShutdown, sizeof(autoShutdown), NULL, NULL);

	return res;
}
Exemple #19
0
static void DeleteThreads(padState_t *state)
{
	DeleteThread(state->updatepadTid);
	DeleteThread(state->querypadTid);
	DeleteThread(state->setmainmodeTid);
	DeleteThread(state->setactalignTid);
	DeleteThread(state->setbuttoninfoTid);
	DeleteThread(state->setvrefparamTid);
}
Exemple #20
0
void iopException(int cause, int badvaddr, int status, int epc, u32 *regs, int repc, char* name)
{
    int i;
    int code;
    //    extern void printf(char *, ...);
    static void (* excpPrintf)(const char *, ...);

    FlushCache(0);
    FlushCache(2);

#if 1
    if (userThreadID) {
        TerminateThread(userThreadID);
        DeleteThread(userThreadID);
    }
#endif

    code = cause & 0x7c;

    if(excepscrdump)
    {
        init_scr();
        excpPrintf = scr_printf;
    }
	else excpPrintf = (void*)printf;
   
	excpPrintf("\n\n         IOP Exception handler: %s exception\n\n", 
               codeTxt[code>>2]);
		
	excpPrintf("               Module Name \"%s\" Relative EPC %08X\n\n",
               name, repc);


	excpPrintf("      Cause %08X  BadVAddr %08X  Status %08X  EPC %08X\n\n",
               cause, badvaddr, status, epc);

	for(i = 0; i < 32/4; i++) 
	{
		excpPrintf("       %4s: %08X %4s: %08X %4s: %08X %4s: %08X\n", 
					regName[i],  regs[i], regName[i+8], regs[i+8],
					regName[i+16],  regs[i+16], regName[i+24], regs[i+24]); 
	}
	
	excpPrintf("\n");
	

	
	SleepThread();
}
int ThreadDestroy(ThreadData* aThreadData,void* aThreadId)
	{
	int retval=0;
	HarnessThread threadId;
	if(aThreadData->iSelf != EThreadMain)
		{
		retval = KNoPermission;
		}
	else
		{
		threadId = (HarnessThread)(int) aThreadId;
		retval = DeleteThread(aThreadData,threadId);
		}
	return retval;
	}
Exemple #22
0
int audsrv_quit()
{
	WaitSema(completion_sema);

	SifCallRpc(&cd0, AUDSRV_QUIT, 0, sbuff, 1*4, sbuff, 4, NULL, NULL);
	set_error(AUDSRV_ERR_NOERROR);

	SifRemoveRpc(&cb_srv, &cb_queue);
	SifRemoveRpcQueue(&cb_queue);
	TerminateThread(rpc_server_thread_id);
	DeleteThread(rpc_server_thread_id);

	DeleteSema(completion_sema);
	return 0;
}
  void MdiEditor::thread_start(int index)
  {
	 DeleteThread(index);

	if(index>=0&&index<layer_num)
	{
		thread_flag[index]=0;
		if(gpu_flag)
		{
			match_thread_GPU[index] = new CMatchingThread_GPU(parameters[index],pyramids[index],index);
			connect(match_thread_GPU[index],SIGNAL(sigFinished(int)),this,SLOT(thread_finished(int)));
			connect(match_thread_GPU[index],SIGNAL(sigUpdate(int)),this,SLOT(SetResults(int)));
			match_thread_GPU[index]->start(QThread::HighestPriority);
		}
		else
		{
Exemple #24
0
BOOL
DeleteProcess(
    PPROCESS_INFO Process
    )
{
    PLIST_ENTRY Next, Head;
    PTHREAD_INFO Thread;
    PMODULE_INFO Module;
    CHAR Line[256];

    RemoveEntryList( &Process->Entry );

    Head = &Process->ThreadListHead;
    Next = Head->Flink;
    while (Next != Head) {
        Thread = CONTAINING_RECORD( Next, THREAD_INFO, Entry );
        Next = Next->Flink;
        DeleteThread( Process, Thread );
        }

    LocalFree( Process );
    fprintf(stdout,"\n");

    Next = ModuleListHead.Flink;
    while ( Next != &ModuleListHead ) {
        Module = CONTAINING_RECORD(Next,MODULE_INFO,Entry);


        sprintf(Line,"%16s Caused %6d faults had %6d Soft %6d Hard faulted VA's\n",
            Module->DebugInfo->ImageFileName,
            Module->NumberCausedFaults,
            Module->NumberFaultedSoftVas,
            Module->NumberFaultedHardVas
            );
        if ( !fLogOnly ) {
            fprintf(stdout,"%s",Line);
            }
        if ( LogFile ) {
            fprintf(LogFile,"%s",Line);
            }

        Next = Next->Flink;
        }


    return TRUE;
}
Exemple #25
0
int gsiStartThread(GSThreadFunc func,  gsi_u32 theStackSize, void *arg, GSIThreadID *id)
{
	const unsigned int stackSize = theStackSize;
	const int threadPriority = 3;
	struct ThreadParam param;
	void * stack;
	int threadID;

	// allocate a stack
	stack = gsimemalign(16, stackSize);
	if(!stack)
		return -1;

	// setup the thread parameters
	param.entry = func;
	param.stack = stack;
	param.stackSize = (int)stackSize;
	param.gpReg = &_gp;
	param.initPriority = threadPriority;

	// create the thread
	threadID = CreateThread(&param);
	if(threadID == -1)
	{
		gsifree(stack);
		return -1;
	}

	// start the thread
	if(StartThread(threadID, arg) == -1)
	{
		DeleteThread(threadID);
		gsifree(stack);
		return -1;
	}

	// store the id
	*id = threadID;

	// Note:  This was added to prevent PS2 lockups when starting multiple threads
	//        The PS2 would block for approx 5 seconds
	msleep(1);

	return 0;
}
Exemple #26
0
void gsiCancelThread(GSIThreadID id)
{
	void* aStack = NULL;

	// get the stack ptr
	struct ThreadParam aThreadParam;
	ReferThreadStatus(id, &aThreadParam);
	aStack = (void*)aThreadParam.stack;

	// terminate the thread
	TerminateThread(id);

	// delete the thread
	DeleteThread(id);

	//free the stack
	gsifree(aStack);
}
Exemple #27
0
void wxThread::Exit(ExitCode status)
{
    wxASSERT_MSG( This() == this,
                  _T("wxThread::Exit() can only be called in the context of the same thread") );

    if ( m_isDetached )
    {
        // from the moment we call OnExit(), the main program may terminate at
        // any moment, so mark this thread as being already in process of being
        // deleted or wxThreadModule::OnExit() will try to delete it again
        ScheduleThreadForDeletion();
    }

    // don't enter m_critsect before calling OnExit() because the user code
    // might deadlock if, for example, it signals a condition in OnExit() (a
    // common case) while the main thread calls any of functions entering
    // m_critsect on us (almost all of them do)
    OnExit();

    // delete C++ thread object if this is a detached thread - user is
    // responsible for doing this for joinable ones
    if ( m_isDetached )
    {
        // FIXME I'm feeling bad about it - what if another thread function is
        //       called (in another thread context) now? It will try to access
        //       half destroyed object which will probably result in something
        //       very bad - but we can't protect this by a crit section unless
        //       we make it a global object, but this would mean that we can
        //       only call one thread function at a time :-(
        DeleteThread(this);
        pthread_setspecific(gs_keySelf, 0);
    }
    else
    {
        m_critsect.Enter();
        m_internal->SetState(STATE_EXITED);
        m_critsect.Leave();
    }

    // terminate the thread (pthread_exit() never returns)
    pthread_exit(status);

    wxFAIL_MSG(_T("pthread_exit() failed"));
}
Exemple #28
0
//--------------------------------------------------------------------------------------------------
static void CleanupThread
(
    void* objPtr    ///< Pointer to the Thread object.
)
{
    ThreadObj_t* threadObjPtr = objPtr;

    // Call all destructors in the list.
    le_sls_Link_t* destructorLinkPtr = le_sls_Pop(&(threadObjPtr->destructorList));

    while (destructorLinkPtr != NULL)
    {
        // Get the destructor object
        DestructorObj_t* destructorObjPtr = CONTAINER_OF(destructorLinkPtr, DestructorObj_t, link);

        // Call the destructor.
        if (destructorObjPtr->destructor != NULL)
        {
            destructorObjPtr->destructor(destructorObjPtr->context);
        }

        // Free the destructor object.
        le_mem_Release(destructorObjPtr);

        destructorLinkPtr = le_sls_Pop(&(threadObjPtr->destructorList));
    }

    // Destruct the event loop.
    event_DestructThread();

    // If this thread is NOT joinable, then immediately invalidate its safe reference and free
    // the thread object.  Otherwise, wait until someone joins with it.
    if (! threadObjPtr->isJoinable)
    {
        Lock();

        le_ref_DeleteRef(ThreadRefMap, threadObjPtr->safeRef);

        Unlock();

        DeleteThread(threadObjPtr);
    }
}
Exemple #29
0
static void deinitCleanup(void)
{
	if(TxThreadID >= 0)
	{
		TerminateThread(TxThreadID);
		DeleteThread(TxThreadID);
		TxThreadID = -1;
	}
	if(NetManIOSemaID >= 0)
	{
		DeleteSema(NetManIOSemaID);
		NetManIOSemaID = -1;
	}
	if(NetManTxSemaID >= 0)
	{
		DeleteSema(NetManTxSemaID);
		NetManTxSemaID = -1;
	}
}
Exemple #30
0
/** called after a camera is accepted */
void PS2CamInitializeNewDevice(CAMERA_DEVICE *cam)
{
	unsigned char			*temp_str;
	UsbDeviceDescriptor		*d;


	PS2CamSetDeviceConfiguration(cam,1);

	camStopStream(cam);
	PS2CamSelectInterface(cam,0,0);
	camStartStream(cam);

	PS2CamSetDeviceDefaults(cam);

/*	camStopStream(dev);
	setReg16(dev, 0x30, 384);
	camStartStream(dev);
*/
	camStopStream(cam);
	PS2CamSelectInterface(cam,0,EYETOY_ALTERNATE_SIZE_384);
	camStartStream(cam);

	cam->status = CAM_STATUS_CONNECTEDREADY;



	// connected message (alloc som mem and get device string then print it and free the mem we alloced)
	d   = UsbGetDeviceStaticDescriptor(cam->device_id, NULL, USB_DT_DEVICE);
	temp_str = AllocSysMemory(0, 128, 0);
	temp_str[0]=0x00;
	PS2CamGetDeviceSring(cam, d->iProduct,      (char *)temp_str, 128);
	printf("cam initialized(%s)\n",temp_str);
	FreeSysMemory(temp_str);



	DeleteThread(maintain_thread);

	return;

}