这篇教程C++ wakeup函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中wakeup函数的典型用法代码示例。如果您正苦于以下问题:C++ wakeup函数的具体用法?C++ wakeup怎么用?C++ wakeup使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了wakeup函数的23个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: doexitvoid doexit(uint16_t val){ int16_t j; ptptr p; irqflags_t irq;#ifdef DEBUG kprintf("process %d exiting %d/n", udata.u_ptab->p_pid, val); kprintf ("udata.u_page %u, udata.u_ptab %p, udata.u_ptab->p_page %u/n", udata.u_page, udata.u_ptab, udata.u_ptab->p_page);#endif if (udata.u_ptab->p_pid == 1) panic(PANIC_KILLED_INIT); sync(); /* Not necessary, but a good idea. */ irq = di(); /* We are exiting, hold all signals (they will never be delivered). If we don't do this we might take a signal while exiting which would be ... unfortunate */ udata.u_ptab->p_held = 0xFFFFFFFFUL; udata.u_cursig = 0; /* Discard our memory before we blow away and reuse the memory */ pagemap_free(udata.u_ptab); for (j = 0; j < UFTSIZE; ++j) { if (udata.u_files[j] != NO_FILE) doclose(j); } udata.u_ptab->p_exitval = val; i_deref(udata.u_cwd); i_deref(udata.u_root); /* Stash away child's execution tick counts in process table, * overlaying some no longer necessary stuff. * * Pedantically POSIX says we should do this at the point of wait() */ udata.u_utime += udata.u_cutime; udata.u_stime += udata.u_cstime; memcpy(&(udata.u_ptab->p_priority), &udata.u_utime, 2 * sizeof(clock_t)); for (p = ptab; p < ptab_end; ++p) { if (p->p_status == P_EMPTY || p == udata.u_ptab) continue; /* Set any child's parents to init */ if (p->p_pptr == udata.u_ptab) { p->p_pptr = ptab; /* ptab is always init */ /* Suppose our child is a zombie and init has SIGCLD blocked */ if (ptab[0].p_ignored & (1UL << SIGCHLD)) { p->p_status = P_EMPTY; } else { ssig(&ptab[0], SIGCHLD); wakeup(&ptab[0]); } } /* Send SIGHUP to any pgrp members and remove them from our pgrp */ if (p->p_pgrp == udata.u_ptab->p_pid) { p->p_pgrp = 0; ssig(p, SIGHUP); ssig(p, SIGCONT); } } tty_exit(); irqrestore(irq);#ifdef DEBUG kprintf ("udata.u_page %u, udata.u_ptab %p, udata.u_ptab->p_page %u/n", udata.u_page, udata.u_ptab, udata.u_ptab->p_page);#endif#ifdef CONFIG_ACCT acctexit(p);#endif udata.u_page = 0xFFFFU; udata.u_page2 = 0xFFFFU; signal_parent(udata.u_ptab->p_pptr); nready--; nproc--; switchin(getproc()); panic(PANIC_DOEXIT);}
开发者ID:willsowerbutts,项目名称:FUZIX,代码行数:92,
示例2: statusBarvoid QtTrader::statusMessage (QString d){ // update the status bar with a new message from somewhere statusBar()->showMessage(d, 0); wakeup();}
开发者ID:WeizhongDai,项目名称:qttrader,代码行数:6,
示例3: tegra_i2c_intrstatic voidtegra_i2c_intr(void *arg){ struct tegra_i2c_softc *sc; uint32_t status, reg; int rv; sc = (struct tegra_i2c_softc *)arg; LOCK(sc); status = RD4(sc, I2C_INTERRUPT_SOURCE_REGISTER); if (sc->msg == NULL) { /* Unexpected interrupt - disable FIFOs, clear reset. */ reg = RD4(sc, I2C_INTERRUPT_MASK_REGISTER); reg &= ~I2C_INT_TFIFO_DATA_REQ; reg &= ~I2C_INT_RFIFO_DATA_REQ; WR4(sc, I2C_INTERRUPT_MASK_REGISTER, 0); WR4(sc, I2C_INTERRUPT_STATUS_REGISTER, status); UNLOCK(sc); return; } if ((status & I2C_ERROR_MASK) != 0) { if (status & I2C_INT_NOACK) sc->bus_err = IIC_ENOACK; if (status & I2C_INT_ARB_LOST) sc->bus_err = IIC_EBUSERR; if ((status & I2C_INT_TFIFO_OVR) || (status & I2C_INT_RFIFO_UNF)) sc->bus_err = IIC_EBUSERR; sc->done = 1; } else if ((status & I2C_INT_RFIFO_DATA_REQ) && (sc->msg != NULL) && (sc->msg->flags & IIC_M_RD)) { rv = tegra_i2c_rx(sc); if (rv == 0) { reg = RD4(sc, I2C_INTERRUPT_MASK_REGISTER); reg &= ~I2C_INT_RFIFO_DATA_REQ; WR4(sc, I2C_INTERRUPT_MASK_REGISTER, reg); } } else if ((status & I2C_INT_TFIFO_DATA_REQ) && (sc->msg != NULL) && !(sc->msg->flags & IIC_M_RD)) { rv = tegra_i2c_tx(sc); if (rv == 0) { reg = RD4(sc, I2C_INTERRUPT_MASK_REGISTER); reg &= ~I2C_INT_TFIFO_DATA_REQ; WR4(sc, I2C_INTERRUPT_MASK_REGISTER, reg); } } else if ((status & I2C_INT_RFIFO_DATA_REQ) || (status & I2C_INT_TFIFO_DATA_REQ)) { device_printf(sc->dev, "Unexpected data interrupt: 0x%08X/n", status); reg = RD4(sc, I2C_INTERRUPT_MASK_REGISTER); reg &= ~I2C_INT_TFIFO_DATA_REQ; reg &= ~I2C_INT_RFIFO_DATA_REQ; WR4(sc, I2C_INTERRUPT_MASK_REGISTER, reg); } if (status & I2C_INT_PACKET_XFER_COMPLETE) sc->done = 1; WR4(sc, I2C_INTERRUPT_STATUS_REGISTER, status); if (sc->done) { WR4(sc, I2C_INTERRUPT_MASK_REGISTER, 0); wakeup(&(sc->done)); } UNLOCK(sc);}
开发者ID:nanakom,项目名称:freebsd,代码行数:65,
示例4: crlintrvoidcrlintr(void *arg){ struct buf *bp; int i; bp = crltab.crl_buf; i = mfpr(PR_STXCS); switch ((i>>24) & 0xFF) { case CRL_S_XCMPLT: switch (crltab.crl_active) { case CRL_F_RETSTS: { char sbuf[256], sbuf2[256]; crlstat.crl_ds = mfpr(PR_STXDB); snprintb(sbuf, sizeof(sbuf), CRLCS_BITS, crlstat.crl_cs); snprintb(sbuf2, sizeof(sbuf2), CRLDS_BITS, crlstat.crl_ds); printf("crlcs=0x%s, crlds=0x%s/n", sbuf, sbuf2); break; } case CRL_F_READ: case CRL_F_WRITE: bp->b_oflags |= BO_DONE; } crltab.crl_active = 0; wakeup(bp); break; case CRL_S_XCONT: switch (crltab.crl_active) { case CRL_F_WRITE: mtpr(*crltab.crl_xaddr++, PR_STXDB); mtpr(bp->b_blkno<<8 | STXCS_IE | CRL_F_WRITE, PR_STXCS); break; case CRL_F_READ: *crltab.crl_xaddr++ = mfpr(PR_STXDB); mtpr(bp->b_blkno<<8 | STXCS_IE | CRL_F_READ, PR_STXCS); } break; case CRL_S_ABORT: crltab.crl_active = CRL_F_RETSTS; mtpr(STXCS_IE | CRL_F_RETSTS, PR_STXCS); bp->b_oflags |= BO_DONE; bp->b_error = EIO; break; case CRL_S_RETSTS: crlstat.crl_cs = mfpr(PR_STXDB); mtpr(STXCS_IE | CRL_S_RETSTS, PR_STXCS); break; case CRL_S_HNDSHK: printf("crl: hndshk error/n"); /* dump out some status too? */ crltab.crl_active = 0; bp->b_oflags |= BO_DONE; bp->b_error = EIO; cv_broadcast(&bp->b_done); break; case CRL_S_HWERR: printf("crl: hard error sn%" PRId64 "/n", bp->b_blkno); crltab.crl_active = CRL_F_ABORT; mtpr(STXCS_IE | CRL_F_ABORT, PR_STXCS); break; }}
开发者ID:ryo,项目名称:netbsd-src,代码行数:76,
示例5: ptstartstatic voidptstart(struct cam_periph *periph, union ccb *start_ccb){ struct pt_softc *softc; struct buf *bp; int s; softc = (struct pt_softc *)periph->softc; /* * See if there is a buf with work for us to do.. */ s = splbio(); bp = bufq_first(&softc->buf_queue); if (periph->immediate_priority <= periph->pinfo.priority) { CAM_DEBUG_PRINT(CAM_DEBUG_SUBTRACE, ("queuing for immediate ccb/n")); start_ccb->ccb_h.ccb_state = PT_CCB_WAITING; SLIST_INSERT_HEAD(&periph->ccb_list, &start_ccb->ccb_h, periph_links.sle); periph->immediate_priority = CAM_PRIORITY_NONE; splx(s); wakeup(&periph->ccb_list); } else if (bp == NULL) { splx(s); xpt_release_ccb(start_ccb); } else { int oldspl; bufq_remove(&softc->buf_queue, bp); devstat_start_transaction(&softc->device_stats); scsi_send_receive(&start_ccb->csio, /*retries*/4, ptdone, MSG_SIMPLE_Q_TAG, bp->b_flags & B_READ, /*byte2*/0, bp->b_bcount, bp->b_data, /*sense_len*/SSD_FULL_SIZE, /*timeout*/softc->io_timeout); start_ccb->ccb_h.ccb_state = PT_CCB_BUFFER_IO; /* * Block out any asyncronous callbacks * while we touch the pending ccb list. */ oldspl = splcam(); LIST_INSERT_HEAD(&softc->pending_ccbs, &start_ccb->ccb_h, periph_links.le); splx(oldspl); start_ccb->ccb_h.ccb_bp = bp; bp = bufq_first(&softc->buf_queue); splx(s); xpt_action(start_ccb); if (bp != NULL) { /* Have more work to do, so ensure we stay scheduled */ xpt_schedule(periph, /* XXX priority */1); } }}
开发者ID:UnitedMarsupials,项目名称:kame,代码行数:67,
示例6: alq_getn/* * Retrieve a pointer for the ALQ to write directly into, avoiding bcopy. */struct ale *alq_getn(struct alq *alq, int len, int flags){ int contigbytes; void *waitchan; KASSERT((len > 0 && len <= alq->aq_buflen), ("%s: len <= 0 || len > alq->aq_buflen", __func__)); waitchan = NULL; ALQ_LOCK(alq); /* * Determine the number of free contiguous bytes. * We ensure elsewhere that if aq_writehead == aq_writetail because * the buffer is empty, they will both be set to 0 and therefore * aq_freebytes == aq_buflen and is fully contiguous. * If they are equal and the buffer is not empty, aq_freebytes will * be 0 indicating the buffer is full. */ if (alq->aq_writehead <= alq->aq_writetail) contigbytes = alq->aq_freebytes; else { contigbytes = alq->aq_buflen - alq->aq_writehead; if (contigbytes < len) { /* * Insufficient space at end of buffer to handle a * contiguous write. Wrap early if there's space at * the beginning. This will leave a hole at the end * of the buffer which we will have to skip over when * flushing the buffer to disk. */ if (alq->aq_writetail >= len || flags & ALQ_WAITOK) { /* Keep track of # bytes left blank. */ alq->aq_wrapearly = contigbytes; /* Do the wrap and adjust counters. */ contigbytes = alq->aq_freebytes = alq->aq_writetail; alq->aq_writehead = 0; } } } /* * Return a NULL ALE if: * - The message is larger than our underlying buffer. * - The ALQ is being shutdown. * - There is insufficient free space in our underlying buffer * to accept the message and the user can't wait for space. * - There is insufficient free space in our underlying buffer * to accept the message and the alq is inactive due to prior * use of the ALQ_NOACTIVATE flag (which would lead to deadlock). */ if (len > alq->aq_buflen || alq->aq_flags & AQ_SHUTDOWN || (((flags & ALQ_NOWAIT) || (!(alq->aq_flags & AQ_ACTIVE) && HAS_PENDING_DATA(alq))) && contigbytes < len)) { ALQ_UNLOCK(alq); return (NULL); } /* * If we want ordered writes and there is already at least one thread * waiting for resources to become available, sleep until we're woken. */ if (alq->aq_flags & AQ_ORDERED && alq->aq_waiters > 0) { KASSERT(!(flags & ALQ_NOWAIT), ("%s: ALQ_NOWAIT set but incorrectly ignored!", __func__)); alq->aq_waiters++; msleep_spin(&alq->aq_waiters, &alq->aq_mtx, "alqgnord", 0); alq->aq_waiters--; } /* * (ALQ_WAITOK && contigbytes < len) or contigbytes >= len, either enter * while loop and sleep until we have enough contiguous free bytes * (former) or skip (latter). If AQ_ORDERED is set, only 1 thread at a * time will be in this loop. Otherwise, multiple threads may be * sleeping here competing for ALQ resources. */ while (contigbytes < len && !(alq->aq_flags & AQ_SHUTDOWN)) { KASSERT(!(flags & ALQ_NOWAIT), ("%s: ALQ_NOWAIT set but incorrectly ignored!", __func__)); alq->aq_flags |= AQ_WANTED; alq->aq_waiters++; if (waitchan) wakeup(waitchan); msleep_spin(alq, &alq->aq_mtx, "alqgnres", 0); alq->aq_waiters--; if (alq->aq_writehead <= alq->aq_writetail) contigbytes = alq->aq_freebytes; else contigbytes = alq->aq_buflen - alq->aq_writehead;//.........这里部分代码省略.........
开发者ID:2asoft,项目名称:freebsd,代码行数:101,
示例7: ichsmb_device_intr//.........这里部分代码省略......... if (sc->ich_cmd != -1) { KASSERT(cmd_index < sizeof(ichsmb_state_irqs), ("%s: ich_cmd=%d", device_get_nameunit(dev), sc->ich_cmd)); ok_bits |= ichsmb_state_irqs[cmd_index]; } if ((status & ~ok_bits) != 0) { device_printf(dev, "irq 0x%02x during %d/n", status, cmd_index); bus_write_1(sc->io_res, ICH_HST_STA, (status & ~ok_bits)); continue; } /* Handle SMBALERT interrupt */ if (status & ICH_HST_STA_SMBALERT_STS) { static int smbalert_count = 16; if (smbalert_count > 0) { device_printf(dev, "SMBALERT# rec'd/n"); if (--smbalert_count == 0) { device_printf(dev, "not logging anymore/n"); } } } /* Check for bus error */ if (status & ICH_HST_STA_BUS_ERR) { sc->smb_error = SMB_ECOLLI; /* XXX SMB_EBUSERR? */ goto finished; } /* Check for device error */ if (status & ICH_HST_STA_DEV_ERR) { sc->smb_error = SMB_ENOACK; /* or SMB_ETIMEOUT? */ goto finished; } /* Check for byte completion in block transfer */ if (status & ICH_HST_STA_BYTE_DONE_STS) { if (sc->block_write) { if (sc->block_index < sc->block_count) { /* Write next byte */ bus_write_1(sc->io_res, ICH_BLOCK_DB, sc->block_data[sc->block_index++]); } } else { /* First interrupt, get the count also */ if (sc->block_index == 0) { sc->block_count = bus_read_1( sc->io_res, ICH_D0); } /* Get next byte, if any */ if (sc->block_index < sc->block_count) { /* Read next byte */ sc->block_data[sc->block_index++] = bus_read_1(sc->io_res, ICH_BLOCK_DB); /* Set "LAST_BYTE" bit before reading the last byte of block data */ if (sc->block_index >= sc->block_count - 1) { bus_write_1(sc->io_res, ICH_HST_CNT, ICH_HST_CNT_LAST_BYTE | ICH_HST_CNT_INTREN | sc->ich_cmd); } } } } /* Check command completion */ if (status & ICH_HST_STA_INTR) { sc->smb_error = SMB_ENOERR;finished: sc->ich_cmd = -1; bus_write_1(sc->io_res, ICH_HST_STA, status); wakeup(sc); break; } /* Clear status bits and try again */ bus_write_1(sc->io_res, ICH_HST_STA, status); } lockmgr(&sc->mutex, LK_RELEASE); /* Too many loops? */ if (count == maxloops) { device_printf(dev, "interrupt loop, status=0x%02x/n", bus_read_1(sc->io_res, ICH_HST_STA)); }}
开发者ID:juanfra684,项目名称:DragonFlyBSD,代码行数:101,
示例8: igmpiputvoidigmpiput(Media *m, Ipifc *, Block *bp){ int n; IGMPpkt *ghp; Ipaddr group; IGMPrep *rp, **lrp; Multicast *mp, **lmp; ghp = (IGMPpkt*)(bp->rp); netlog(Logigmp, "igmpiput: %d %I/n", ghp->vertype, ghp->group); n = blocklen(bp); if(n < IGMP_IPHDRSIZE+IGMP_HDRSIZE){ netlog(Logigmp, "igmpiput: bad len/n"); goto error; } if((ghp->vertype>>4) != 1){ netlog(Logigmp, "igmpiput: bad igmp type/n"); goto error; } if(ptclcsum(bp, IGMP_IPHDRSIZE, IGMP_HDRSIZE)){ netlog(Logigmp, "igmpiput: checksum error %I/n", ghp->src); goto error; } group = nhgetl(ghp->group); lock(&igmpalloc); switch(ghp->vertype & 0xf){ case IGMPquery: /* * start reporting groups that we're a member of. */ stats.inqueries++; for(rp = igmpalloc.reports; rp; rp = rp->next) if(rp->m == m) break; if(rp != nil) break; /* already reporting */ mp = Mediacopymulti(m); if(mp == nil) break; rp = malloc(sizeof(*rp)); if(rp == nil) break; rp->m = m; rp->multi = mp; rp->ticks = 0; for(; mp; mp = mp->next) mp->timeout = nrand(MAXTIMEOUT); rp->next = igmpalloc.reports; igmpalloc.reports = rp; wakeup(&igmpalloc.r); break; case IGMPreport: /* * find report list for this medium */ stats.inreports++; lrp = &igmpalloc.reports; for(rp = *lrp; rp; rp = *lrp){ if(rp->m == m) break; lrp = &rp->next; } if(rp == nil) break; /* * if someone else has reported a group, * we don't have to. */ lmp = &rp->multi; for(mp = *lmp; mp; mp = *lmp){ if(mp->addr == group){ *lmp = mp->next; free(mp); break; } lmp = &mp->next; } break; } unlock(&igmpalloc);error: freeb(bp);}
开发者ID:0intro,项目名称:vx32,代码行数:95,
示例9: _flockarg_t _flock(void){ inoptr ino; struct oft *o; staticfast uint8_t c; staticfast uint8_t lock; staticfast int self; lock = lockop & ~LOCK_NB; self = 0; if (lock > LOCK_UN) { udata.u_error = EINVAL; return -1; } if ((ino = getinode(file)) == NULLINODE) return -1; o = &of_tab[udata.u_files[file]]; c = ino->c_flags & CFLOCK; /* Upgrades and downgrades. Check if we are in fact doing a no-op */ if (o->o_access & O_FLOCK) { self = 1; /* Shared or exclusive to shared can't block and is easy */ if (lock == LOCK_SH) { if (c == CFLEX) c = 1; goto done; } /* Exclusive to exclusive - no op */ if (c == CFLEX && lock == LOCK_EX) return 0; /* Shared to exclusive - handle via the loop */ } /* Unlock - drop the locks, mark us not a lock holder. Doesn't block */ if (lockop == LOCK_UN) { o->o_access &= ~O_FLOCK; deflock(o); return 0; } do { /* Exclusive lock must have no holders */ if (c == self && lock == LOCK_EX) { c = CFLEX; goto done; } if (c < CFMAX) { c++; goto done; } if (c == CFMAX) { udata.u_error = ENOLCK; return -1; } /* LOCK_NB is defined as O_NDELAY... */ if (psleep_flags(&ino->c_flags, (lockop & LOCK_NB))) return -1; /* locks will hopefully have changed .. */ c = ino->c_flags & CFLOCK; } while (1);done: if (o->o_access & O_FLOCK) deflock(o); ino->c_flags &= ~CFLOCK; ino->c_flags |= c; o->o_access |= O_FLOCK; wakeup(&ino->c_flags); return 0;}
开发者ID:NoSuchProcess,项目名称:FUZIX,代码行数:75,
示例10: pagerstatic voidpager(void *junk){ int i; Segment *s; Proc *p, *ep; if(waserror()) panic("pager: os error"); p = proctab(0); ep = &p[conf.nproc];loop: up->psstate = "Idle"; sleep(&swapalloc.r, needpages, 0); while(needpages(junk)) { if(swapimage.c) { p++; if(p >= ep) p = proctab(0); if(p->state == Dead || p->noswap) continue; if(!canqlock(&p->seglock)) continue; /* process changing its segments */ for(i = 0; i < NSEG; i++) { if(!needpages(junk)){ qunlock(&p->seglock); goto loop; } if(s = p->seg[i]) { switch(s->type&SG_TYPE) { default: break; case SG_TEXT: pageout(p, s); break; case SG_DATA: case SG_BSS: case SG_STACK: case SG_SHARED: up->psstate = "Pageout"; pageout(p, s); if(ioptr != 0) { up->psstate = "I/O"; executeio(); } break; } } } qunlock(&p->seglock); } else { print("out of physical memory; no swap configured/n"); if(!cpuserver) freebroken(); /* can use the memory */ else killbig("out of memory"); /* Emulate the old system if no swap channel */ tsleep(&up->sleep, return0, 0, 5000); wakeup(&palloc.r); } } goto loop;}
开发者ID:AustenConrad,项目名称:plan-9,代码行数:73,
示例11: consoleintr//.........这里部分代码省略......... } break; case KEY_LEFT: // Left arrow if (input.e != input.w) { input.e--; consputc(KEY_LEFT); } break; case KEY_RIGHT: // Right arrow if (input.f > input.e) { input.e++; consputc(KEY_RIGHT); } break; case KEY_UP: // Key Up if (historyInd != 0) kill_line(); if (historyList.size > 0) { char buffer[INPUT_BUF]; tmp = (historyInd - 1) % historyList.size; if (tmp > -1) { historyInd = tmp; if (history(buffer, historyInd) == 0) { setHistory(buffer); } else panic("history"); } } break; case KEY_DOWN: // Key Down kill_line(); if (historyInd < historyList.size - 1) { char buffer[INPUT_BUF]; historyInd = (historyInd + 1) % MAX_HISTORY; if (historyInd < historyList.size) { if (history(buffer, historyInd) == 0) { setHistory(buffer); } else panic("history"); } else kill_line(); } else if (historyInd == historyList.size - 1) kill_line(); break; default: if (c != 0 && input.f - input.r < INPUT_BUF) { c = (c == '/r') ? '/n' : c; if (c == '/n') { // if any command is currently written, first record it in the history books if (input.f >= input.w) { updateHistory(); } } //*** regular caret *** if (input.e >= input.f) { input.buf[input.e++ % INPUT_BUF] = c; consputc(c); } //*** middle caret *** else { if (c == '/n') { input.buf[input.f % INPUT_BUF] = c; input.e = input.f + 1; consputc(c); } else { int index = input.f; while (index > input.e) { // first shift by one each char in buffer from caret to the end input.buf[index % INPUT_BUF] = input.buf[(index - 1) % INPUT_BUF]; index--; } input.buf[input.e % INPUT_BUF] = c; // Write new char in buffer int i = input.e; index = input.f + 1; while (i < index) // Print those chars from buffer to console consputc(input.buf[i++ % INPUT_BUF]); i = input.e; index = input.f; while (i < index) { // move caret back to it's place after the new character consputc(KEY_LEFT); i++; } input.e++; } } input.f++; if (c == '/n' || c == C('D') || input.f == input.r + INPUT_BUF) { input.w = input.f; input.e = input.f; wakeup(&input.r); } } break; } } release(&cons.lock); if (doprocdump) { procdump(); // now call procdump() wo. cons.lock held }}
开发者ID:salexa92,项目名称:os161ass1,代码行数:101,
示例12: ald_activate/* * Put a queue on the active list. This will schedule it for writing. */static voidald_activate(struct alq *alq){ LIST_INSERT_HEAD(&ald_active, alq, aq_act); wakeup(&ald_active);}
开发者ID:2asoft,项目名称:freebsd,代码行数:9,
示例13: trapvoidtrap(struct trapframe *tf){ if(tf->trapno == T_SYSCALL){ if(proc->killed) exit(); proc->tf = tf; syscall(); if (proc->tf->trapno != T_PGFLT) { if(proc->killed) exit(); return;} } switch(tf->trapno){ case T_IRQ0 + IRQ_TIMER: if(cpu->id == 0){ acquire(&tickslock); ticks++; wakeup(&ticks); release(&tickslock); } lapiceoi(); break; case T_IRQ0 + IRQ_IDE: ideintr(); lapiceoi(); break; case T_IRQ0 + IRQ_IDE+1: // Bochs generates spurious IDE1 interrupts. break; case T_IRQ0 + IRQ_KBD: kbdintr(); lapiceoi(); break; case T_IRQ0 + IRQ_COM1: uartintr(); lapiceoi(); break; case T_IRQ0 + 7: case T_IRQ0 + IRQ_SPURIOUS: cprintf("cpu%d: spurious interrupt at %x:%x/n", cpu->id, tf->cs, tf->eip); lapiceoi(); break; // TODO(byan23): Add a case for page fault. case T_PGFLT: // check range of rcr2() not in guard page // only grow one page at a time //cprintf("check: /nstack: %d/nproc->sz: %d/nrcr: %d/n", USERTOP-proc->ssz, proc->sz, rcr2()); if ((PGROUNDUP(proc->sz) + PGSIZE < USERTOP - proc->ssz) && (rcr2() >= USERTOP - proc->ssz - PGSIZE) && (rcr2() >= proc->sz + PGSIZE)) { //uint pgpos = //(rcr2() % PGSIZE == 0) ? rcr2() : (PGROUNDUP(rcr2()) - PGSIZE); uint pgpos = proc->ssz + PGSIZE; if (allocuvm(proc->pgdir, USERTOP - pgpos, USERTOP - proc->ssz) == 0) { cprintf("allocuvm failed cr2=0x%x/n", rcr2()); proc->killed = 1; break; } proc->ssz = pgpos; break; } default: if(proc == 0 || (tf->cs&3) == 0){ // In kernel, it must be our mistake. cprintf("unexpected trap %d from cpu %d eip %x (cr2=0x%x)/n", tf->trapno, cpu->id, tf->eip, rcr2()); panic("trap"); } // In user space, assume process misbehaved. cprintf("pid %d %s: trap %d err %d on cpu %d " "eip 0x%x addr 0x%x--kill proc/n", proc->pid, proc->name, tf->trapno, tf->err, cpu->id, tf->eip, rcr2()); proc->killed = 1; } // Force process exit if it has been killed and is in user space. // (If it is still executing in the kernel, let it keep running // until it gets to the regular system call return.) if(proc && proc->killed && (tf->cs&3) == DPL_USER) exit(); // Force process to give up CPU on clock tick. // If interrupts were on while locks held, would need to check nlock. if(proc && proc->state == RUNNING && tf->trapno == T_IRQ0+IRQ_TIMER) yield(); // Check if the process has been killed since we yielded if(proc && proc->killed && (tf->cs&3) == DPL_USER) exit();}
开发者ID:byan23,项目名称:OS_P3,代码行数:94,
示例14: alq_writen/* * Copy a new entry into the queue. If the operation would block either * wait or return an error depending on the value of waitok. */intalq_writen(struct alq *alq, void *data, int len, int flags){ int activate, copy, ret; void *waitchan; KASSERT((len > 0 && len <= alq->aq_buflen), ("%s: len <= 0 || len > aq_buflen", __func__)); activate = ret = 0; copy = len; waitchan = NULL; ALQ_LOCK(alq); /* * Fail to perform the write and return EWOULDBLOCK if: * - The message is larger than our underlying buffer. * - The ALQ is being shutdown. * - There is insufficient free space in our underlying buffer * to accept the message and the user can't wait for space. * - There is insufficient free space in our underlying buffer * to accept the message and the alq is inactive due to prior * use of the ALQ_NOACTIVATE flag (which would lead to deadlock). */ if (len > alq->aq_buflen || alq->aq_flags & AQ_SHUTDOWN || (((flags & ALQ_NOWAIT) || (!(alq->aq_flags & AQ_ACTIVE) && HAS_PENDING_DATA(alq))) && alq->aq_freebytes < len)) { ALQ_UNLOCK(alq); return (EWOULDBLOCK); } /* * If we want ordered writes and there is already at least one thread * waiting for resources to become available, sleep until we're woken. */ if (alq->aq_flags & AQ_ORDERED && alq->aq_waiters > 0) { KASSERT(!(flags & ALQ_NOWAIT), ("%s: ALQ_NOWAIT set but incorrectly ignored!", __func__)); alq->aq_waiters++; msleep_spin(&alq->aq_waiters, &alq->aq_mtx, "alqwnord", 0); alq->aq_waiters--; } /* * (ALQ_WAITOK && aq_freebytes < len) or aq_freebytes >= len, either * enter while loop and sleep until we have enough free bytes (former) * or skip (latter). If AQ_ORDERED is set, only 1 thread at a time will * be in this loop. Otherwise, multiple threads may be sleeping here * competing for ALQ resources. */ while (alq->aq_freebytes < len && !(alq->aq_flags & AQ_SHUTDOWN)) { KASSERT(!(flags & ALQ_NOWAIT), ("%s: ALQ_NOWAIT set but incorrectly ignored!", __func__)); alq->aq_flags |= AQ_WANTED; alq->aq_waiters++; if (waitchan) wakeup(waitchan); msleep_spin(alq, &alq->aq_mtx, "alqwnres", 0); alq->aq_waiters--; /* * If we're the first thread to wake after an AQ_WANTED wakeup * but there isn't enough free space for us, we're going to loop * and sleep again. If there are other threads waiting in this * loop, schedule a wakeup so that they can see if the space * they require is available. */ if (alq->aq_waiters > 0 && !(alq->aq_flags & AQ_ORDERED) && alq->aq_freebytes < len && !(alq->aq_flags & AQ_WANTED)) waitchan = alq; else waitchan = NULL; } /* * If there are waiters, we need to signal the waiting threads after we * complete our work. The alq ptr is used as a wait channel for threads * requiring resources to be freed up. In the AQ_ORDERED case, threads * are not allowed to concurrently compete for resources in the above * while loop, so we use a different wait channel in this case. */ if (alq->aq_waiters > 0) { if (alq->aq_flags & AQ_ORDERED) waitchan = &alq->aq_waiters; else waitchan = alq; } else waitchan = NULL; /* Bail if we're shutting down. */ if (alq->aq_flags & AQ_SHUTDOWN) { ret = EWOULDBLOCK; goto unlock; }//.........这里部分代码省略.........
开发者ID:2asoft,项目名称:freebsd,代码行数:101,
示例15: ucomopenStatic intucomopen(dev_t dev, int flag, int mode, usb_proc_ptr p){ int unit = UCOMUNIT(dev); struct ucom_softc *sc; usbd_status err; struct tty *tp; int s; int error; USB_GET_SC_OPEN(ucom, unit, sc); if (sc->sc_dying) return (ENXIO); tp = sc->sc_tty; DPRINTF(("%s: ucomopen: tp = %p/n", USBDEVNAME(sc->sc_dev), tp)); if (ISSET(tp->t_state, TS_ISOPEN) && ISSET(tp->t_state, TS_XCLUDE) && suser(p)) return (EBUSY); /* * Do the following iff this is a first open. */ s = spltty(); while (sc->sc_opening) tsleep(&sc->sc_opening, PRIBIO, "ucomop", 0); sc->sc_opening = 1; if (!ISSET(tp->t_state, TS_ISOPEN)) { struct termios t; sc->sc_poll = 0; sc->sc_lsr = sc->sc_msr = sc->sc_mcr = 0; tp->t_dev = dev; /* * Initialize the termios status to the defaults. Add in the * sticky bits from TIOCSFLAGS. */ t.c_ispeed = 0; t.c_ospeed = TTYDEF_SPEED; t.c_cflag = TTYDEF_CFLAG; /* Make sure ucomparam() will do something. */ tp->t_ospeed = 0; (void)ucomparam(tp, &t); tp->t_iflag = TTYDEF_IFLAG; tp->t_oflag = TTYDEF_OFLAG; tp->t_lflag = TTYDEF_LFLAG; ttychars(tp); ttsetwater(tp); /* * Turn on DTR. We must always do this, even if carrier is not * present, because otherwise we'd have to use TIOCSDTR * immediately after setting CLOCAL, which applications do not * expect. We always assert DTR while the device is open * unless explicitly requested to deassert it. */ (void)ucomctl(sc, TIOCM_DTR | TIOCM_RTS, DMBIS); /* Device specific open */ if (sc->sc_callback->ucom_open != NULL) { error = sc->sc_callback->ucom_open(sc->sc_parent, sc->sc_portno); if (error) { ucom_cleanup(sc); sc->sc_opening = 0; wakeup(&sc->sc_opening); splx(s); return (error); } } DPRINTF(("ucomopen: open pipes in = %d out = %d/n", sc->sc_bulkin_no, sc->sc_bulkout_no)); /* Open the bulk pipes */ /* Bulk-in pipe */ err = usbd_open_pipe(sc->sc_iface, sc->sc_bulkin_no, 0, &sc->sc_bulkin_pipe); if (err) { printf("%s: open bulk out error (addr %d): %s/n", USBDEVNAME(sc->sc_dev), sc->sc_bulkin_no, usbd_errstr(err)); error = EIO; goto fail_0; } /* Bulk-out pipe */ err = usbd_open_pipe(sc->sc_iface, sc->sc_bulkout_no, USBD_EXCLUSIVE_USE, &sc->sc_bulkout_pipe); if (err) { printf("%s: open bulk in error (addr %d): %s/n", USBDEVNAME(sc->sc_dev), sc->sc_bulkout_no, usbd_errstr(err)); error = EIO;//.........这里部分代码省略.........
开发者ID:MarginC,项目名称:kame,代码行数:101,
示例16: ucomstartStatic voiducomstart(struct tty *tp){ struct ucom_softc *sc; struct cblock *cbp; usbd_status err; int s; u_char *data; int cnt; USB_GET_SC(ucom, UCOMUNIT(tp->t_dev), sc); DPRINTF(("ucomstart: sc = %p/n", sc)); if (sc->sc_dying) return; s = spltty(); if (tp->t_state & TS_TBLOCK) { if (ISSET(sc->sc_mcr, UMCR_RTS) && ISSET(sc->sc_state, UCS_RTS_IFLOW)) { DPRINTF(("ucomstart: clear RTS/n")); (void)ucomctl(sc, UMCR_RTS, DMBIC); } } else { if (!ISSET(sc->sc_mcr, UMCR_RTS) && tp->t_rawq.c_cc <= tp->t_ilowat && ISSET(sc->sc_state, UCS_RTS_IFLOW)) { DPRINTF(("ucomstart: set RTS/n")); (void)ucomctl(sc, UMCR_RTS, DMBIS); } } if (ISSET(tp->t_state, TS_BUSY | TS_TIMEOUT | TS_TTSTOP)) { ttwwakeup(tp); DPRINTF(("ucomstart: stopped/n")); goto out; } if (tp->t_outq.c_cc <= tp->t_olowat) { if (ISSET(tp->t_state, TS_SO_OLOWAT)) { CLR(tp->t_state, TS_SO_OLOWAT); wakeup(TSA_OLOWAT(tp)); } selwakeup(&tp->t_wsel); if (tp->t_outq.c_cc == 0) { if (ISSET(tp->t_state, TS_BUSY | TS_SO_OCOMPLETE) == TS_SO_OCOMPLETE && tp->t_outq.c_cc == 0) { CLR(tp->t_state, TS_SO_OCOMPLETE); wakeup(TSA_OCOMPLETE(tp)); } goto out; } } /* Grab the first contiguous region of buffer space. */ data = tp->t_outq.c_cf; cbp = (struct cblock *) ((intptr_t) tp->t_outq.c_cf & ~CROUND); cnt = min((char *) (cbp+1) - tp->t_outq.c_cf, tp->t_outq.c_cc); if (cnt == 0) { DPRINTF(("ucomstart: cnt == 0/n")); goto out; } SET(tp->t_state, TS_BUSY); if (cnt > sc->sc_obufsize) { DPRINTF(("ucomstart: big buffer %d chars/n", cnt)); cnt = sc->sc_obufsize; } if (sc->sc_callback->ucom_write != NULL) sc->sc_callback->ucom_write(sc->sc_parent, sc->sc_portno, sc->sc_obuf, data, &cnt); else memcpy(sc->sc_obuf, data, cnt); DPRINTF(("ucomstart: %d chars/n", cnt)); usbd_setup_xfer(sc->sc_oxfer, sc->sc_bulkout_pipe, (usbd_private_handle)sc, sc->sc_obuf, cnt, USBD_NO_COPY, USBD_NO_TIMEOUT, ucomwritecb); /* What can we do on error? */ err = usbd_transfer(sc->sc_oxfer); if (err != USBD_IN_PROGRESS) printf("ucomstart: err=%s/n", usbd_errstr(err)); ttwwakeup(tp); out: splx(s);}
开发者ID:MarginC,项目名称:kame,代码行数:91,
示例17: trap//PAGEBREAK: 41voidtrap(struct trapframe *tf){ if(tf->trapno == T_SYSCALL){ if(proc->killed) exit(); proc->tf = tf; syscall(); if(proc->killed) exit(); return; } switch(tf->trapno){ case T_IRQ0 + IRQ_TIMER: if(cpu->id == 0){ acquire(&tickslock); ticks++; wakeup(&ticks); release(&tickslock); } lapiceoi(); break; case T_IRQ0 + IRQ_IDE: ideintr(); lapiceoi(); break; case T_IRQ0 + IRQ_IDE+1: // Bochs generates spurious IDE1 interrupts. break; case T_IRQ0 + IRQ_KBD: kbdintr(); lapiceoi(); break; case T_IRQ0 + IRQ_COM1: uartintr(); lapiceoi(); break; case T_IRQ0 + 7: case T_IRQ0 + IRQ_SPURIOUS: cprintf("cpu%d: spurious interrupt at %x:%x/n", cpu->id, tf->cs, tf->eip); lapiceoi(); break; //PAGEBREAK: 13 default: if(proc == 0 || (tf->cs&3) == 0){ // In kernel, it must be our mistake. cprintf("unexpected trap %d from cpu %d eip %x (cr2=0x%x)/n", tf->trapno, cpu->id, tf->eip, rcr2()); panic("trap"); } // In user space, assume process misbehaved. if((tf->eip+1)!=0 || (*(int *)(tf->esp-4)+1)!=0 || proc->xstack==0) { cprintf("pid %d %s: trap %d err %d on cpu %d " "eip 0x%x addr 0x%x--kill proc/n", proc->pid, proc->name, tf->trapno, tf->err, cpu->id, tf->eip, rcr2()); } else { // Catch the exception and get the return value. //asm volatile("/t movl %%eax,%0" : "=r"(ret_val)); //cprintf("trap: return val=0x%x/n",ret_val); thread_exit((void* )tf->eax); } proc->killed = 1; } // Force process exit if it has been killed and is in user space. // (If it is still executing in the kernel, let it keep running // until it gets to the regular system call return.) if(proc && proc->killed && (tf->cs&3) == DPL_USER) exit(); // Force process to give up CPU on clock tick. // If interrupts were on while locks held, would need to check nlock. if(proc && proc->state == RUNNING && tf->trapno == T_IRQ0+IRQ_TIMER) yield(); // Check if the process has been killed since we yielded if(proc && proc->killed && (tf->cs&3) == DPL_USER) exit();}
开发者ID:MicGeeGee,项目名称:xv6_proj3,代码行数:89,
示例18: switchvoid BodySW::set_state(PhysicsServer::BodyState p_state, const Variant &p_variant) { switch (p_state) { case PhysicsServer::BODY_STATE_TRANSFORM: { if (mode == PhysicsServer::BODY_MODE_KINEMATIC) { new_transform = p_variant; //wakeup_neighbours(); set_active(true); if (first_time_kinematic) { _set_transform(p_variant); _set_inv_transform(get_transform().affine_inverse()); first_time_kinematic = false; } } else if (mode == PhysicsServer::BODY_MODE_STATIC) { _set_transform(p_variant); _set_inv_transform(get_transform().affine_inverse()); wakeup_neighbours(); } else { Transform t = p_variant; t.orthonormalize(); new_transform = get_transform(); //used as old to compute motion if (new_transform == t) break; _set_transform(t); _set_inv_transform(get_transform().inverse()); } wakeup(); } break; case PhysicsServer::BODY_STATE_LINEAR_VELOCITY: { /* if (mode==PhysicsServer::BODY_MODE_STATIC) break; */ linear_velocity = p_variant; wakeup(); } break; case PhysicsServer::BODY_STATE_ANGULAR_VELOCITY: { /* if (mode!=PhysicsServer::BODY_MODE_RIGID) break; */ angular_velocity = p_variant; wakeup(); } break; case PhysicsServer::BODY_STATE_SLEEPING: { //? if (mode == PhysicsServer::BODY_MODE_STATIC || mode == PhysicsServer::BODY_MODE_KINEMATIC) break; bool do_sleep = p_variant; if (do_sleep) { linear_velocity = Vector3(); //biased_linear_velocity=Vector3(); angular_velocity = Vector3(); //biased_angular_velocity=Vector3(); set_active(false); } else { if (mode != PhysicsServer::BODY_MODE_STATIC) set_active(true); } } break; case PhysicsServer::BODY_STATE_CAN_SLEEP: { can_sleep = p_variant; if (mode == PhysicsServer::BODY_MODE_RIGID && !active && !can_sleep) set_active(true); } break; }}
开发者ID:angjminer,项目名称:godot,代码行数:73,
示例19: isdn_layer2_trace_ind/*---------------------------------------------------------------------------* * isdn_layer2_trace_ind * --------------------- * is called from layer 1, adds timestamp to trace data and puts * it into a queue, from which it can be read from the i4btrc * device. The unit number in the trace header selects the minor * device's queue the data is put into. *---------------------------------------------------------------------------*/intisdn_layer2_trace_ind(struct l2_softc *sc, struct isdn_l3_driver *drv, i4b_trace_hdr *hdr, size_t len, unsigned char *buf){ struct mbuf *m; int bri, x; int trunc = 0; int totlen = len + sizeof(i4b_trace_hdr); MICROTIME(hdr->time); hdr->bri = sc->drv->bri; /* * for telephony (or better non-HDLC HSCX mode) we get * (MCLBYTE + sizeof(i4b_trace_hdr_t)) length packets * to put into the queue to userland. because of this * we detect this situation, strip the length to MCLBYTES * max size, and infor the userland program of this fact * by putting the no of truncated bytes into hdr->trunc. */ if(totlen > MCLBYTES) { trunc = 1; hdr->trunc = totlen - MCLBYTES; totlen = MCLBYTES; } else { hdr->trunc = 0; } /* set length of trace record */ hdr->length = totlen; /* check valid interface */ if((bri = hdr->bri) > NISDNTRC) { printf("i4b_trace: get_trace_data_from_l1 - bri > NISDNTRC!/n"); return(0); } /* get mbuf */ if(!(m = i4b_Bgetmbuf(totlen))) { printf("i4b_trace: get_trace_data_from_l1 - i4b_getmbuf() failed!/n"); return(0); } /* check if we are in analyzemode */ if(analyzemode && (bri == rxunit || bri == txunit)) { if(bri == rxunit) hdr->dir = FROM_NT; else hdr->dir = FROM_TE; bri = outunit; } if(IF_QFULL(&trace_queue[bri])) { struct mbuf *m1; x = splnet(); IF_DEQUEUE(&trace_queue[bri], m1); splx(x); i4b_Bfreembuf(m1); } /* copy trace header */ memcpy(m->m_data, hdr, sizeof(i4b_trace_hdr)); /* copy trace data */ if(trunc) memcpy(&m->m_data[sizeof(i4b_trace_hdr)], buf, totlen-sizeof(i4b_trace_hdr)); else memcpy(&m->m_data[sizeof(i4b_trace_hdr)], buf, len); x = splnet(); IF_ENQUEUE(&trace_queue[bri], m); if(device_state[bri] & ST_WAITDATA) { device_state[bri] &= ~ST_WAITDATA; wakeup((caddr_t) &trace_queue[bri]); }//.........这里部分代码省略.........
开发者ID:MarginC,项目名称:kame,代码行数:101,
示例20: cbb_pci_filtstatic intcbb_pci_filt(void *arg){ struct cbb_softc *sc = arg; uint32_t sockevent; uint8_t csc; int retval = FILTER_STRAY; /* * Some chips also require us to read the old ExCA registe for card * status change when we route CSC vis PCI. This isn't supposed to be * required, but it clears the interrupt state on some chipsets. * Maybe there's a setting that would obviate its need. Maybe we * should test the status bits and deal with them, but so far we've * not found any machines that don't also give us the socket status * indication above. * * This call used to be unconditional. However, further research * suggests that we hit this condition when the card READY interrupt * fired. So now we only read it for 16-bit cards, and we only claim * the interrupt if READY is set. If this still causes problems, then * the next step would be to read this if we have a 16-bit card *OR* * we have no card. We treat the READY signal as if it were the power * completion signal. Some bridges may double signal things here, bit * signalling twice should be OK since we only sleep on the powerintr * in one place and a double wakeup would be benign there. */ if (sc->flags & CBB_16BIT_CARD) { csc = exca_getb(&sc->exca[0], EXCA_CSC); if (csc & EXCA_CSC_READY) { atomic_add_int(&sc->powerintr, 1); wakeup((void *)&sc->powerintr); retval = FILTER_HANDLED; } } /* * Read the socket event. Sometimes, the theory goes, the PCI bus is * so loaded that it cannot satisfy the read request, so we get * garbage back from the following read. We have to filter out the * garbage so that we don't spontaneously reset the card under high * load. PCI isn't supposed to act like this. No doubt this is a bug * in the PCI bridge chipset (or cbb brige) that's being used in * certain amd64 laptops today. Work around the issue by assuming * that any bits we don't know about being set means that we got * garbage. */ sockevent = cbb_get(sc, CBB_SOCKET_EVENT); if (sockevent != 0 && (sockevent & ~CBB_SOCKET_EVENT_VALID_MASK) == 0) { /* * If anything has happened to the socket, we assume that the * card is no longer OK, and we shouldn't call its ISR. We * set cardok as soon as we've attached the card. This helps * in a noisy eject, which happens all too often when users * are ejecting their PC Cards. * * We use this method in preference to checking to see if the * card is still there because the check suffers from a race * condition in the bouncing case. */#define DELTA (CBB_SOCKET_MASK_CD) if (sockevent & DELTA) { cbb_clrb(sc, CBB_SOCKET_MASK, DELTA); cbb_set(sc, CBB_SOCKET_EVENT, DELTA); sc->cardok = 0; cbb_disable_func_intr(sc); wakeup(&sc->intrhand); }#undef DELTA /* * Wakeup anybody waiting for a power interrupt. We have to * use atomic_add_int for wakups on other cores. */ if (sockevent & CBB_SOCKET_EVENT_POWER) { cbb_clrb(sc, CBB_SOCKET_MASK, CBB_SOCKET_EVENT_POWER); cbb_set(sc, CBB_SOCKET_EVENT, CBB_SOCKET_EVENT_POWER); atomic_add_int(&sc->powerintr, 1); wakeup((void *)&sc->powerintr); } /* * Status change interrupts aren't presently used in the * rest of the driver. For now, just ACK them. */ if (sockevent & CBB_SOCKET_EVENT_CSTS) cbb_set(sc, CBB_SOCKET_EVENT, CBB_SOCKET_EVENT_CSTS); retval = FILTER_HANDLED; } return retval;}
开发者ID:hlcherub,项目名称:src,代码行数:91,
示例21: ptdone//.........这里部分代码省略......... softc = (struct pt_softc *)periph->softc; csio = &done_ccb->csio; switch (csio->ccb_h.ccb_state) { case PT_CCB_BUFFER_IO: case PT_CCB_BUFFER_IO_UA: { struct buf *bp; int oldspl; bp = (struct buf *)done_ccb->ccb_h.ccb_bp; if ((done_ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { int error; int s; int sf; if ((csio->ccb_h.ccb_state & PT_CCB_RETRY_UA) != 0) sf = SF_RETRY_UA; else sf = 0; sf |= SF_RETRY_SELTO; if ((error = pterror(done_ccb, 0, sf)) == ERESTART) { /* * A retry was scheuled, so * just return. */ return; } if (error != 0) { struct buf *q_bp; s = splbio(); if (error == ENXIO) { /* * Catastrophic error. Mark our device * as invalid. */ xpt_print_path(periph->path); printf("Invalidating device/n"); softc->flags |= PT_FLAG_DEVICE_INVALID; } /* * return all queued I/O with EIO, so that * the client can retry these I/Os in the * proper order should it attempt to recover. */ while ((q_bp = bufq_first(&softc->buf_queue)) != NULL) { bufq_remove(&softc->buf_queue, q_bp); q_bp->b_resid = q_bp->b_bcount; q_bp->b_error = EIO; q_bp->b_flags |= B_ERROR; biodone(q_bp); } splx(s); bp->b_error = error; bp->b_resid = bp->b_bcount; bp->b_flags |= B_ERROR; } else { bp->b_resid = csio->resid; bp->b_error = 0; if (bp->b_resid != 0) { /* Short transfer ??? */ bp->b_flags |= B_ERROR; } } if ((done_ccb->ccb_h.status & CAM_DEV_QFRZN) != 0) cam_release_devq(done_ccb->ccb_h.path, /*relsim_flags*/0, /*reduction*/0, /*timeout*/0, /*getcount_only*/0); } else { bp->b_resid = csio->resid; if (bp->b_resid != 0) bp->b_flags |= B_ERROR; } /* * Block out any asyncronous callbacks * while we touch the pending ccb list. */ oldspl = splcam(); LIST_REMOVE(&done_ccb->ccb_h, periph_links.le); splx(oldspl); devstat_end_transaction_buf(&softc->device_stats, bp); biodone(bp); break; } case PT_CCB_WAITING: /* Caller will release the CCB */ wakeup(&done_ccb->ccb_h.cbfcnp); return; } xpt_release_ccb(done_ccb);}
开发者ID:UnitedMarsupials,项目名称:kame,代码行数:101,
示例22: tegra_i2c_transferstatic inttegra_i2c_transfer(device_t dev, struct iic_msg *msgs, uint32_t nmsgs){ int rv, i; struct tegra_i2c_softc *sc; enum tegra_i2c_xfer_type xtype; sc = device_get_softc(dev); LOCK(sc); /* Get the bus. */ while (sc->bus_inuse == 1) SLEEP(sc, 0); sc->bus_inuse = 1; rv = 0; for (i = 0; i < nmsgs; i++) { sc->msg = &msgs[i]; sc->msg_idx = 0; sc->bus_err = 0; sc->done = 0; /* Check for valid parameters. */ if (sc->msg == NULL || sc->msg->buf == NULL || sc->msg->len == 0) { rv = EINVAL; break; } /* Get flags for next transfer. */ if (i == (nmsgs - 1)) { if (msgs[i].flags & IIC_M_NOSTOP) xtype = XFER_CONTINUE; else xtype = XFER_STOP; } else { if (msgs[i + 1].flags & IIC_M_NOSTART) xtype = XFER_CONTINUE; else xtype = XFER_REPEAT_START; } tegra_i2c_start_msg(sc, sc->msg, xtype); if (cold) rv = tegra_i2c_poll(sc); else rv = msleep(&sc->done, &sc->mtx, PZERO, "iic", I2C_REQUEST_TIMEOUT); WR4(sc, I2C_INTERRUPT_MASK_REGISTER, 0); WR4(sc, I2C_INTERRUPT_STATUS_REGISTER, 0xFFFFFFFF); if (rv == 0) rv = sc->bus_err; if (rv != 0) break; } if (rv != 0) { tegra_i2c_hw_init(sc); tegra_i2c_flush_fifo(sc); } sc->msg = NULL; sc->msg_idx = 0; sc->bus_err = 0; sc->done = 0; /* Wake up the processes that are waiting for the bus. */ sc->bus_inuse = 0; wakeup(sc); UNLOCK(sc); return (rv);}
开发者ID:nanakom,项目名称:freebsd,代码行数:72,
示例23: kbdirq//.........这里部分代码省略......... /* make or break */ if( c & 0x80 ){ /* break */ c &= 0x7f; switch( scan_codes[c].type ){ case SCROLL: k->state &= ~SCROLL; break; case SHIFT: k->state &= ~SHIFT; break; case ALT: k->state &= ~ALT; break; case CTL: k->state &= ~CTL; break; } }else{ /* make */ switch( scan_codes[c].type ){ case SHIFT: k->state |= SHIFT; break; case ALT: k->state |= ALT; break; case CTL: k->state |= CTL; break; case NUM: k->state ^= NUM; break; case CAPS: k->state ^= CAPS; break; case NONE: break; case ASCII: case FUNC: if( k->state & CTL ) cs = scan_codes[c].ctl; else if( k->state & (SHIFT | CAPS) ) cs = scan_codes[c].shift; else cs = scan_codes[c].unshift; break; case KP: if( c == 83 && k->state & CTL && k->state & ALT ){ /* ctl-alt-del detected */#ifdef USE_GDB if( bootflags & BOOT_USEGDB ) breakpoint(); else#endif { E9PRINTF(("/n<C-A-Del>/nrebooting/n")); kprintf("/nrebooting..."); reboot(); } } if( k->state & CTL ) cs = scan_codes[c].ctl; else if( k->state & (SHIFT | NUM) ) cs = scan_codes[c].shift; else cs = scan_codes[c].unshift; break; } /* special control char ? */ for(i=0; i<sizeof(term.file.cchars); i++){ if(cs && term.file.cchars[i] && *cs == term.file.cchars[i]){ sigunblock( term.file.ccpid ); ksendmsg( term.file.ccpid, MSG_CCHAR_0 + i ); return; } } /* enqueue chars */ while( cs && *cs ){ if( k->len < PCTERM_QUEUE_SIZE ){ k->queue[ k->head++ ] = (k->state & ALT) ? (0x80 | *cs) : *cs; k->head %= PCTERM_QUEUE_SIZE; k->len ++; } /* else just drop it */ cs++; } wakeup(k); }}
开发者ID:jaw0,项目名称:osj5,代码行数:101,
注:本文中的wakeup函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ wakeup1函数代码示例 C++ wake_up_new_task函数代码示例 |