示例#1
0
文件: hub.c 项目: NieHao/Tomato-RAF
static int usb_hub_thread(void *startup)
{
    lock_kernel();

    /*
     * This thread doesn't need any user-level access,
     * so get rid of all our resources
     */

    daemonize();
    reparent_to_init();

    /* Block all signals */
    spin_lock_irq(&current->sigmask_lock);
    sigfillset(&current->blocked);
    recalc_sigpending(current);
    spin_unlock_irq(&current->sigmask_lock);

    /* Setup a nice name */
    strcpy(current->comm, "khubd");

    khubd_terminated = 0;
    complete((struct completion *)startup);

    /* Set khubd_terminated=1 to get me die */
    do {
        usb_hub_events();
        wait_event_interruptible(khubd_wait, !list_empty(&hub_event_list) || khubd_terminated);
    } while (!khubd_terminated || !list_empty(&hub_event_list));

    dbg("usb_hub_thread exiting");

    unlock_kernel();
    complete_and_exit(&khubd_exited, 0);
}
示例#2
0
文件: xio_server.c 项目: SUSE/accelio
/*---------------------------------------------------------------------------*/
static int xio_server_main(void *data)
{
	struct xio_server		*server;
	struct xio_context_params	ctx_params;

	init_xio_rdma_common_test();

	memset(&ctx_params, 0, sizeof(ctx_params));
	ctx_params.flags = XIO_LOOP_GIVEN_THREAD;
	ctx_params.worker = current;

	test_params.ctx = xio_context_create(&ctx_params, 0, 0);
	xio_assert(test_params.ctx);

	session_ops.on_session_event = on_session_event;
	server = xio_bind(test_params.ctx, &session_ops,
			  url, NULL, 0, NULL);
	xio_assert(server);
	pr_info("listen to %s\n", url);

	xio_context_run_loop(test_params.ctx);

	/* normal exit phase */
	pr_info("exit signaled\n");

	/* free the server */
	xio_unbind(server);
	xio_context_destroy(test_params.ctx);
	fini_xio_rdma_common_test();

	complete_and_exit(&cleanup_complete, 0);

	return 0;
}
示例#3
0
/****************************************************************************
 * Function (run in a thread) which changes the screen contents during a fixed
 * time period following module initialisation, then disappears.
 * Ideally we'd provide a way to kill this thread if the module gets unloaded
 * before it finishes its work...
 ****************************************************************************/
