这篇教程C++ waitqueue_active函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中waitqueue_active函数的典型用法代码示例。如果您正苦于以下问题:C++ waitqueue_active函数的具体用法?C++ waitqueue_active怎么用?C++ waitqueue_active使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了waitqueue_active函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: abort_exclusive_wait/* * abort_exclusive_wait - abort exclusive waiting in a queue * @q: waitqueue waited on * @wait: wait descriptor * @state: runstate of the waiter to be woken * @key: key to identify a wait bit queue or %NULL * * Sets current thread back to running state and removes * the wait descriptor from the given waitqueue if still * queued. * * Wakes up the next waiter if the caller is concurrently * woken up through the queue. * * This prevents waiter starvation where an exclusive waiter * aborts and is woken up concurrently and noone wakes up * the next waiter. */void abort_exclusive_wait(wait_queue_head_t *q, wait_queue_t *wait, unsigned int mode, void *key){ unsigned long flags; __set_current_state(TASK_RUNNING); spin_lock_irqsave(&q->lock, flags); if (!list_empty(&wait->task_list)) list_del_init(&wait->task_list); else if (waitqueue_active(q)) __wake_up_common(q, mode, 1, 0, key); spin_unlock_irqrestore(&q->lock, flags);}
开发者ID:gaojie,项目名称:GaoGit,代码行数:31,
示例2: _mali_osk_wait_queue_wake_upvoid _mali_osk_wait_queue_wake_up( _mali_osk_wait_queue_t *queue ){ MALI_DEBUG_ASSERT_POINTER( queue ); /* if queue is empty, don't attempt to wake up its elements */ if (!waitqueue_active(&queue->wait_queue)) return; MALI_DEBUG_PRINT(6, ("Waking up elements in wait queue %p ..../n", queue)); wake_up_all(&queue->wait_queue); MALI_DEBUG_PRINT(6, ("... elements in wait queue %p woken up/n", queue));}
开发者ID:HuaweiHonor4C,项目名称:kernel_hi6210sft_mm,代码行数:13,
示例3: sk_stream_write_space/** * sk_stream_write_space - stream socket write_space callback. * @sk: socket * * FIXME: write proper description */void sk_stream_write_space(struct sock *sk){ struct socket *sock = sk->sk_socket; if (sk_stream_wspace(sk) >= sk_stream_min_wspace(sk) && sock) { clear_bit(SOCK_NOSPACE, &sock->flags); if (sk->sk_sleep && waitqueue_active(sk->sk_sleep)) wake_up_interruptible(sk->sk_sleep); if (sock->fasync_list && !(sk->sk_shutdown & SEND_SHUTDOWN)) sock_wake_async(sock, 2, POLL_OUT); }}
开发者ID:3sOx,项目名称:asuswrt-merlin,代码行数:19,
示例4: snd_seq_oss_writeq_wakeup/* * wake up sync - echo event was catched */voidsnd_seq_oss_writeq_wakeup(seq_oss_writeq_t *q, abstime_t time){ unsigned long flags; spin_lock_irqsave(&q->sync_lock, flags); q->sync_time = time; q->sync_event_put = 0; if (waitqueue_active(&q->sync_sleep)) { wake_up(&q->sync_sleep); } spin_unlock_irqrestore(&q->sync_lock, flags);}
开发者ID:Antonio-Zhou,项目名称:Linux-2.6.11,代码行数:16,
示例5: drm_free_buffer/** * Free a buffer. * * /param dev DRM device. * /param buf buffer to free. * * Resets the fields of /p buf. */void drm_free_buffer(drm_device_t *dev, drm_buf_t *buf){ if (!buf) return; buf->waiting = 0; buf->pending = 0; buf->filp = NULL; buf->used = 0; if (drm_core_check_feature(dev, DRIVER_DMA_QUEUE) && waitqueue_active(&buf->dma_wait)) { wake_up_interruptible(&buf->dma_wait); }}
开发者ID:Antonio-Zhou,项目名称:Linux-2.6.11,代码行数:21,
示例6: shutdown/** * shutdown - shutdown socket connection * @sock: socket structure * @how: direction to close (must be SHUT_RDWR) * * Terminates connection (if necessary), then purges socket's receive queue. * * Returns 0 on success, errno otherwise */static int shutdown(struct socket *sock, int how){ struct sock *sk = sock->sk; struct tipc_port *tport = tipc_sk_port(sk); struct sk_buff *buf; int res; if (how != SHUT_RDWR) return -EINVAL; lock_sock(sk); switch (sock->state) { case SS_CONNECTING: case SS_CONNECTED:restart: /* Disconnect and send a 'FIN+' or 'FIN-' message to peer */ buf = __skb_dequeue(&sk->sk_receive_queue); if (buf) { atomic_dec(&tipc_queue_size); if (TIPC_SKB_CB(buf)->handle != 0) { kfree_skb(buf); goto restart; } tipc_disconnect(tport->ref); tipc_reject_msg(buf, TIPC_CONN_SHUTDOWN); } else { tipc_shutdown(tport->ref); } sock->state = SS_DISCONNECTING; /* fall through */ case SS_DISCONNECTING: /* Discard any unreceived messages; wake up sleeping tasks */ discard_rx_queue(sk); if (waitqueue_active(sk_sleep(sk))) wake_up_interruptible(sk_sleep(sk)); res = 0; break; default: res = -ENOTCONN; } release_sock(sk); return res;}
开发者ID:AllenWeb,项目名称:linux,代码行数:60,
示例7: eventfd_signal/** * eventfd_signal - Adds @n to the eventfd counter. * @ctx: [in] Pointer to the eventfd context. * @n: [in] Value of the counter to be added to the eventfd internal counter. * The value cannot be negative. * * This function is supposed to be called by the kernel in paths that do not * allow sleeping. In this function we allow the counter to reach the ULLONG_MAX * value, and we signal this as overflow condition by returining a POLLERR * to poll(2). * * Returns the amount by which the counter was incrememnted. This will be less * than @n if the counter has overflowed. */__u64 eventfd_signal(struct eventfd_ctx *ctx, __u64 n){ unsigned long flags; spin_lock_irqsave(&ctx->wqh.lock, flags); if (ULLONG_MAX - ctx->count < n) n = ULLONG_MAX - ctx->count; ctx->count += n; if (waitqueue_active(&ctx->wqh)) wake_up_locked_poll(&ctx->wqh, POLLIN); spin_unlock_irqrestore(&ctx->wqh.lock, flags); return n;}
开发者ID:ARMWorks,项目名称:FA_2451_Linux_Kernel,代码行数:28,
示例8: timerfd_callback/* * This gets called when the timer event triggers. We set the "expired" * flag, but we do not re-arm the timer (in case it's necessary, * interval.tv64 != 0) until the timer is accessed. */enum hrtimer_restart timerfd_callback(struct hrtimer *timer){ struct timerfd_ctx *ctx = container_of(timer, struct timerfd_ctx, timer); unsigned long flags; spin_lock_irqsave(&ctx->wqh.lock, flags); ctx->expired = 1; ctx->ticks++; if (waitqueue_active(&ctx->wqh)) __wake_up_locked_keyPtr(&ctx->wqh, TASK_NORMAL, (void *) (POLLIN)); spin_unlock_irqrestore(&ctx->wqh.lock, flags); return HRTIMER_NORESTART;}
开发者ID:Dav3xor,项目名称:Lethe,代码行数:19,
示例9: RESET_EVENTvoid RESET_EVENT( EVENT_HNDL* pEvent ){ DWORD LockFlag; // clear the event flag ACQUIRE_LOCK( &pEvent->FlagLock, LockFlag ); pEvent->SetFlag = FALSE; // empty out the queue while ( waitqueue_active( &pEvent->WaitQue ) ) interruptible_sleep_on( &pEvent->WaitQue ); RELEASE_LOCK( &pEvent->FlagLock, LockFlag );}
开发者ID:BackupTheBerlios,项目名称:wl530g-svn,代码行数:14,
示例10: kvm_vcpu_kickvoid kvm_vcpu_kick(struct kvm_vcpu *vcpu){ int me; int cpu = vcpu->cpu; me = get_cpu(); if (waitqueue_active(vcpu->arch.wqp)) { wake_up_interruptible(vcpu->arch.wqp); vcpu->stat.halt_wakeup++; } else if (cpu != me && cpu != -1) { smp_send_reschedule(vcpu->cpu); } put_cpu();}
开发者ID:openube,项目名称:android_kernel_sony_c2305,代码行数:14,
示例11: tmio_irqstatic irqreturn_t tmio_irq(int irq, void *__tmio){ struct tmio_nand *tmio = __tmio; struct nand_chip *nand_chip = &tmio->chip; /* disable RDYREQ interrupt */ tmio_iowrite8(0x00, tmio->fcr + FCR_IMR); if (unlikely(!waitqueue_active(&nand_chip->controller->wq))) dev_warn(&tmio->dev->dev, "spurious interrupt/n"); wake_up(&nand_chip->controller->wq); return IRQ_HANDLED;}
开发者ID:03199618,项目名称:linux,代码行数:14,
示例12: signalfd_cleanupvoid signalfd_cleanup(struct sighand_struct *sighand){ wait_queue_head_t *wqh = &sighand->signalfd_wqh; /* */ if (likely(!waitqueue_active(wqh))) return; /* */ wake_up_poll(wqh, POLLHUP | POLLFREE);}
开发者ID:romanbb,项目名称:android_kernel_lge_d851,代码行数:14,
示例13: eventfd_ctx_remove_wait_queue/** * eventfd_ctx_remove_wait_queue - Read the current counter and removes wait queue. * @ctx: [in] Pointer to eventfd context. * @wait: [in] Wait queue to be removed. * @cnt: [out] Pointer to the 64-bit counter value. * * Returns %0 if successful, or the following error codes: * * -EAGAIN : The operation would have blocked. * * This is used to atomically remove a wait queue entry from the eventfd wait * queue head, and read/reset the counter value. */int eventfd_ctx_remove_wait_queue(struct eventfd_ctx *ctx, wait_queue_t *wait, __u64 *cnt){ unsigned long flags; spin_lock_irqsave(&ctx->wqh.lock, flags); eventfd_ctx_do_read(ctx, cnt); __remove_wait_queue(&ctx->wqh, wait); if (*cnt != 0 && waitqueue_active(&ctx->wqh)) wake_up_locked_poll(&ctx->wqh, POLLOUT); spin_unlock_irqrestore(&ctx->wqh.lock, flags); return *cnt != 0 ? 0 : -EAGAIN;}
开发者ID:kenkit,项目名称:AndromadusMod-New,代码行数:27,
示例14: kni_sk_write_spacestatic voidkni_sk_write_space(struct sock *sk){ wait_queue_head_t *wqueue; if (!sock_writeable(sk) || !test_and_clear_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags)) return; wqueue = sk_sleep(sk); if (wqueue && waitqueue_active(wqueue)) wake_up_interruptible_poll( wqueue, POLLOUT | POLLWRNORM | POLLWRBAND);}
开发者ID:fleitner,项目名称:dpdk,代码行数:14,
示例15: signalfd_cleanupvoid signalfd_cleanup(struct sighand_struct *sighand){ wait_queue_head_t *wqh = &sighand->signalfd_wqh; /* * The lockless check can race with remove_wait_queue() in progress, * but in this case its caller should run under rcu_read_lock() and * sighand_cachep is SLAB_DESTROY_BY_RCU, we can safely return. */ if (likely(!waitqueue_active(wqh))) return; /* wait_queue_t->func(POLLFREE) should do remove_wait_queue() */ wake_up_poll(wqh, POLLHUP | POLLFREE);}
开发者ID:Lance0312,项目名称:osdi-exercise,代码行数:14,
示例16: vloopback_writestatic ssize_t vloopback_write(struct file *f, const char *buf, size_t count, loff_t *offset){ struct video_device *loopdev=video_devdata(f);#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) priv_ptr ptr=(priv_ptr)video_get_drvdata(loopdev);#else priv_ptr ptr=(priv_ptr)loopdev->priv;#endif int nr=ptr->pipenr; unsigned long realcount=count; if (!ptr->in) return -EINVAL; if (loops[nr]->zerocopy) return -EINVAL; if (loops[nr]->buffer==NULL) { return -EINVAL; } /* Anybody want some pictures??? */ if (!waitqueue_active(&loops[nr]->wait)) { /* No, waiting this makes the write op blocking */ wait_event_interruptible(loops[nr]->wait, loops[nr]->pendingread); } down(&loops[nr]->lock); if (!loops[nr]->buffer) { up(&loops[nr]->lock); return -EINVAL; } if (realcount > loops[nr]->buflength) { realcount = loops[nr]->buflength; info("Too much data! Only %ld bytes used.", realcount); } if (copy_from_user( loops[nr]->buffer+loops[nr]->frame*loops[nr]->buflength, buf, realcount )) return -EFAULT; loops[nr]->frame=0; up(&loops[nr]->lock); loops[nr]->frameswrite++; wake_up(&loops[nr]->wait); return realcount;}
开发者ID:ravalnet,项目名称:xarxa-omnia,代码行数:50,
示例17: kvm_vcpu_ioctl_interruptint kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu, struct kvm_interrupt *irq){ if (irq->irq == KVM_INTERRUPT_UNSET) kvmppc_core_dequeue_external(vcpu, irq); else kvmppc_core_queue_external(vcpu, irq); if (waitqueue_active(&vcpu->wq)) { wake_up_interruptible(&vcpu->wq); vcpu->stat.halt_wakeup++; } return 0;}
开发者ID:007kumarraja,项目名称:rockchip-rk3188-mk908,代码行数:14,
示例18: osprd_close_laststatic int osprd_close_last(struct inode *inode, struct file *filp){ int r; r = 0; if (filp) { osprd_info_t *d = file2osprd(filp); int filp_writable = filp->f_mode & FMODE_WRITE; // EXERCISE: If the user closes a ramdisk file that holds // a lock, release the lock. Also wake up blocked processes // as appropriate. //r = osprd_ioctl (inode, filp, OSPRDIOCRELEASE, 0); // Your code here. // This line avoids compiler warnings; you may remove it. (void) filp_writable, (void) d; if (!(filp->f_flags & F_OSPRD_LOCKED)) {r = -EINVAL; } // Otherwise, clear the lock from filp->f_flags, wake up // the wait queue, perform any additional accounting steps // you need, and return 0. else { osp_spin_lock(&(d->mutex)); // Clear lock flag. filp->f_flags &= ~F_OSPRD_LOCKED; //d->mutex.lock = 0; d->n_writel = 0; d->n_readl = 0; d->dead = 0; // Wake queue. if(waitqueue_active(&d->blockq) == 0){ //eprintk("Tail: %d head: %d/n", d->ticket_tail, d->ticket_head); //d->ticket_head = d->ticket_tail; d->ticket_tail += d->desync; d->desync = 0; } osp_spin_unlock(&(d->mutex)); wake_up_all(&d->blockq); r = 0; } } return r;}
开发者ID:tbramer,项目名称:CS-111-Lab-2,代码行数:49,
示例19: dna_e1000e_clean_rx_irqstatic bool dna_e1000e_clean_rx_irq(struct e1000_adapter *adapter) { bool ret; int i, debug = 0; struct e1000_ring *rx_ring = adapter->rx_ring; union e1000_rx_desc_extended *rx_desc; struct e1000_buffer *buffer_info; struct e1000_hw *hw = &adapter->hw; u32 staterr; /* The register contains the last packet that we have read */ i = E1000_READ_REG(hw, E1000_RDT(0)); if(++i == rx_ring->count) i = 0; rx_ring->next_to_clean = i; rx_desc = E1000_RX_DESC_EXT(*rx_ring, i); staterr = le32_to_cpu(rx_desc->wb.upper.status_error); buffer_info = &rx_ring->buffer_info[i]; if(unlikely(debug)) printk(KERN_INFO "DNA: dna_e1000_clean_rx_irq(%s)[id=%d][status=%d][rx_reg=%u]/n", adapter->netdev->name, i, staterr, E1000_READ_REG(&adapter->hw, E1000_RDT(0))); if(staterr & E1000_RXD_STAT_DD) { if(!adapter->dna.interrupt_received) { if(waitqueue_active(&adapter->dna.packet_waitqueue)) { wake_up_interruptible(&adapter->dna.packet_waitqueue); adapter->dna.interrupt_received = 1; if(unlikely(debug)) printk(KERN_WARNING "DNA: dna_e1000_clean_rx_irq(%s): " "woken up [slot=%d] XXXX/n", adapter->netdev->name, i); } } if(unlikely(debug)) printk(KERN_WARNING "DNA: dna_e1000_clean_rx_irq(%s): " "woken up [slot=%d][interrupt_received=%d]/n", adapter->netdev->name, i, adapter->dna.interrupt_received); ret = TRUE; } else ret = FALSE; return(ret); }
开发者ID:a5216652166,项目名称:ss,代码行数:49,
示例20: tier_attr_internals_showstatic ssize_t tier_attr_internals_show(struct tier_device *dev, char *buf){ char *iotype; char *iopending; char *qlock; char *aiowq; char *discard;#ifndef MAX_PERFORMANCE char *debug_state;#endif int res = 0; if (atomic_read(&dev->migrate) == MIGRATION_IO) iotype = as_sprintf("iotype (normal or migration) : migration_io/n"); else if (atomic_read(&dev->wqlock)) iotype = as_sprintf("iotype (normal or migration) : normal_io/n"); else iotype = as_sprintf("iotype (normal or migration) : no activity/n"); iopending = as_sprintf("async random ios pending : %i/n", atomic_read(&dev->aio_pending)); if ( mutex_is_locked(&dev->qlock)) qlock = as_sprintf("main mutex : locked/n"); else qlock = as_sprintf("main mutex : unlocked/n"); if (waitqueue_active(&dev->aio_event)) aiowq = as_sprintf("waiting on asynchrounous io : True/n"); else aiowq = as_sprintf("waiting on asynchrounous io : False/n");#ifndef MAX_PERFORMANCE spin_lock(&dev->dbg_lock); if (dev->debug_state & DISCARD) discard = as_sprintf("discard request is pending : True/n"); else discard = as_sprintf("discard request is pending : False/n"); debug_state = as_sprintf("debug state : %i/n", dev->debug_state); spin_unlock(&dev->dbg_lock); res = sprintf(buf, "%s%s%s%s%s%s", iotype, iopending, qlock, aiowq, discard, debug_state);#else res = sprintf(buf, "%s%s%s%s", iotype, iopending, qlock, aiowq);#endif kfree(iotype); kfree(iopending); kfree(qlock); kfree(aiowq);#ifndef MAX_PERFORMANCE kfree(discard); kfree(debug_state);#endif return res;}
开发者ID:borland667,项目名称:btier,代码行数:49,
示例21: sdp_tx_handler_select/* Select who will handle tx completion: * - a write is pending - wake it up and let it do the poll + post * - post handler is taken - taker will do the poll + post * else return 1 and let the caller do it */static int sdp_tx_handler_select(struct sdp_sock *ssk){ struct sock *sk = sk_ssk(ssk); if (sk->sk_write_pending) { /* Do the TX posts from sender context */ if (sdp_sk_sleep(sk) && waitqueue_active(sdp_sk_sleep(sk))) { sdp_prf1(sk, NULL, "Waking up pending sendmsg"); wake_up_interruptible(sdp_sk_sleep(sk)); return 0; } else sdp_prf1(sk, NULL, "Unexpected: sk_sleep=%p, " "waitqueue_active: %d/n", sdp_sk_sleep(sk), waitqueue_active(sdp_sk_sleep(sk))); } if (posts_handler(ssk)) { /* Somebody else available to check for completion */ sdp_prf1(sk, NULL, "Somebody else will call do_posts"); return 0; } return 1;}
开发者ID:u9621071,项目名称:kernel-uek-UEK3,代码行数:29,
示例22: __kaio_queue_fsync_reqstatic void __kaio_queue_fsync_req(struct ploop_request * preq, int prio){ struct ploop_device * plo = preq->plo; struct ploop_delta * delta = ploop_top_delta(plo); struct ploop_io * io = &delta->io; if (prio) list_add(&preq->list, &io->fsync_queue); else list_add_tail(&preq->list, &io->fsync_queue); io->fsync_qlen++; if (waitqueue_active(&io->fsync_waitq)) wake_up_interruptible(&io->fsync_waitq);}
开发者ID:cloudlinuxadmin,项目名称:cl7-kernel,代码行数:15,
示例23: btrfs_tree_unlockint btrfs_tree_unlock(struct extent_buffer *eb){ /* * if we were a blocking owner, we don't have the spinlock held * just clear the bit and look for waiters */ if (test_and_clear_bit(EXTENT_BUFFER_BLOCKING, &eb->bflags)) smp_mb__after_clear_bit(); else spin_unlock(&eb->lock); if (waitqueue_active(&eb->lock_wq)) wake_up(&eb->lock_wq); return 0;}
开发者ID:458941968,项目名称:mini2440-kernel-2.6.29,代码行数:15,
示例24: kmalloc_mali_osk_wait_queue_t *_mali_osk_wait_queue_init(void){ _mali_osk_wait_queue_t *ret = NULL; ret = kmalloc(sizeof(_mali_osk_wait_queue_t), GFP_KERNEL); if (NULL == ret) { return ret; } init_waitqueue_head(&ret->wait_queue); MALI_DEBUG_ASSERT(!waitqueue_active(&ret->wait_queue)); return ret;}
开发者ID:AOSC-Dev,项目名称:aosc-os-armel-sunxi-boot,代码行数:15,
示例25: aml_demod_isrstatic irqreturn_t aml_demod_isr(int irq, void *dev_id){ if (demod_sta.dvb_mode == 0) { //dvbc_isr(&demod_sta); if(dvbc_isr_islock()){ printk("sync4/n"); if(waitqueue_active(&lock_wq)) wake_up_interruptible(&lock_wq); } } else { dvbt_isr(&demod_sta); } return IRQ_HANDLED;}
开发者ID:xbai043,项目名称:zt280-kernel,代码行数:16,
示例26: eventfd_writestatic ssize_t eventfd_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos){ struct eventfd_ctx *ctx = file->private_data; ssize_t res; __u64 ucnt; DECLARE_WAITQUEUE(wait, current); if (count < sizeof(ucnt)) return -EINVAL; if (copy_from_user(&ucnt, buf, sizeof(ucnt))) return -EFAULT; if (ucnt == ULLONG_MAX) return -EINVAL; spin_lock_irq(&ctx->wqh.lock); res = -EAGAIN; if (ULLONG_MAX - ctx->count > ucnt) res = sizeof(ucnt); else if (!(file->f_flags & O_NONBLOCK)) { __add_wait_queue(&ctx->wqh, &wait); for (res = 0;;) { set_current_state(TASK_INTERRUPTIBLE); if (ULLONG_MAX - ctx->count > ucnt) { res = sizeof(ucnt); break; } if (signal_pending(current)) { res = -ERESTARTSYS; break; } spin_unlock_irq(&ctx->wqh.lock); schedule(); spin_lock_irq(&ctx->wqh.lock); } __remove_wait_queue(&ctx->wqh, &wait); __set_current_state(TASK_RUNNING); } if (likely(res > 0)) { ctx->count += ucnt; if (waitqueue_active(&ctx->wqh)) wake_up_locked_poll(&ctx->wqh, POLLIN); } spin_unlock_irq(&ctx->wqh.lock); return res;}
开发者ID:kenkit,项目名称:AndromadusMod-New,代码行数:46,
示例27: ext4_free_io_endvoid ext4_free_io_end(ext4_io_end_t *io){ int i; wait_queue_head_t *wq; BUG_ON(!io); if (io->page) put_page(io->page); for (i = 0; i < io->num_io_pages; i++) put_io_page(io->pages[i]); io->num_io_pages = 0; wq = ext4_ioend_wq(io->inode); if (atomic_dec_and_test(&EXT4_I(io->inode)->i_ioend_count) && waitqueue_active(wq)) wake_up_all(wq); kmem_cache_free(io_end_cachep, io);}
开发者ID:CSCLOG,项目名称:beaglebone,代码行数:17,
示例28: eventfd_readstatic ssize_t eventfd_read(struct file *file, char __user *buf, size_t count, loff_t *ppos){ struct eventfd_ctx *ctx = file->private_data; ssize_t res; __u64 ucnt; DECLARE_WAITQUEUE(wait, current); if (count < sizeof(ucnt)) return -EINVAL; spin_lock_irq(&ctx->wqh.lock); res = -EAGAIN; ucnt = ctx->count; if (ucnt > 0) res = sizeof(ucnt); else if (!(file->f_flags & O_NONBLOCK)) { __add_wait_queue(&ctx->wqh, &wait); for (res = 0;;) { set_current_state(TASK_INTERRUPTIBLE); if (ctx->count > 0) { ucnt = ctx->count; res = sizeof(ucnt); break; } if (signal_pending(current)) { res = -ERESTARTSYS; break; } spin_unlock_irq(&ctx->wqh.lock); schedule(); spin_lock_irq(&ctx->wqh.lock); } __remove_wait_queue(&ctx->wqh, &wait); __set_current_state(TASK_RUNNING); } if (res > 0) { ctx->count = 0; if (waitqueue_active(&ctx->wqh)) wake_up_locked(&ctx->wqh); } spin_unlock_irq(&ctx->wqh.lock); if (res > 0 && put_user(ucnt, (__u64 __user *) buf)) return -EFAULT; return res;}
开发者ID:LouZiffer,项目名称:m900_kernel_cupcake-SDX,代码行数:46,
注:本文中的waitqueue_active函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ wake函数代码示例 C++ waitpid函数代码示例 |