• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ sleep_on函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中sleep_on函数的典型用法代码示例。如果您正苦于以下问题:C++ sleep_on函数的具体用法?C++ sleep_on怎么用?C++ sleep_on使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了sleep_on函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: falcon_get_lock

static void falcon_get_lock( void )
{
	unsigned long flags;

	if (IS_A_TT()) return;

	local_irq_save(flags);

	while( !in_interrupt() && falcon_got_lock && stdma_others_waiting() )
		sleep_on( &falcon_fairness_wait );

	while (!falcon_got_lock) {
		if (in_interrupt())
			panic( "Falcon SCSI hasn't ST-DMA lock in interrupt" );
		if (!falcon_trying_lock) {
			falcon_trying_lock = 1;
			stdma_lock(scsi_falcon_intr, NULL);
			falcon_got_lock = 1;
			falcon_trying_lock = 0;
			wake_up( &falcon_try_wait );
		}
		else {
			sleep_on( &falcon_try_wait );
		}
	}	

	local_irq_restore(flags);
	if (!falcon_got_lock)
		panic("Falcon SCSI: someone stole the lock :-(\n");
}
开发者ID:BackupTheBerlios,项目名称:tuxap,代码行数:30,代码来源:atari_scsi.c


示例2: falcon_get_lock

static void falcon_get_lock( void )
{
	unsigned long	oldflags;

	if (IS_A_TT()) return;

	save_flags(oldflags);
	cli();

	while( intr_count == 0 && falcon_got_lock && stdma_others_waiting() )
		sleep_on( &falcon_fairness_wait );

	while (!falcon_got_lock) {
		if (intr_count > 0)
			panic( "Falcon SCSI hasn't ST-DMA lock in interrupt" );
		if (!falcon_trying_lock) {
			falcon_trying_lock = 1;
			stdma_lock(scsi_falcon_intr, NULL);
			falcon_got_lock = 1;
			falcon_trying_lock = 0;
			wake_up( &falcon_try_wait );
		}
		else {
			sleep_on( &falcon_try_wait );
		}
	}	

	restore_flags(oldflags);
	if (!falcon_got_lock)
		panic("Falcon SCSI: someone stole the lock :-(\n");
}
开发者ID:liexusong,项目名称:linux2.0-comment,代码行数:31,代码来源:atari_scsi.c


示例3: sleep_on

// Look through buffer cache for the nblk-th sector on device dev
// If not found, allocate a fresh block.
// In either case, return BUF_BUSY buffer
struct buf *getblk(uint32_t dev, uint32_t nblk)
{
	struct buf *bp;

repeat:
	for(bp = bhead.next; bp != &bhead; bp = bp->next){
		if(bp->dev == dev && bp->num == nblk){
			if((bp->flags & BUF_BUSY) == 0){
				bp->flags |= BUF_BUSY;
				return bp;
			}
			sleep_on(&bp->bwait);
			goto repeat;
		}
	}

	// block not cached yet
	for(bp = bhead.prev; bp != &bhead; bp = bp->prev){
		if((bp->flags & (BUF_BUSY | BUF_DIRTY)) == 0){
			bp->flags = BUF_BUSY;
			bp->dev = dev;
			bp->num = nblk;
			return bp;
		}
	}

	// no cache available
	panic("getblk: no buffers available");
}
开发者ID:chunis,项目名称:chunix,代码行数:32,代码来源:buffer.c


示例4: ar7100fr_ioctl

static int
ar7100fr_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
		unsigned long arg)
{
	int ret = 0;

	switch(cmd) {
		case AR7100_FACTORY_RESET:
            
			/* Userspace process "factoryreset" is doing IOCTL
 			 * Hope AP is successfully UP
 			 * Turn the power LED on
 			 */
#ifdef CONFIG_AR9100
#define AP8x_GPIO_POWER_LED  (0x01 << 14) 
 			ar7100_reg_wr(AR7100_GPIO_OE, AP8x_GPIO_POWER_LED);
			ar7100_reg_wr(AR7100_GPIO_OUT,
	          ((ar7100_reg_rd(AR7100_GPIO_OUT)) | ((AP8x_GPIO_POWER_LED))));
#endif

            atomic_inc(&ar7100_fr_status);
			sleep_on(&ar7100_fr_wq);
			break;

		default: ret = -EINVAL;
	}

	return ret;
}
开发者ID:Wolfgart,项目名称:SDK.UBNT.v5.5,代码行数:29,代码来源:gpio.c