static int iGreetingFrameThread(void *arg)
{
  up(&start_thread_sem);
  set_current_state(TASK_INTERRUPTIBLE);
  schedule_timeout(banner_update_time_secs * HZ); /* sleep */
  vDrawGreetingFrame(2);
  complete_and_exit(&greeting_frame_complete, 0);
}
示例#4
0
static int mtd_blktrans_thread(void *arg)
{
    struct mtd_blktrans_ops *tr = arg;
    struct request_queue *rq = &tr->blkcore_priv->rq;

    /* we might get involved when memory gets low, so use PF_MEMALLOC */
    current->flags |= PF_MEMALLOC;

    daemonize("%sd", tr->name);

    /* daemonize() doesn't do this for us since some kernel threads
       actually want to deal with signals. We can't just call
       exit_sighand() since that'll cause an oops when we finally
       do exit. */
    spin_lock_irq(&current->sighand->siglock);
    sigfillset(&current->blocked);
    recalc_sigpending();
    spin_unlock_irq(&current->sighand->siglock);

    spin_lock_irq(rq->queue_lock);

    while (!tr->blkcore_priv->exiting) {
        struct request *req;
        struct mtd_blktrans_dev *dev;
        int res = 0;
        DECLARE_WAITQUEUE(wait, current);

        req = elv_next_request(rq);

        if (!req) {
            add_wait_queue(&tr->blkcore_priv->thread_wq, &wait);
            set_current_state(TASK_INTERRUPTIBLE);

            spin_unlock_irq(rq->queue_lock);

            schedule();
            remove_wait_queue(&tr->blkcore_priv->thread_wq, &wait);

            spin_lock_irq(rq->queue_lock);

            continue;
        }

        dev = req->rq_disk->private_data;
        tr = dev->tr;

        spin_unlock_irq(rq->queue_lock);

        down(&dev->sem);
        res = do_blktrans_request(tr, dev, req);
        up(&dev->sem);

        spin_lock_irq(rq->queue_lock);

        end_request(req, res);
    }
    complete_and_exit(&tr->blkcore_priv->thread_dead, 0);
}
示例#5
0
/*
========================================================================
Routine Description:
    MLME kernel thread.

Arguments:
	*Context			the pAd, driver control block pointer

Return Value:
    0					close the thread

Note:
========================================================================
*/
INT MlmeThread(
    IN ULONG Context)
{
    RTMP_ADAPTER *pAd;
    RTMP_OS_TASK *pTask;
    int status;
    status = 0;

    pTask = (RTMP_OS_TASK *)Context;
    pAd = (PRTMP_ADAPTER)pTask->priv;

    RtmpOSTaskCustomize(pTask);

    while(!pTask->task_killed)
    {
#ifdef KTHREAD_SUPPORT
        RTMP_WAIT_EVENT_INTERRUPTIBLE(pAd, pTask);
#else
        RTMP_SEM_EVENT_WAIT(&(pTask->taskSema), status);

        /* unlock the device pointers */
        if (status != 0)
        {
            RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS);
            break;
        }
#endif

        /* lock the device pointers , need to check if required*/
        //down(&(pAd->usbdev_semaphore));

        if (!pAd->PM_FlgSuspend)
            MlmeHandler(pAd);
    }

    /* notify the exit routine that we're actually exiting now
     *
     * complete()/wait_for_completion() is similar to up()/down(),
     * except that complete() is safe in the case where the structure
     * is getting deleted in a parallel mode of execution (i.e. just
     * after the down() -- that's necessary for the thread-shutdown
     * case.
     *
     * complete_and_exit() goes even further than this -- it is safe in
     * the case that the thread of the caller is going away (not just
     * the structure) -- this is necessary for the module-remove case.
     * This is important in preemption kernels, which transfer the flow
     * of execution immediately upon a complete().
     */
    DBGPRINT(RT_DEBUG_TRACE,( "<---%s\n",__FUNCTION__));
#ifndef KTHREAD_SUPPORT
    pTask->taskPID = THREAD_PID_INIT_VALUE;
    complete_and_exit (&pTask->taskComplete, 0);
#endif
    return 0;

}
示例#6
0
文件: spl-thread.c 项目: csiden/spl
void
__thread_exit(void)
{
	SENTRY;
	SEXIT;
	tsd_exit();
	complete_and_exit(NULL, 0);
	/* Unreachable */
}
示例#7
0
/* thread to serialize all requests, both sync and async */
static int async_task(void *param)
 {
    HIF_DEVICE *device;
    BUS_REQUEST *request;
    A_STATUS status;
    unsigned long flags;

    device = (HIF_DEVICE *)param;
    AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: async task\n"));
    set_current_state(TASK_INTERRUPTIBLE);
    while(!device->async_shutdown) {
        /* wait for work */
        if (down_interruptible(&device->sem_async) != 0) {
            /* interrupted, exit */
            AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: async task interrupted\n"));
            break;
        }
        if (device->async_shutdown) {
            AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: async task stopping\n"));
            break;
        }
        /* we want to hold the host over multiple cmds if possible, but holding the host blocks card interrupts */
        sdio_claim_host(device->func);
        spin_lock_irqsave(&device->asynclock, flags);
        /* pull the request to work on */
        while (device->asyncreq != NULL) {
            request = device->asyncreq;
            if (request->inusenext != NULL) {
                device->asyncreq = request->inusenext;
            } else {
                device->asyncreq = NULL;
            }
            spin_unlock_irqrestore(&device->asynclock, flags);
            /* call HIFReadWrite in sync mode to do the work */
            AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: async_task processing req: 0x%X\n", (unsigned int)request));
            status = __HIFReadWrite(device, request->address, request->buffer,
                                  request->length, request->request & ~HIF_SYNCHRONOUS, NULL);
            if (request->request & HIF_ASYNCHRONOUS) {
                AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: async_task completion routine req: 0x%X\n", (unsigned int)request));
                device->htcCallbacks.rwCompletionHandler(request->context, status);
                AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: async_task freeing req: 0x%X\n", (unsigned int)request));
                hifFreeBusRequest(device, request);
            } else {
                AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: async_task upping req: 0x%X\n", (unsigned int)request));
                request->status = status;
                up(&request->sem_req);
            }
            spin_lock_irqsave(&device->asynclock, flags);
        }
        spin_unlock_irqrestore(&device->asynclock, flags);
        sdio_release_host(device->func);
    }

    complete_and_exit(&device->async_completion, 0);
    return 0;
 }
