本文整理汇总了C++中sleep_on函数的典型用法代码示例。如果您正苦于以下问题:C++ sleep_on函数的具体用法?C++ sleep_on怎么用?C++ sleep_on使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sleep_on函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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");
}
示例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");
}
示例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");
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}
示例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(); // 开中断。
}
示例9: sleep_on1
void
sleep_on1(void *p)
{
cli();
sleep_on(p);
sti();
}
示例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);
}
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
}
示例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;
}