Пример #1
0
/*******************************************************************************

	Task create/management/kill related functions.
	
 *******************************************************************************/
NDIS_STATUS ral_task_kill(
	IN KTHREAD *pTask)
{
	int ret = STATUS_FAILURE;
	RTBT_OS_TASK *pOSThread = (RTBT_OS_TASK *)pTask->pOSThread;
	
#ifdef KTHREAD_SUPPORT
	if (pOSThread->kthread_task) {
		kthread_stop(pOSThread->kthread_task);
		ret = STATUS_SUCCESS;
	}
#else
	if(IS_VALID_PID(pOSThread->taskPID)) {
		printk(KERN_WARNING "Terminate the task(%s) with pid(%d)!\n", 
					pOSThread->taskName, GET_PID_NUMBER(pOSThread->taskPID));
		
		mb();
		pOSThread->task_killed = 1;
		mb();
		ret = KILL_THREAD_PID(pOSThread->taskPID, SIGTERM, 1);
		if (ret){
			printk(KERN_WARNING "kill task(%s) with pid(%d) failed(retVal=%d)!\n", 
				pOSThread->taskName, GET_PID_NUMBER(pOSThread->taskPID), ret);
		} else {
			wait_for_completion(&pOSThread->taskComplete);
			pOSThread->taskPID = THREAD_PID_INIT_VALUE;
			pOSThread->task_killed = 0;
			ret = STATUS_SUCCESS;
		}
	}
#endif

	return ret;
	
}
Пример #2
0
static int usb_rtusb_close_device(
	IN	PRTMP_ADAPTER	pAd)
{
	int i = 0;
	int ret;
	
	DECLARE_WAIT_QUEUE_HEAD (unlink_wakeup); 
	DECLARE_WAITQUEUE (wait, current);

	DBGPRINT(RT_DEBUG_TRACE, "-->usb_rtusb_close_device \n");

	// ensure there are no more active urbs. 
	add_wait_queue (&unlink_wakeup, &wait);
	pAd->wait = &unlink_wakeup;

	// maybe wait for deletions to finish.
	while ((i < 25) && atomic_read(&pAd->PendingRx) > 0)
	{
#if LINUX_VERSION_CODE >KERNEL_VERSION(2,6,9)
		msleep(UNLINK_TIMEOUT_MS);
#endif
		i++;
	}

	pAd->wait = NULL;
	remove_wait_queue (&unlink_wakeup, &wait); 

	if (pAd->MLMEThr_pid >= 0) 
	{
		mlme_kill = 1;
		RTUSBMlmeUp(pAd);
		wmb(); // need to check
		ret = KILL_THREAD_PID (pAd->MLMEThr_pid, SIGTERM, 1);
		if (ret) 
		{
			printk (KERN_WARNING "%s: unable to Mlme thread \n", pAd->net_dev->name);
		}
		wait_for_completion (&pAd->MlmeThreadNotify);
		// reset mlme thread
		pAd->MLMEThr_pid = THREAD_PID_INIT_VALUE;
	}

	if (pAd->RTUSBCmdThr_pid>= 0) 
	{
		RTUSBCmd_kill = 1;
		RTUSBCMDUp(pAd);
		wmb(); // need to check
		ret = KILL_THREAD_PID (pAd->RTUSBCmdThr_pid, SIGTERM, 1);
		if (ret) 
		{
			printk (KERN_WARNING "%s: unable to RTUSBCmd thread \n", pAd->net_dev->name);
		}
		wait_for_completion (&pAd->CmdThreadNotify);
		// reset cmd thread
		pAd->RTUSBCmdThr_pid= THREAD_PID_INIT_VALUE;
	}

	RTUSBHalt(pAd, TRUE);
	RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_REMOVE_IN_PROGRESS);
	tasklet_kill(&pAd->rx_bh);



	DBGPRINT(RT_DEBUG_TRACE,"<--usb_rtusb_close_device \n");

	return 0;
}