示例#8
0
INT ral_task_notify_exit(
	IN KTHREAD *pTask)
{
	RTBT_OS_TASK *pOSThread = (RTBT_OS_TASK *)pTask->pOSThread;
	
#ifndef KTHREAD_SUPPORT
	complete_and_exit(&pOSThread->taskComplete, 0);
#endif
	
	return 0;
}
示例#9
0
int exemple_thread(void * arg)
{
	complete(& exemple_started);

	while (! exemple_stop) {
		printk(KERN_INFO "%s - %s(): Thread running, jiffies = %lu\n",
		                 THIS_MODULE->name, __FUNCTION__, jiffies);
		ssleep(1);
	}
	complete_and_exit(& exemple_stopped, 0);
}
示例#10
0
static int dump_thread(void *data)
{
	struct rtc_device *rtc;
	struct rtc_time tm;
	int err = 0;
	char log_file_name[100];
	char backup_log_file_name[100];

	pr_at_info("%s: Enter into dump_thread\n", __func__);

	/* Dump the last kernel log */
	/* MX have two rtc devices */
	rtc = rtc_class_open("rtc0");
	if (rtc == NULL) {
		rtc = rtc_class_open("rtc1");
		if (rtc == NULL) {
			pr_err(ATP "%s: can not open rtc devices\n", __func__);
			err = -ENODEV;
		}
	}
	if (!err) {
		err = rtc_read_time(rtc, &tm);
		if (err)
			pr_err(ATP "%s: unable to read the hardware clock\n", __func__);
	}

	sprintf(log_file_name, "%s-%d%02d%02d_%02d%02d%02d", CONFIG_LAST_KMSG_LOG_FILE,
		tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
		tm.tm_hour + 8, tm.tm_min, tm.tm_sec);
	pr_at_info("%s: Get log file name: %s\n", __func__, log_file_name);
	err = dump_last_kmsg(log_file_name);
	if (err) {
		pr_err(ATP "%s: Failed dump kernel log to %s\n", __func__, log_file_name);
		sprintf(backup_log_file_name, "%s-%d%02d%02d_%02d%02d%02d", CONFIG_BACKUP_LAST_KMSG_LOG_FILE,
			tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
			tm.tm_hour + 8, tm.tm_min, tm.tm_sec);
		pr_at_info("%s: Get backup log file name: %s\n", __func__, backup_log_file_name);
		err = dump_last_kmsg(backup_log_file_name);
		if (err) {
			pr_err(ATP "%s: Failed dump kernel log to %s\n", __func__, backup_log_file_name);
			goto out;
		} else {
			pr_at_info("%s: kernel log file dumped to %s\n", __func__, backup_log_file_name);
		}
	} else {
		pr_at_info("%s: kernel log file dumped to %s\n", __func__, log_file_name);
	}

out:
	complete_and_exit(&dump, 0);

	return err;
}
示例#11
0
文件: spl-debug.c 项目: Kream/spl
static int
spl_debug_dumplog_thread(void *arg)
{
	dumplog_priv_t *dp = (dumplog_priv_t *)arg;

        spl_debug_dumplog_internal(dp);
	atomic_set(&dp->dp_done, 1);
        wake_up(&dp->dp_waitq);
	complete_and_exit(NULL, 0);

        return 0; /* Unreachable */
}
示例#12
0
/** This handler is invoked when the sig_unused hook finds a non-NULL entry
 * in the clondike record in the task_struct */