示例5: wait_on_buffer

static void wait_on_buffer(struct buffer_head *bh)
{
    disable_int();
    while(bh->b_lock)
        sleep_on(&bh->b_wait);
    enable_int();
}
开发者ID:monomaniar,项目名称:prettyos,代码行数:7,代码来源:buffer.c


示例6: sys_doevent_wait

asmlinkage long sys_doevent_wait(long event_id)
{
	/*lock global lock*/

	event_t * event = find_event_by_id(event_id);		/*find event by event id*/
	if(event==NULL)
	{
		/*unlock global lock*/
		return -1;
	}
	event->count++;										/*increase the num of process using the event*/

	/*unlock global lock*/

	/*lock event lock*/

	if(event->invalid)									/*if already close*/
	{
		if(event->count==1)								/*if last one of use*/
			kfree(event);
		count--;										/*after use of the event*/
		return -1;
	}
	sleep_on(&event->Q);								/*sleep on event*/
	event->count--;										/*after use of the event*/

	/*unlock event lock*/
	
	return 0;
}
开发者ID:qiuqiyuan,项目名称:CS2456,代码行数:30,代码来源:sys_doevent_open.c


示例7: ar7240wdt_ioctl

static int
ar7240wdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
		unsigned long arg)
{
	int ret = 0;

	wddbg("%s: called\n", __func__);

	switch(cmd) {
		case FACTORY_RESET:
			wddbg("%s: intr action\n", __func__);
#ifndef CONFIG_MACH_HORNET
			if ((ret = request_irq(
					AR7240_MISC_IRQ_WATCHDOG,
					ar7240_wdt_isr,
					0,
					"Watchdog Timer",
					wdt))) {
				wddbg("%s: request_irq %d\n", __func__, ret);
				return ret;
			}

			ar7240_set_wd_timer_action(AR7240_WD_ACT_GP_INTR);
			sleep_on(&wdt->wq);
			free_irq(AR7240_MISC_IRQ_WATCHDOG, wdt);
#endif
			break;

		default: ret = -EINVAL;
	}

	return ret;
}
开发者ID:Wolfgart,项目名称:SDK.UBNT.v5.5,代码行数:33,代码来源:wdt.c


示例8: wait_on_buffer

//// 等待指定缓冲区解锁。
static _inline void wait_on_buffer(struct buffer_head * bh)
{
	cli();		// 关中断。
	while (bh->b_lock)	// 如果已被上锁,则进程进入睡眠,等待其解锁。
		sleep_on(&bh->b_wait);
	sti();		// 开中断。
}
开发者ID:0x1abin,项目名称:linux0.11,代码行数:8,代码来源:buffer.c


示例9: sleep_on1

void
sleep_on1(void *p)
{
    cli();
    sleep_on(p);
    sti();
}
开发者ID:leadingtheway,项目名称:Jix,代码行数:7,代码来源:proc.c


示例10: put_last_lru

static struct buffer_head *get_free_buffer(void)
{
    register struct buffer_head *bh;

    for (;;) {
	bh = bh_lru;
	do {
#ifdef CONFIG_FS_EXTERNAL_BUFFER
	    if (bh->b_count == 0 && !bh->b_dirty && !bh->b_lock && !bh->b_data)
#else
	    if (bh->b_count == 0 && !bh->b_dirty && !bh->b_lock)
#endif
	    {
		put_last_lru(bh);
		return bh;
	    }
	} while((bh = bh->b_next_lru) != NULL);
#if 0
	fsync_dev(0);
	/* This causes a sleep until another process brelse's */
	sleep_on(&bufwait);
#endif
	sync_buffers(0, 0);
    }
}
开发者ID:foolsh,项目名称:elks,代码行数:25,代码来源:buffer.c


示例11: reiserfs_rename

