这篇教程C++ wait_for_completion_killable函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中wait_for_completion_killable函数的典型用法代码示例。如果您正苦于以下问题:C++ wait_for_completion_killable函数的具体用法?C++ wait_for_completion_killable怎么用?C++ wait_for_completion_killable使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了wait_for_completion_killable函数的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: wait_for_vfork_donestatic int wait_for_vfork_done(struct task_struct *child, struct completion *vfork){ int killed; freezer_do_not_count(); killed = wait_for_completion_killable(vfork); freezer_count(); if (killed) { task_lock(child); child->vfork_done = NULL; task_unlock(child); } put_task_struct(child); return killed;}
开发者ID:GAXUSXX,项目名称:G935FGaXusKernel2,代码行数:18,
示例2: mdp4_overlay_dtv_wait4_ov_donestatic void mdp4_overlay_dtv_wait4_ov_done(struct msm_fb_data_type *mfd){ unsigned long flag; /* enable irq */ spin_lock_irqsave(&mdp_spin_lock, flag); mdp_enable_irq(MDP_OVERLAY1_TERM); INIT_COMPLETION(dtv_pipe->comp); mfd->dma->waiting = TRUE; outp32(MDP_INTR_CLEAR, INTR_OVERLAY1_DONE); mdp_intr_mask |= INTR_OVERLAY1_DONE; outp32(MDP_INTR_ENABLE, mdp_intr_mask); spin_unlock_irqrestore(&mdp_spin_lock, flag); wait_for_completion_killable(&dtv_pipe->comp); spin_lock_irqsave(&mdp_done_lock, flag); mdp_disable_irq(MDP_OVERLAY1_TERM); spin_unlock_irqrestore(&mdp_done_lock, flag);}
开发者ID:AmeriCanAndroid,项目名称:aca-evo3d-omega-htc-35,代码行数:18,
示例3: mdp4_overlay_dtv_wait4vsyncvoid mdp4_overlay_dtv_wait4vsync(void){ unsigned long flag; if (!dtv_enabled) return; /* enable irq */ spin_lock_irqsave(&mdp_spin_lock, flag); mdp_enable_irq(MDP_DMA_E_TERM); INIT_COMPLETION(dtv_comp); outp32(MDP_INTR_CLEAR, INTR_EXTERNAL_VSYNC); mdp_intr_mask |= INTR_EXTERNAL_VSYNC; outp32(MDP_INTR_ENABLE, mdp_intr_mask); spin_unlock_irqrestore(&mdp_spin_lock, flag); wait_for_completion_killable(&dtv_comp); mdp_disable_irq(MDP_DMA_E_TERM);}
开发者ID:syhost,项目名称:kernel_ef39s_ics_new,代码行数:18,
示例4: mdp4_mddi_dma_s_kickoffvoid mdp4_mddi_dma_s_kickoff(struct msm_fb_data_type *mfd, struct mdp4_overlay_pipe *pipe){ down(&mfd->sem); mdp_enable_irq(MDP_DMA_S_TERM); mfd->dma->busy = TRUE; INIT_COMPLETION(pipe->dmas_comp); mfd->ibuf_flushed = TRUE; pending_pipe = pipe; /* start dma_s pipe */ mdp_pipe_kickoff(MDP_DMA_S_TERM, mfd); up(&mfd->sem); /* wait until DMA finishes the current job */ wait_for_completion_killable(&pipe->dmas_comp); pending_pipe = NULL; mdp_disable_irq(MDP_DMA_S_TERM);}
开发者ID:mantera,项目名称:triumph-kernel-msm7x30,代码行数:18,
示例5: mlx5_fpga_ipsec_sa_cmd_waitint mlx5_fpga_ipsec_sa_cmd_wait(void *ctx){ struct mlx5_ipsec_command_context *context = ctx; int res; res = wait_for_completion_killable(&context->complete); if (res) { mlx5_fpga_warn(context->dev, "Failure waiting for IPSec command response/n"); return -EINTR; } if (context->status == MLX5_FPGA_IPSEC_SACMD_COMPLETE) res = context->status_code; else res = -EIO; kfree(context); return res;}
开发者ID:ReneNyffenegger,项目名称:linux,代码行数:19,
示例6: mdp4_mddi_kickoff_uivoid mdp4_mddi_kickoff_ui(struct msm_fb_data_type *mfd, struct mdp4_overlay_pipe *pipe){ if (mdp4_overlay_mixer_play(mddi_pipe->mixer_num) > 0) {#ifdef MDDI_TIMER mddi_add_delay_timer(10);#endif atomic_set(&mddi_delay_kickoff_cnt, 1); INIT_COMPLETION(mddi_delay_comp); up(&mfd->dma->ov_sem); wait_for_completion_killable(&mddi_delay_comp); down(&mfd->dma->ov_sem); /* semaphore was re-locked, wait for DMA completion again*/ mdp4_mddi_dma_busy_wait(mfd, pipe); } mdp4_mddi_overlay_kickoff(mfd, pipe);}
开发者ID:maxzoel,项目名称:FreeXperia,代码行数:19,
示例7: mdp4_writeback_overlay_kickoffvoid mdp4_writeback_overlay_kickoff(struct msm_fb_data_type *mfd, struct mdp4_overlay_pipe *pipe){ unsigned long flag; spin_lock_irqsave(&mdp_spin_lock, flag); mdp_enable_irq(MDP_OVERLAY2_TERM); INIT_COMPLETION(writeback_pipe->comp); mfd->dma->busy = TRUE; outp32(MDP_INTR_CLEAR, INTR_OVERLAY2_DONE); mdp_intr_mask |= INTR_OVERLAY2_DONE; outp32(MDP_INTR_ENABLE, mdp_intr_mask); wmb(); /* make sure all registers updated */ spin_unlock_irqrestore(&mdp_spin_lock, flag); /* start OVERLAY pipe */ mdp_pipe_kickoff(MDP_OVERLAY2_TERM, mfd); wmb(); pr_debug("%s: before ov done interrupt/n", __func__); wait_for_completion_killable(&mfd->dma->comp);}
开发者ID:hroark13,项目名称:android_kernel_zte_elden,代码行数:20,
示例8: virtio_readstatic int virtio_read(struct hwrng *rng, void *buf, size_t size, bool wait){ int ret; if (!busy) { busy = true; init_completion(&have_data); register_buffer(buf, size); } if (!wait) return 0; ret = wait_for_completion_killable(&have_data); if (ret < 0) return ret; busy = false; return data_avail;}
开发者ID:Truefans,项目名称:KVMGT-kernel,代码行数:21,
示例9: mdp4_overlay_dtv_wait4dmaestatic void mdp4_overlay_dtv_wait4dmae(struct msm_fb_data_type *mfd){ unsigned long flag; if (!dtv_pipe) { pr_debug("%s: no mixer1 base layer pipe allocated!/n", __func__); return; } /* enable irq */ spin_lock_irqsave(&mdp_spin_lock, flag); mdp_enable_irq(MDP_DMA_E_TERM); INIT_COMPLETION(dtv_pipe->comp); mfd->dma->waiting = TRUE; outp32(MDP_INTR_CLEAR, INTR_DMA_E_DONE); mdp_intr_mask |= INTR_DMA_E_DONE; outp32(MDP_INTR_ENABLE, mdp_intr_mask); spin_unlock_irqrestore(&mdp_spin_lock, flag); wait_for_completion_killable(&dtv_pipe->comp); mdp_disable_irq(MDP_DMA_E_TERM);}
开发者ID:syhost,项目名称:kernel_ef39s_ics_new,代码行数:21,
示例10: mdp4_mddi_overlay_kickoffvoid mdp4_mddi_overlay_kickoff(struct msm_fb_data_type *mfd, struct mdp4_overlay_pipe *pipe){ struct msm_fb_panel_data *pdata = (struct msm_fb_panel_data *)mfd->pdev->dev.platform_data; down(&mfd->sem); mdp_enable_irq(MDP_OVERLAY0_TERM); mfd->dma->busy = TRUE; if (pdata->power_on_panel_at_pan) { INIT_COMPLETION(pipe->comp); pending_pipe = pipe; } /* start OVERLAY pipe */ mdp_pipe_kickoff(MDP_OVERLAY0_TERM, mfd); up(&mfd->sem); if (pdata->power_on_panel_at_pan) { wait_for_completion_killable(&pipe->comp); pending_pipe = NULL; }}
开发者ID:maxzoel,项目名称:FreeXperia,代码行数:22,
示例11: mdp_dma2_updatevoid mdp_dma2_update(struct msm_fb_data_type *mfd)#endif{ unsigned long flag; if (!mfd) return; down(&mfd->dma->mutex); if ((mfd) && (!mfd->dma->busy) && (mfd->panel_power_on)) { down(&mfd->sem); mfd->ibuf_flushed = TRUE; mdp_dma2_update_lcd(mfd); spin_lock_irqsave(&mdp_spin_lock, flag); mdp_enable_irq(MDP_DMA2_TERM); mfd->dma->busy = TRUE; INIT_COMPLETION(mfd->dma->comp); spin_unlock_irqrestore(&mdp_spin_lock, flag); /* schedule DMA to start */ mdp_dma_schedule(mfd, MDP_DMA2_TERM); up(&mfd->sem); /* wait until DMA finishes the current job */ wait_for_completion_killable(&mfd->dma->comp); mdp_disable_irq(MDP_DMA2_TERM); /* signal if pan function is waiting for the update completion */ if (mfd->pan_waiting) { mfd->pan_waiting = FALSE; complete(&mfd->pan_comp); } } up(&mfd->dma->mutex);}
开发者ID:carvsdriver,项目名称:msm8660-common_marla,代码行数:36,
示例12: mdp_dsi_video_updatevoid mdp_dsi_video_update(struct msm_fb_data_type *mfd){ struct fb_info *fbi = mfd->fbi; uint8 *buf; int bpp; unsigned long flag; int irq_block = MDP_DMA2_TERM; if (!mfd->panel_power_on) return; down(&mfd->dma->mutex); bpp = fbi->var.bits_per_pixel / 8; buf = (uint8 *) fbi->fix.smem_start; buf += calc_fb_offset(mfd, fbi, bpp); /* no need to power on cmd block since it's dsi mode */ /* starting address */ MDP_OUTP(MDP_BASE + DMA_P_BASE + 0x8, (uint32) buf); /* enable irq */ spin_lock_irqsave(&mdp_spin_lock, flag); mdp_enable_irq(irq_block); INIT_COMPLETION(mfd->dma->comp); mfd->dma->waiting = TRUE; outp32(MDP_INTR_CLEAR, LCDC_FRAME_START); mdp_intr_mask |= LCDC_FRAME_START; outp32(MDP_INTR_ENABLE, mdp_intr_mask); spin_unlock_irqrestore(&mdp_spin_lock, flag); wait_for_completion_killable(&mfd->dma->comp); mdp_disable_irq(irq_block); up(&mfd->dma->mutex);}
开发者ID:AmperificSuperKANG,项目名称:android_kernel_mako,代码行数:36,
示例13: mdp_lcdc_updatevoid mdp_lcdc_update(struct msm_fb_data_type *mfd){ struct fb_info *fbi = mfd->fbi; uint8 *buf; int bpp; unsigned long flag; if (!mfd->panel_power_on) return; /* no need to power on cmd block since it's lcdc mode */ bpp = fbi->var.bits_per_pixel / 8; buf = (uint8 *) fbi->fix.smem_start; buf += (fbi->var.xoffset + fbi->var.yoffset * fbi->var.xres_virtual) * bpp; /* starting address */ MDP_OUTP(MDP_BASE + 0x90008, (uint32) buf); /* enable LCDC irq */ spin_lock_irqsave(&mdp_spin_lock, flag); mdp_enable_irq(MDP_DMA2_TERM); INIT_COMPLETION(mfd->dma->comp); mfd->dma->waiting = TRUE;#ifdef CONFIG_FB_MSM_MDP40 outp32(MDP_INTR_CLEAR, INTR_DMA_P_DONE); mdp_intr_mask |= INTR_DMA_P_DONE; outp32(MDP_INTR_ENABLE, mdp_intr_mask);#else outp32(MDP_INTR_CLEAR, LCDC_FRAME_START); mdp_intr_mask |= LCDC_FRAME_START; outp32(MDP_INTR_ENABLE, mdp_intr_mask);#endif spin_unlock_irqrestore(&mdp_spin_lock, flag); wait_for_completion_killable(&mfd->dma->comp); mdp_disable_irq(MDP_DMA2_TERM);}
开发者ID:mtuton,项目名称:linux_u82x0,代码行数:36,
示例14: mdp_dma2_updatevoid mdp_dma2_update(struct msm_fb_data_type *mfd)#endif{ unsigned long flag; static int first_vsync; int need_wait = 0; down(&mfd->dma->mutex); if ((mfd) && (mfd->panel_power_on)) { down(&mfd->sem); spin_lock_irqsave(&mdp_spin_lock, flag); if (mfd->dma->busy == TRUE) need_wait++; spin_unlock_irqrestore(&mdp_spin_lock, flag); if (need_wait) wait_for_completion_killable(&mfd->dma->comp);#if defined (CONFIG_MACH_KYLEPLUS_CTC) /* wait until Vsync finishes the current job */ if (first_vsync) { if (!wait_for_completion_killable_timeout (&vsync_cntrl.vsync_comp, HZ/10)) pr_err("Timedout DMA %s %d", __func__, __LINE__); } else { first_vsync = 1; }#endif /* schedule DMA to start */ mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); mfd->ibuf_flushed = TRUE; mdp_dma2_update_lcd(mfd); spin_lock_irqsave(&mdp_spin_lock, flag); mdp_enable_irq(MDP_DMA2_TERM); mfd->dma->busy = TRUE; INIT_COMPLETION(mfd->dma->comp); INIT_COMPLETION(vsync_cntrl.vsync_comp); if (!vsync_cntrl.vsync_irq_enabled && vsync_cntrl.disabled_clocks) { MDP_OUTP(MDP_BASE + 0x021c, 0x10); /* read pointer */ outp32(MDP_INTR_CLEAR, MDP_PRIM_RDPTR); mdp_intr_mask |= MDP_PRIM_RDPTR; outp32(MDP_INTR_ENABLE, mdp_intr_mask); mdp_enable_irq(MDP_VSYNC_TERM); vsync_cntrl.vsync_dma_enabled = 1; } spin_unlock_irqrestore(&mdp_spin_lock, flag); /* schedule DMA to start */ mdp_dma_schedule(mfd, MDP_DMA2_TERM); up(&mfd->sem); #ifndef CONFIG_MACH_KYLEPLUS_CTC /* wait until Vsync finishes the current job */ if (first_vsync) { if (!wait_for_completion_killable_timeout (&vsync_cntrl.vsync_comp, HZ/10)) pr_err("Timedout DMA %s %d", __func__, __LINE__); } else { first_vsync = 1; }#endif mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); /* signal if pan function is waiting for the update completion */ if (mfd->pan_waiting) { mfd->pan_waiting = FALSE; complete(&mfd->pan_comp); } } up(&mfd->dma->mutex);}
开发者ID:NovaFusion,项目名称:android_kernel_samsung_arubaslim,代码行数:73,
示例15: hil_dev_connectstatic int hil_dev_connect(struct serio *serio, struct serio_driver *drv){ struct hil_dev *dev; struct input_dev *input_dev; uint8_t did, *idd; int error; dev = kzalloc(sizeof(*dev), GFP_KERNEL); input_dev = input_allocate_device(); if (!dev || !input_dev) { error = -ENOMEM; goto bail0; } dev->serio = serio; dev->dev = input_dev; error = serio_open(serio, drv); if (error) goto bail0; serio_set_drvdata(serio, dev); /* Get device info. MLC driver supplies devid/status/etc. */ init_completion(&dev->cmd_done); serio_write(serio, 0); serio_write(serio, 0); serio_write(serio, HIL_PKT_CMD >> 8); serio_write(serio, HIL_CMD_IDD); error = wait_for_completion_killable(&dev->cmd_done); if (error) goto bail1; init_completion(&dev->cmd_done); serio_write(serio, 0); serio_write(serio, 0); serio_write(serio, HIL_PKT_CMD >> 8); serio_write(serio, HIL_CMD_RSC); error = wait_for_completion_killable(&dev->cmd_done); if (error) goto bail1; init_completion(&dev->cmd_done); serio_write(serio, 0); serio_write(serio, 0); serio_write(serio, HIL_PKT_CMD >> 8); serio_write(serio, HIL_CMD_RNM); error = wait_for_completion_killable(&dev->cmd_done); if (error) goto bail1; init_completion(&dev->cmd_done); serio_write(serio, 0); serio_write(serio, 0); serio_write(serio, HIL_PKT_CMD >> 8); serio_write(serio, HIL_CMD_EXD); error = wait_for_completion_killable(&dev->cmd_done); if (error) goto bail1; did = dev->idd[0]; idd = dev->idd + 1; switch (did & HIL_IDD_DID_TYPE_MASK) { case HIL_IDD_DID_TYPE_KB_INTEGRAL: case HIL_IDD_DID_TYPE_KB_ITF: case HIL_IDD_DID_TYPE_KB_RSVD: case HIL_IDD_DID_TYPE_CHAR: if (HIL_IDD_NUM_BUTTONS(idd) || HIL_IDD_NUM_AXES_PER_SET(*idd)) { printk(KERN_INFO PREFIX "combo devices are not supported./n"); goto bail1; } dev->is_pointer = false; hil_dev_keyboard_setup(dev); break; case HIL_IDD_DID_TYPE_REL: case HIL_IDD_DID_TYPE_ABS: dev->is_pointer = true; hil_dev_pointer_setup(dev); break; default: goto bail1; } input_dev->id.bustype = BUS_HIL; input_dev->id.vendor = PCI_VENDOR_ID_HP; input_dev->id.product = 0x0001; /* TODO: get from kbd->rsc */ input_dev->id.version = 0x0100; /* TODO: get from kbd->rsc */ input_dev->dev.parent = &serio->dev; if (!dev->is_pointer) { serio_write(serio, 0); serio_write(serio, 0); serio_write(serio, HIL_PKT_CMD >> 8); /* Enable Keyswitch Autorepeat 1 *///.........这里部分代码省略.........
开发者ID:mikuhatsune001,项目名称:linux2.6.32,代码行数:101,
示例16: mdp4_mddi_overlay_kickoffvoid mdp4_mddi_overlay_kickoff(struct msm_fb_data_type *mfd, struct mdp4_overlay_pipe *pipe){#ifdef MDP4_NONBLOCKING unsigned long flag; if (pipe == mddi_pipe) { /* base layer */ if (mdp4_overlay_pipe_staged(pipe->mixer_num) > 1) { if (time_before(jiffies, (mddi_last_kick + mddi_kick_interval/2))) { mdp4_stat.kickoff_mddi_skip++; return; /* let other pipe to kickoff */ } } } spin_lock_irqsave(&mdp_spin_lock, flag); if (mfd->dma->busy == TRUE) { INIT_COMPLETION(pipe->comp); pending_pipe = pipe; } spin_unlock_irqrestore(&mdp_spin_lock, flag); if (pending_pipe != NULL) { /* wait until DMA finishes the current job */ wait_for_completion_killable(&pipe->comp); pending_pipe = NULL; } down(&mfd->sem); mdp_enable_irq(MDP_OVERLAY0_TERM); mfd->dma->busy = TRUE; /* start OVERLAY pipe */ mdp_pipe_kickoff(MDP_OVERLAY0_TERM, mfd); if (pipe != mddi_pipe) { /* non base layer */ int intv; if (mddi_last_kick == 0) intv = 0; else intv = jiffies - mddi_last_kick; mddi_kick_interval += intv; mddi_kick_interval /= 2; /* average */ mddi_last_kick = jiffies; } up(&mfd->sem);#else down(&mfd->sem); mdp_enable_irq(MDP_OVERLAY0_TERM); mfd->dma->busy = TRUE; INIT_COMPLETION(pipe->comp); pending_pipe = pipe; /* start OVERLAY pipe */ mdp_pipe_kickoff(MDP_OVERLAY0_TERM, mfd); up(&mfd->sem); /* wait until DMA finishes the current job */ wait_for_completion_killable(&pipe->comp); mdp_disable_irq(MDP_OVERLAY0_TERM);#endif}
开发者ID:mantera,项目名称:triumph-kernel-msm7x30,代码行数:62,
示例17: DECLARE_COMPLETION_ONSTACK/** * kthread_create_on_node - create a kthread. * @threadfn: the function to run until signal_pending(current). * @data: data ptr for @threadfn. * @node: memory node number. * @namefmt: printf-style name for the thread. * * Description: This helper function creates and names a kernel * thread. The thread will be stopped: use wake_up_process() to start * it. See also kthread_run(). * * If thread is going to be bound on a particular cpu, give its node * in @node, to get NUMA affinity for kthread stack, or else give -1. * When woken, the thread will run @threadfn() with @data as its * argument. @threadfn() can either call do_exit() directly if it is a * standalone thread for which no one will call kthread_stop(), or * return when 'kthread_should_stop()' is true (which means * kthread_stop() has been called). The return value should be zero * or a negative error number; it will be passed to kthread_stop(). * * Returns a task_struct or ERR_PTR(-ENOMEM). */struct task_struct *kthread_create_on_node(int (*threadfn)(void *data), void *data, int node, const char namefmt[], ...){ DECLARE_COMPLETION_ONSTACK(done); struct task_struct *task; struct kthread_create_info *create = kmalloc(sizeof(*create), GFP_KERNEL); if (!create) return ERR_PTR(-ENOMEM); create->threadfn = threadfn; create->data = data; create->node = node; create->done = &done; spin_lock(&kthread_create_lock); list_add_tail(&create->list, &kthread_create_list); spin_unlock(&kthread_create_lock); wake_up_process(kthreadd_task); /* * Wait for completion in killable state, for I might be chosen by * the OOM killer while kthreadd is trying to allocate memory for * new kernel thread. */ if (unlikely(wait_for_completion_killable(&done))) { int i = 0; /* * I got SIGKILL, but wait for 10 more seconds for completion * unless chosen by the OOM killer. This delay is there as a * workaround for boot failure caused by SIGKILL upon device * driver initialization timeout. */ while (i++ < 10 && !test_tsk_thread_flag(current, TIF_MEMDIE)) if (wait_for_completion_timeout(&done, HZ)) goto ready; /* * If I was SIGKILLed before kthreadd (or new kernel thread) * calls complete(), leave the cleanup of this structure to * that thread. */ if (xchg(&create->done, NULL)) return ERR_PTR(-ENOMEM); /* * kthreadd (or new kernel thread) will call complete() * shortly. */ wait_for_completion(&done); }ready: task = create->result; if (!IS_ERR(task)) { static const struct sched_param param = { .sched_priority = 0 }; va_list args; va_start(args, namefmt); vsnprintf(task->comm, sizeof(task->comm), namefmt, args); va_end(args); /* * root may have changed our (kthreadd's) priority or CPU mask. * The kernel thread should not inherit these properties. */ sched_setscheduler_nocheck(task, SCHED_NORMAL, ¶m); set_cpus_allowed_ptr(task, cpu_all_mask); } kfree(create); return task;}EXPORT_SYMBOL(kthread_create_on_node);static void __kthread_bind(struct task_struct *p, unsigned int cpu, long state){ /* Must have done schedule() in kthread() before we set_task_cpu */ if (!wait_task_inactive(p, state)) { WARN_ON(1);//.........这里部分代码省略.........
开发者ID:mobilehunter,项目名称:trafficsqueezer-org,代码行数:101,
示例18: DECLARE_COMPLETION_ONSTACK/** * kthread_create_on_node - create a kthread. * @threadfn: the function to run until signal_pending(current). * @data: data ptr for @threadfn. * @node: memory node number. * @namefmt: printf-style name for the thread. * * Description: This helper function creates and names a kernel * thread. The thread will be stopped: use wake_up_process() to start * it. See also kthread_run(). * * If thread is going to be bound on a particular cpu, give its node * in @node, to get NUMA affinity for kthread stack, or else give -1. * When woken, the thread will run @threadfn() with @data as its * argument. @threadfn() can either call do_exit() directly if it is a * standalone thread for which no one will call kthread_stop(), or * return when 'kthread_should_stop()' is true (which means * kthread_stop() has been called). The return value should be zero * or a negative error number; it will be passed to kthread_stop(). * * Returns a task_struct or ERR_PTR(-ENOMEM) or ERR_PTR(-EINTR). */struct task_struct *kthread_create_on_node(int (*threadfn)(void *data), void *data, int node, const char namefmt[], ...){ DECLARE_COMPLETION_ONSTACK(done); struct task_struct *task; struct kthread_create_info *create = kmalloc(sizeof(*create), GFP_KERNEL); if (!create) return ERR_PTR(-ENOMEM); create->threadfn = threadfn; create->data = data; create->node = node; create->done = &done; spin_lock(&kthread_create_lock); list_add_tail(&create->list, &kthread_create_list); spin_unlock(&kthread_create_lock); wake_up_process(kthreadd_task); /* * Wait for completion in killable state, for I might be chosen by * the OOM killer while kthreadd is trying to allocate memory for * new kernel thread. */ if (unlikely(wait_for_completion_killable(&done))) { /* * If I was SIGKILLed before kthreadd (or new kernel thread) * calls complete(), leave the cleanup of this structure to * that thread. */ if (xchg(&create->done, NULL)) return ERR_PTR(-EINTR); /* * kthreadd (or new kernel thread) will call complete() * shortly. */ wait_for_completion(&done); } task = create->result; if (!IS_ERR(task)) { static const struct sched_param param = { .sched_priority = 0 }; va_list args; va_start(args, namefmt); vsnprintf(task->comm, sizeof(task->comm), namefmt, args); va_end(args); /* * root may have changed our (kthreadd's) priority or CPU mask. * The kernel thread should not inherit these properties. */ sched_setscheduler_nocheck(task, SCHED_NORMAL, ¶m); set_cpus_allowed_ptr(task, cpu_all_mask); } kfree(create); return task;}EXPORT_SYMBOL(kthread_create_on_node);/** * kthread_bind - bind a just-created kthread to a cpu. * @p: thread created by kthread_create(). * @cpu: cpu (might not be online, must be possible) for @k to run on. * * Description: This function is equivalent to set_cpus_allowed(), * except that @cpu doesn't need to be online, and the thread must be * stopped (i.e., just returned from kthread_create()). */void kthread_bind(struct task_struct *p, unsigned int cpu){ /* Must have done schedule() in kthread() before we set_task_cpu */ if (!wait_task_inactive(p, TASK_UNINTERRUPTIBLE)) { WARN_ON(1); return; }//.........这里部分代码省略.........
开发者ID:milosivanovic,项目名称:Googy-Max3-Kernel,代码行数:101,
注:本文中的wait_for_completion_killable函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ wait_for_completion_timeout函数代码示例 C++ wait_for_completion_interruptible_timeout函数代码示例 |