void guest_mig_mode_handler(void)
{
	struct tcmi_task *tmp, *task;
	int res;
	long exit_code;

	minfo(INFO1, "Migration mode handler for task '%s' executing", 
	      current->comm);


	if (!(task = tcmi_taskhelper_sanity_check())) {
		minfo(ERR3, "Stub - invalid entry to migration mode - kernel task %p, PID=%d",
		      current, current->pid);
		goto exit0;
	}

	/* keep moving the task between migration managers */
	while ((res = tcmi_task_process_methods(task)) ==
	       TCMI_TASK_MOVE_ME);
	/* check the result of the last method processed */
	switch (res) {
	case TCMI_TASK_KEEP_PUMPING:
		minfo(INFO1, "KEEP PUMPING - but no methods left %d", res);
		break;
	case TCMI_TASK_LET_ME_GO:
		minfo(INFO1, "LET ME GO - request %d", res);
		break;
		/* no need for special handling a fall through causes
		 * do_exit which sends a message to the shadow */
	case TCMI_TASK_EXECVE_FAILED_KILL_ME:
		minfo(INFO1, "EXECVE_FAILED KILL ME - request %d", res);
		break;
	case TCMI_TASK_KILL_ME:
		minfo(INFO1, "KILL ME - request %d", res);
		tmp = tcmi_taskhelper_detach();
		/* get the exit code prior terminating. */
		exit_code = tcmi_task_exit_code(tmp);
		tcmi_task_put(tmp);
		complete_and_exit(NULL, exit_code);
		break;
	case TCMI_TASK_REMOVE_AND_LET_ME_GO:
		minfo(INFO1, "REMOVE AND LET ME GO - request %d", res);
		tcmi_task_put(tcmi_taskhelper_detach());
		break;
	default:
		minfo(ERR1, "Unexpected result %d.", res);
		break;
	}
	/* error handling */
 exit0:
	return;
}
示例#13
0
INT RTUSBCmdThread(
    IN void * Context)
{
	PRTMP_ADAPTER	pAd = (PRTMP_ADAPTER)Context;

//2007/12/11:KH modified to fix compiled failed
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
	daemonize();
#else
	daemonize("rt73");
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
	allow_signal(SIGTERM);
#endif
	current->flags |= PF_NOFREEZE;
	/* signal that we've started the thread */
	complete(&(pAd->CmdThreadNotify));

	while (1)	
	{		
		int status;				
		status = down_interruptible(&(pAd->RTUSBCmd_semaphore));		
		if (status != 0)			
			continue;				

		if (RTUSBCmd_kill)
			break;
		pAd->CmdHandlerIsRunning=TRUE;
		CMDHandler(pAd);	
		pAd->CmdHandlerIsRunning=FALSE;
	}

	/* notify the exit routine that we're actually exiting now 
	 *
	 * complete()/wait_for_completion() is similar to up()/down(),
	 * except that complete() is safe in the case where the structure
	 * is getting deleted in a parallel mode of execution (i.e. just
	 * after the down() -- that's necessary for the thread-shutdown
	 * case.
	 *
	 * complete_and_exit() goes even further than this -- it is safe in
	 * the case that the thread of the caller is going away (not just
	 * the structure) -- this is necessary for the module-remove case.
	 * This is important in preemption kernels, which transfer the flow
	 * of execution immediately upon a complete().
	 */
	complete_and_exit (&pAd->CmdThreadNotify, 0);
	DBGPRINT(RT_DEBUG_TRACE, "<---RTUSBCmdThread\n");

}
/*
 * bcm63xx_timer: 100ms timer for updating rx rate control credits
 */