int	reiserfs_rename (
			 struct inode * old_dir, struct dentry *old_dentry,
			 struct inode * new_dir, struct dentry *new_dentry
			 )
{
  static struct wait_queue * wait = NULL;
  static int lock = 0;
  int result;
  int windex ;
  struct reiserfs_transaction_handle th ;
  int jbegin_count = JOURNAL_PER_BALANCE_CNT * 3; 
  
  while (lock)
    sleep_on(&wait);
  lock = 1;
  journal_begin(&th, old_dir->i_sb, jbegin_count) ;
  windex = push_journal_writer("reiesrfs_rename") ;
  /* we are trusting if_in_ram_update_sd to update the transaction 
  ** info in each inode as they get chagned
  */
  result = do_reiserfs_rename (&th, old_dir, old_dentry, new_dir, new_dentry);
  pop_journal_writer(windex) ;
  journal_end(&th, old_dir->i_sb, jbegin_count) ;
  lock = 0;
  wake_up(&wait);
  return result;
}
开发者ID:chinnyannieb,项目名称:empeg-hijack,代码行数:27,代码来源:namei.c


示例12: rw_abs_hd

void rw_abs_hd(int rw, unsigned int nr, unsigned int sec, unsigned int head,
	       unsigned int cyl, struct buffer_head * bh)
{
    struct hd_request * req;

    if (rw != READ && rw != WRITE)
	panic("Bad hd command, must be R/W");
    lock_buffer(bh);
 repeat:
    for (req = 0 + request; req < NR_REQUEST + request; req++)
	if (req->hd < 0)
	    break;
    if (req == NR_REQUEST + request) {
	sleep_on(&wait_for_request);
	goto repeat;
    }
    req->hd = nr;
    req->nsector = 2;
    req->sector = sec;
    req->head = head;
    req->cyl = cyl;
    req->cmd = ((rw == READ) ? WIN_READ : WIN_WRITE);
    req->bh = bh;
    req->errors = 0;
    req->next = NULL;
    add_request(req);
    wait_on_buffer(bh);
}
开发者ID:trbhoang,项目名称:Vinix,代码行数:28,代码来源:hd.c


示例13: write_pipe

uint32_t write_pipe(fs_node_t *node, uint32_t offset, uint32_t size, uint8_t *buffer) {
	assert(node->device != 0 && "Attempted to write to a fully-closed pipe.");

	/* Retreive the pipe object associated with this file node */
	pipe_device_t * pipe = (pipe_device_t *)node->device;

#if DEBUG_PIPES
	if (pipe->size > 300) { /* Ignore small pipes (ie, keyboard) */
		debug_print(INFO, "[debug] Call to write to pipe 0x%x", node->device);
		debug_print(INFO, "        Available space: %d", pipe_available(pipe));
		debug_print(INFO, "        Total size:      %d", pipe->size);
		debug_print(INFO, "        Request size:    %d", size);
		debug_print(INFO, "        Write pointer:   %d", pipe->write_ptr);
		debug_print(INFO, "        Read  pointer:   %d", pipe->read_ptr);
		debug_print(INFO, "        Buffer address:  0x%x", pipe->buffer);
		debug_print(INFO, " Write: %s", buffer);
	}
#endif

	if (pipe->dead) {
		debug_print(WARNING, "Pipe is dead?");
		send_signal(getpid(), SIGPIPE);
		return 0;
	}

	size_t written = 0;
	while (written < size) {
		spin_lock(pipe->lock_write);

#if 0
		size_t available = 0;
		if (pipe->read_ptr <= pipe->write_ptr) {
			available = pipe->size - pipe->write_ptr;
		} else {
			available = pipe->read_ptr - pipe->write_ptr - 1;
		}
		if (available) {
			available = min(available, size - written);
			memcpy(&pipe->buffer[pipe->write_ptr], buffer, available);
			pipe_increment_write_by(pipe, available);
			written += available;
		}
#else
		while (pipe_available(pipe) > 0 && written < size) {
			pipe->buffer[pipe->write_ptr] = buffer[written];
			pipe_increment_write(pipe);
			written++;
		}
#endif

		spin_unlock(pipe->lock_write);
		wakeup_queue(pipe->wait_queue_readers);
		pipe_alert_waiters(pipe);
		if (written < size) {
			sleep_on(pipe->wait_queue_writers);
		}
	}

	return written;
}
开发者ID:klange,项目名称:ponyos,代码行数:60,代码来源:pipe.c


示例14: journal_sync_buffer

void journal_sync_buffer(struct buffer_head *bh)
{
	transaction_t *transaction;
	journal_t *journal;
	long sequence;
	
	/* If the buffer isn't journaled, this is easy: just sync it to
	 * disk.  */

	if (bh->b_transaction == NULL) {
		/* If the buffer has already been journaled, then this
		 * is a noop. */
		if (bh->b_cp_transaction == NULL) 
			return;
		ll_rw_block (WRITE, 1, &bh);
		wait_on_buffer (bh);
		return;
	}
	
	/* Otherwise, just wait until the transaction is synced to disk. */
	transaction = bh->b_transaction;
	journal = transaction->t_journal;
	sequence = transaction->t_tid;
	
	jfs_debug(2, "requesting commit for bh %p\n", bh);
	log_start_commit (journal, transaction);
	
	while (tid_gt(sequence, journal->j_commit_sequence)) {
		wake_up(&journal->j_wait_done_commit);
		sleep_on(&journal->j_wait_done_commit);
	}
}
开发者ID:chinnyannieb,项目名称:empeg-hijack,代码行数:32,代码来源:transaction.c


示例15: locks_delete_lock

static void locks_delete_lock(struct file_lock **fl_p, unsigned int wait)
{
	struct file_lock *fl;
	struct file_lock *pfl;
	struct file_lock *nfl;
	
	fl = *fl_p;
	*fl_p = fl->fl_next;
	pfl = fl->fl_prevlink;
	nfl = fl->fl_nextlink;

	if (nfl != NULL)
		nfl->fl_prevlink = pfl;

	if (pfl != NULL)
		pfl->fl_nextlink = nfl;
	else
		file_lock_table = nfl;
	
	while ((nfl = fl->fl_block) != NULL) {
		fl->fl_block = nfl->fl_block;
		nfl->fl_block = NULL;
		wake_up(&nfl->fl_wait);
		if (wait)
			sleep_on(&nfl->fl_wait);
	}

	wake_up(&fl->fl_wait);
	kfree(fl);

	return;
}
开发者ID:liexusong,项目名称:linux2.0-comment,代码行数:32,代码来源:locks.c


示例16: write_pipe

int write_pipe(struct m_inode * inode, char * buf, int count)
{
	char * b=buf;

	wake_up(&inode->i_wait);
	if (inode->i_count != 2) { /* no readers */
		current->signal |= (1<<(SIGPIPE-1));
		return -1;
	}
	while (count-->0) {
		while (PIPE_FULL(*inode)) {
			wake_up(&inode->i_wait);
			if (inode->i_count != 2) {
				current->signal |= (1<<(SIGPIPE-1));
				return b-buf;
			}
			sleep_on(&inode->i_wait);
		}
		((char *)inode->i_size)[PIPE_HEAD(*inode)] = get_fs_byte(b++);
		INC_PIPE( PIPE_HEAD(*inode) );
		wake_up(&inode->i_wait);
	}
	wake_up(&inode->i_wait);
	return b-buf;
}
开发者ID:AditGhildiyal8,项目名称:linux-0.0.1,代码行数:25,代码来源:pipe.c


示例17: wait_on_buffer

static inline void wait_on_buffer(struct buffer_head * bh)
{
	cli();
	while (bh->b_lock)
		sleep_on(&bh->b_wait);
	sti();
}
开发者ID:hnlq715,项目名称:kernel-001,代码行数:7,代码来源:buffer.c


示例18: write_pipe

int write_pipe(struct m_inode * inode, char * buf, int count)
{
	int chars, size, written = 0;

	while (count>0) {
		while (!(size=(PAGE_SIZE-1)-PIPE_SIZE(*inode))) {
			wake_up(&inode->i_wait);
			if (inode->i_count != 2) { /* no readers */
				current->signal |= (1<<(SIGPIPE-1));
				return written?written:-1;
			}
			sleep_on(&inode->i_wait);
		}
		chars = PAGE_SIZE-PIPE_HEAD(*inode);
		if (chars > count)
			chars = count;
		if (chars > size)
			chars = size;
		count -= chars;
		written += chars;
		size = PIPE_HEAD(*inode);
		PIPE_HEAD(*inode) += chars;
		PIPE_HEAD(*inode) &= (PAGE_SIZE-1);
		while (chars-->0)
			((char *)inode->i_size)[size++]=get_fs_byte(buf++);
	}
	wake_up(&inode->i_wait);
	return written;
}
开发者ID:AmosZ,项目名称:OS,代码行数:29,代码来源:pipe.c