static void bcm63xx_timer(unsigned long arg)
{
    BcmEnet_devctrl *priv;
    BcmEnet_RxDma *rxdma;
    unsigned int elapsed_msecs;
    int i;
    struct sched_param param;

    daemonize("bcmsw_timer");
    param.sched_priority = BCM_RTPRIO_DATA;
    sched_setscheduler(current, SCHED_RR, &param);
    set_user_nice(current, 0);

    while (atomic_read(&timer_lock) > 0)
    {
        for (i = 0; i < iface_cnt; i++) {
            ENET_RX_LOCK();
            priv = (BcmEnet_devctrl *)netdev_priv(vnet_dev[i]);
            if (rxchannel_rate_limit_enable[i]) {
                elapsed_msecs = jiffies_to_msecs(jiffies -
                        last_pkt_jiffies[i]);
                if (elapsed_msecs >= 99) {
                    rxdma = priv->rxdma[0];
                    BCM_ENET_DEBUG("pkts_from_last_jiffies = %d \n",
                            rx_pkts_from_last_jiffies[i]);
                    rx_pkts_from_last_jiffies[i] = 0;
                    last_pkt_jiffies[i] = jiffies;
                    if (rxchannel_isr_enable[i] == 0) {
                        BCM_ENET_DEBUG("Enabling DMA Channel & Interrupt \n");
                        /* Disable this. Should be implemented differently in
                         * impl6
                        switch_rx_ring(priv, 0, 0);
                        */
                        bcmPktDma_BcmHalInterruptEnable(i, rxdma->rxIrq);
                        rxchannel_isr_enable[i] = 1;
                    }
                }
            }
            ENET_RX_UNLOCK();
        }

        /*  Sleep for HZ/10 jiffies (100ms)  */
        set_current_state(TASK_INTERRUPTIBLE);
        schedule_timeout(HZ/10);
    }

    complete_and_exit(&timer_done, 0);
    printk("bcm63xx_timer: thread exits!\n");
}
示例#15
0
static void rsi_coex_scheduler_thread(struct rsi_common *common)
{
	struct rsi_coex_ctrl_block *coex_cb =
		(struct rsi_coex_ctrl_block *)common->coex_cb;
	u32 timeout = EVENT_WAIT_FOREVER;

	do {
		rsi_wait_event(&coex_cb->coex_tx_thread.event, timeout);
		rsi_reset_event(&coex_cb->coex_tx_thread.event);

		rsi_coex_sched_tx_pkts(coex_cb);
	} while (atomic_read(&coex_cb->coex_tx_thread.thread_done) == 0);

	complete_and_exit(&coex_cb->coex_tx_thread.completion, 0);
}
示例#16
0
static int thread_write(void *write_data)
{
	private_data *data = (private_data *) write_data;

	if (genstack_full(&stack))	// For debug added
	{
		pr_debug("Producer is going to sleep...\n");
		if (wait_event_interruptible(wq_write, !genstack_full(&stack)))
			return -ERESTART;
	}

	genstack_push(&stack, &data->write_data->user);

	complete_and_exit(&data->on_exit, 0);
}
示例#17
0
static int
dhd_probe_thread(void *data)
{
	probe_info_t *pinfo = (probe_info_t *) data;

	DAEMONIZE("dbus_probe_thread");

	if (probe_cb) {
		if (down_interruptible(&pinfo->sem) == 0)
			disc_arg = probe_cb(probe_arg, "", 0, 0);
	}

	pinfo->dpc_pid = -1;
	complete_and_exit(&pinfo->dpc_exited, 0);
}
static int ovc_scan_thread(void *data)
{
	struct ovc *ovcinfo = NULL;
	int state;

	if (!u_notify) {
		pr_err("%s u_notify is NULL\n", __func__);
		return 0;
	}

	ovcinfo = &u_notify->ovc_info;
	while (!kthread_should_stop()) {
		wait_event_interruptible_timeout(ovcinfo->delay_wait,
			ovcinfo->thread_remove, (ovcinfo->poll_period)*HZ);
		if (ovcinfo->thread_remove)
			break;
		mutex_lock(&u_notify->ovc_info.ovc_lock);
		if (ovcinfo->check_state
			&& ovcinfo->data
				&& ovcinfo->can_ovc) {

			state = ovcinfo->check_state(data);

			if (ovcinfo->prev_state != state) {
				if (state == HNOTIFY_LOW) {
					pr_err("%s overcurrent detected\n",
							__func__);
					host_state_notify(&u_notify->ndev,
						NOTIFY_HOST_OVERCURRENT);
				} else if (state == HNOTIFY_HIGH) {
					pr_info("%s vbus draw detected\n",
							__func__);
					host_state_notify(&u_notify->ndev,
						NOTIFY_HOST_NONE);
				}
			}
			ovcinfo->prev_state = state;
		}
		mutex_unlock(&u_notify->ovc_info.ovc_lock);
		if (!ovcinfo->can_ovc)
			ovcinfo->thread_remove = 1;
	}

	pr_info("ovc_scan_thread exit\n");
	complete_and_exit(&ovcinfo->scanning_done, 0);
	return 0;
}
示例#19
0
文件: rtsx.c 项目: Neves4/DatKernel
static int rtsx_polling_thread(void *__dev)
{
	struct rtsx_dev *dev = (struct rtsx_dev *)__dev;
	struct rtsx_chip *chip = dev->chip;
	struct Scsi_Host *host = rtsx_to_host(dev);
	struct sd_info *sd_card = &(chip->sd_card);
	struct xd_info *xd_card = &(chip->xd_card);
	struct ms_info *ms_card = &(chip->ms_card);

	sd_card->cleanup_counter = 0;
	xd_card->cleanup_counter = 0;
	ms_card->cleanup_counter = 0;

	/* Wait until SCSI scan finished */
	wait_timeout((delay_use + 5) * 1000);

	for (;;) {

		set_current_state(TASK_INTERRUPTIBLE);
		schedule_timeout(POLLING_INTERVAL);

		/* lock the device pointers */
		mutex_lock(&(dev->dev_mutex));

		/* if the device has disconnected, we are free to exit */
		if (rtsx_chk_stat(chip, RTSX_STAT_DISCONNECT)) {
			printk(KERN_INFO "-- rtsx-polling exiting\n");
			mutex_unlock(&dev->dev_mutex);
			break;
		}

		mutex_unlock(&dev->dev_mutex);

		mspro_polling_format_status(chip);

		/* lock the device pointers */
		mutex_lock(&(dev->dev_mutex));

		rtsx_polling_func(chip);

		/* unlock the device pointers */
		mutex_unlock(&dev->dev_mutex);
	}

	scsi_host_put(host);
	complete_and_exit(&threads_gone, 0);
}
示例#20
0
文件: moduledebug.c 项目: yanchao/WTS
static void moduleTestLoop ( void ) {
    int localCount = 0;

    while (1) {
        putABreakPointHere();
        /* Waits 1 sec */
        sleep_on_timeout(&wait,500);
        PRINTF("moduleTest thread woke up. Global is %s !\n", globalData);
        localCount++;
        count += 2;

        if (moduleTestExiting) {
            PRINTF("localCount = %d; count = %d; moduleTest thread exiting!\n", localCount, count);
            complete_and_exit(&evt_dead,0);
        }
    }
}
示例#21
0
static int
dbus_txq_thread(void *data)
{
	sdos_info_t *sdos_info = (sdos_info_t *)data;

	DAEMONIZE("dbus_sdio_txq");

	/* Run until signal received */
	while (1) {
		if (down_interruptible(&sdos_info->txq_sem) == 0)
			dbus_sdio_txq_process(sdos_info->cbarg);
		else
			break;
	}

	complete_and_exit(&sdos_info->txq_exited, 0);
}
/**
 * wlan_logging_thread() - The WLAN Logger thread
 * @Arg - pointer to the HDD context
 *
 * This thread logs log message to App registered for the logs.
 */
static int wlan_logging_thread(void *Arg)
{
	int ret_wait_status = 0;
	int ret = 0;

	set_user_nice(current, -2);

#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 8, 0))
	daemonize("wlan_logging_thread");
#endif

	while (!gwlan_logging.exit) {
		ret_wait_status = wait_event_interruptible(
		    gwlan_logging.wait_queue,
		    (gwlan_logging.wakeEvent || gwlan_logging.exit));

		gwlan_logging.wakeEvent = FALSE;

		if (ret_wait_status == -ERESTARTSYS) {
			pr_err("%s: wait_event_interruptible returned -ERESTARTSYS",
				__func__);
			break;
		}

		if (gwlan_logging.exit) {
		    pr_err("%s: Exiting the thread\n", __func__);
		    break;
		}

		if (INVALID_PID == gapp_pid) {
		    pr_err("%s: Invalid PID\n", __func__);
		    continue;
		}

		ret = send_filled_buffers_to_user();
		if (-ENOMEM == ret) {
		    msleep(200);
		}
	}

	pr_info("%s: Terminating\n", __func__);

	complete_and_exit(&gwlan_logging.shutdown_comp, 0);

	return 0;
}
示例#23
0
static int mmc_queue_thread(void *d)
{
	struct mmc_queue *mq = d;
	struct request_queue *q = mq->queue;
	DECLARE_WAITQUEUE(wait, current);

	/*
	 * Set iothread to ensure that we aren't put to sleep by
	 * the process freezing.  We handle suspension ourselves.
	 */
	current->flags |= PF_MEMALLOC|PF_NOFREEZE;

	daemonize("mmcqd");

	complete(&mq->thread_complete);

	down(&mq->thread_sem);
	add_wait_queue(&mq->thread_wq, &wait);
	do {
		struct request *req = NULL;

		spin_lock_irq(q->queue_lock);
		set_current_state(TASK_INTERRUPTIBLE);
		if (!blk_queue_plugged(q))
			mq->req = req = elv_next_request(q);
		spin_unlock(q->queue_lock);

		if (!req) {
			if (mq->flags & MMC_QUEUE_EXIT)
				break;
			up(&mq->thread_sem);
			schedule();
			down(&mq->thread_sem);
			continue;
		}
		set_current_state(TASK_RUNNING);

		mq->issue_fn(mq, req);
	} while (1);
	remove_wait_queue(&mq->thread_wq, &wait);
	up(&mq->thread_sem);

	complete_and_exit(&mq->thread_complete, 0);
	return 0;
}
示例#24
0
static int thread_code( void *data )
{
    unsigned long timeout;

    allow_signal( SIGTERM ); 
    while(!signal_pending(current)) {
        timeout= 2 * HZ; // wait 1 second
        timeout=wait_event_interruptible_timeout(
            wq, (timeout==0), timeout);
        printk("thread_code: woke up after 2 secs ...\n");
        if( timeout==-ERESTARTSYS ) {
            printk("got signal, break\n");
            break;
        }
    }
    thread_id = 0;
    complete_and_exit( &on_exit, 0 );
}
示例#25
0
static int lock_thread(void *null)
{
	int cpu;
	sprintf(current->comm, "RTAI_LOCK");
	current->nice = -20;
	cpu = -1;
	do {
		if (cpu != rtai_cpu) {
			current->cpus_allowed = 1 << (cpu = rtai_cpu);
			while (rtai_cpu != hard_cpu_id()) {
		        	current->state = TASK_INTERRUPTIBLE;
	        		schedule_timeout(2);
			}
		}
	} while (!signal_pending(current));
	return 0;
	complete_and_exit(&lock_thread_exited, 0);
}
示例#26
0
文件: rtsx.c 项目: AlexShiLucky/linux
static int rtsx_polling_thread(void *__dev)
{
	struct rtsx_dev *dev = __dev;
	struct rtsx_chip *chip = dev->chip;
	struct sd_info *sd_card = &chip->sd_card;
	struct xd_info *xd_card = &chip->xd_card;
	struct ms_info *ms_card = &chip->ms_card;

	sd_card->cleanup_counter = 0;
	xd_card->cleanup_counter = 0;
	ms_card->cleanup_counter = 0;

	/* Wait until SCSI scan finished */
	wait_timeout((delay_use + 5) * 1000);

	for (;;) {
		set_current_state(TASK_INTERRUPTIBLE);
		schedule_timeout(msecs_to_jiffies(POLLING_INTERVAL));

		/* lock the device pointers */
		mutex_lock(&dev->dev_mutex);

		/* if the device has disconnected, we are free to exit */
		if (rtsx_chk_stat(chip, RTSX_STAT_DISCONNECT)) {
			dev_info(&dev->pci->dev, "-- rtsx-polling exiting\n");
			mutex_unlock(&dev->dev_mutex);
			break;
		}

		mutex_unlock(&dev->dev_mutex);

		mspro_polling_format_status(chip);

		/* lock the device pointers */
		mutex_lock(&dev->dev_mutex);

		rtsx_polling_func(chip);

		/* unlock the device pointers */
		mutex_unlock(&dev->dev_mutex);
	}

	complete_and_exit(&dev->polling_exit, 0);
}
示例#27
0
static int rtsx_polling_thread(void * __dev)
{
	struct rtsx_dev *dev = (struct rtsx_dev *)__dev;
	struct rtsx_chip *chip = dev->chip;
	struct Scsi_Host *host = rtsx_to_host(dev);
	struct sd_info *sd_card = &(chip->sd_card);
	struct xd_info *xd_card = &(chip->xd_card);
	struct ms_info *ms_card = &(chip->ms_card);
	
	sd_card->cleanup_counter = 0;
	xd_card->cleanup_counter = 0;
	ms_card->cleanup_counter = 0;

	wait_timeout((delay_use + 5) * 1000);

	for(;;) {
		wait_timeout(POLLING_INTERVAL);

		
		mutex_lock(&(dev->dev_mutex));

		
		if (rtsx_chk_stat(chip, RTSX_STAT_DISCONNECT)) {
			printk(KERN_INFO "-- rtsx-polling exiting\n");
			mutex_unlock(&dev->dev_mutex);
			break;
		}
		
		mutex_unlock(&dev->dev_mutex);		

		mspro_polling_format_status(chip);
		
		
		mutex_lock(&(dev->dev_mutex));

		rtsx_polling_func(chip);

		
		mutex_unlock(&dev->dev_mutex);
	}

	scsi_host_put(host);
	complete_and_exit(&threads_gone, 0);
}
示例#28
0
static int test_thread(void *x)
{
    reparent_to_init();

        /* Setup a nice name */
        strcpy(current->comm, "testd_usb");

    usbprintk("Thread started\n");

    test_usb_init();

    do {        
        test_usb_events();
        my_wait_ms(50);
    } while (!signal_pending(current));

    usbprintk("hub_thread exiting\n");
    complete_and_exit(&testd_exited, 0);    
}
示例#29
0
文件: mod_test.c 项目: yanchao/WTS
static void mod_thread ( int i ) 
{
    int dfe_local = 0;
    int th_id = (int *)i; 
    int seconds = (th_id + 1) * 1000; 
    char dfe_str[14];
    unsigned int new_core_id = raw_smp_processor_id();
    unsigned int old_core_id = new_core_id;

    sprintf(dfe_str,"dfe_%d_alive",(int *)i);

    daemonize(dfe_str);

    while (1) {
        mid_stack1();
        /* Waits 1 sec */
        sleep_on_timeout(&wait,seconds);

        /*-----------------------------------------------------------------------------
         *  add thread transfer code
         *  first ,update new_core_id
         *-----------------------------------------------------------------------------*/
        new_core_id = raw_smp_processor_id();
        if (new_core_id != old_core_id) {
            PRINTF ("kernel thread %ld is transfered from core %d to core %d.\n", th_id, old_core_id, new_core_id);
        }
        /*  update old_core_id to new one */
        old_core_id = new_core_id;

        PRINTF("kernel thread %d  woke up on core %d . thread id is %d !\n", th_id,raw_smp_processor_id(),pid[th_id]); 
        dfe_local++;
        atomic_add(2,&dfe_count);

        if (dfe_gone) {
            PRINTF("dfe_local = %d; dfe_count = %d; module thread exiting!\n", dfe_local,atomic_read(&dfe_count));
            complete_and_exit(&evt_dead,0);
        }
    }
}
static int htckovsky_oj_thread(void *v) {
	struct completion exit;
	siginfo_t info;

	daemonize("oj_thread");
	allow_signal(SIGKILL);
	init_completion(&exit);

	while (true) {
		if (signal_pending(current)) {
			if (dequeue_signal_lock(current, &current->blocked, &info)
				== SIGKILL) {
				goto done;
			}
		}
		htckovsky_oj_work(NULL);
		msleep(OJ_POLL_DELAY);
	}

done:
	complete_and_exit(&exit, 0);
}