示例19: read_pipe

int read_pipe(struct m_inode * inode, char * buf, int count)
{
	int chars, size, read = 0;

	while (count>0) {
		while (!(size=PIPE_SIZE(*inode))) {
			wake_up(&inode->i_wait);
			if (inode->i_count != 2) /* are there any writers? */
				return read;
			sleep_on(&inode->i_wait);
		}
		chars = PAGE_SIZE-PIPE_TAIL(*inode);
		if (chars > count)
			chars = count;
		if (chars > size)
			chars = size;
		count -= chars;
		read += chars;
		size = PIPE_TAIL(*inode);
		PIPE_TAIL(*inode) += chars;
		PIPE_TAIL(*inode) &= (PAGE_SIZE-1);
		while (chars-->0)
			put_fs_byte(((char *)inode->i_size)[size++],buf++);
	}
	wake_up(&inode->i_wait);
	return read;
}
开发者ID:AmosZ,项目名称:OS,代码行数:27,代码来源:pipe.c


示例20: flush_write_buffer

/* Flush the write buffer */
static int flush_write_buffer(int dev)
{
  int offset, transfer, blks;
  int result;
  unsigned char cmd[10];
  Scsi_Cmnd *SCpnt;

#if ST_WRITE_THRESHOLD_BLOCKS < ST_BUFFER_BLOCKS
  if (scsi_tapes[dev].buffer->writing) {
    write_behind_check(dev);
    if (scsi_tapes[dev].buffer->last_result) {
#ifdef DEBUG
      printk("st%d: Async write error %x.\n", dev,
	     scsi_tapes[dev].buffer->last_result);
#endif
      return (-EIO);
    }
  }
#endif

  result = 0;
  if (scsi_tapes[dev].dirty==1) {
    SCpnt = allocate_device(NULL, scsi_tapes[dev].device->index, 1);

    offset = scsi_tapes[dev].buffer->buffer_bytes;
    transfer = ((offset + scsi_tapes[dev].block_size - 1) /
		scsi_tapes[dev].block_size) * scsi_tapes[dev].block_size;
#ifdef DEBUG
    printk("st%d: Flushing %d bytes.\n", dev, transfer);
#endif
    memset(scsi_tapes[dev].buffer->b_data + offset, 0, transfer - offset);

    SCpnt->sense_buffer[0] = 0;
    memset(cmd, 0, 10);
    cmd[0] = WRITE_6;
    cmd[1] = 1;
    blks = transfer / scsi_tapes[dev].block_size;
    cmd[2] = blks >> 16;
    cmd[3] = blks >> 8;
    cmd[4] = blks;
    SCpnt->request.dev = dev;
    scsi_do_cmd (SCpnt,
		 (void *) cmd, scsi_tapes[dev].buffer->b_data, transfer,
		 st_sleep_done, ST_TIMEOUT, MAX_RETRIES);

    if (SCpnt->request.dev == dev) sleep_on( &scsi_tapes[dev].waiting );

    if (SCpnt->result != 0) {
      printk("st%d: Error on flush:\n", dev);
#ifdef DEBUG
      st_chk_result(dev, SCpnt->result, SCpnt->sense_buffer);
#endif
      result = (-EIO);
    }
    else {
      scsi_tapes[dev].dirty = 0;
      scsi_tapes[dev].buffer->buffer_bytes = 0;
    }
    SCpnt->request.dev = -1;  /* Mark as not busy */
  }
开发者ID:LambdaCalculus379,项目名称:SLS-1.02,代码行数:61,代码来源:st.c



注:本文中的sleep_on函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ sleep_seconds函数代码示例发布时间:2022-05-30
下一篇:
C++ sleep_ms函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap