本文整理汇总了C++中crit_enter函数的典型用法代码示例。如果您正苦于以下问题:C++ crit_enter函数的具体用法?C++ crit_enter怎么用?C++ crit_enter使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了crit_enter函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fw_write
static int
fw_write (struct dev_write_args *ap)
{
cdev_t dev = ap->a_head.a_dev;
struct uio *uio = ap->a_uio;
int err = 0;
struct firewire_softc *sc;
int unit = DEV2UNIT(dev);
int slept = 0;
struct fw_pkt *fp;
struct fw_xferq *it;
if (DEV_FWMEM(dev))
return physwrite(ap);
sc = devclass_get_softc(firewire_devclass, unit);
it = ((struct fw_drv1 *)dev->si_drv1)->it;
if (it == NULL || it->buf == NULL)
return (EIO);
isoloop:
if (it->stproc == NULL) {
it->stproc = STAILQ_FIRST(&it->stfree);
if (it->stproc != NULL) {
crit_enter();
STAILQ_REMOVE_HEAD(&it->stfree, link);
crit_exit();
it->queued = 0;
} else if (slept == 0) {
slept = 1;
err = sc->fc->itx_enable(sc->fc, it->dmach);
if (err)
return err;
err = tsleep(it, FWPRI, "fw_write", hz);
if (err)
return err;
goto isoloop;
} else {
err = EIO;
return err;
}
}
fp = (struct fw_pkt *)fwdma_v_addr(it->buf,
it->stproc->poffset + it->queued);
err = uiomove((caddr_t)fp, sizeof(struct fw_isohdr), uio);
err = uiomove((caddr_t)fp->mode.stream.payload,
fp->mode.stream.len, uio);
it->queued ++;
if (it->queued >= it->bnpacket) {
crit_enter();
STAILQ_INSERT_TAIL(&it->stvalid, it->stproc, link);
crit_exit();
it->stproc = NULL;
err = sc->fc->itx_enable(sc->fc, it->dmach);
}
if (uio->uio_resid >= sizeof(struct fw_isohdr)) {
slept = 0;
goto isoloop;
}
return err;
}
示例2: cothread_create
/*
* Create a co-processor thread for a virtual kernel. This thread operates
* outside of the virtual kernel cpu abstraction and may only make direct
* cothread and libc calls.
*/
cothread_t
cothread_create(void (*thr_func)(cothread_t cotd),
void (*thr_intr)(cothread_t cotd),
void *arg, const char *name)
{
cothread_t cotd;
cotd = kmalloc(sizeof(*cotd), M_DEVBUF, M_WAITOK|M_ZERO);
cotd->thr_intr = thr_intr;
cotd->thr_func = thr_func;
cotd->arg = arg;
crit_enter();
pthread_mutex_init(&cotd->mutex, NULL);
pthread_cond_init(&cotd->cond, NULL);
crit_exit();
cotd->pintr = pthread_self();
cotd->intr_id = register_int(1, (void *)thr_intr, cotd, name, NULL,
INTR_MPSAFE, 0);
/*
* The vkernel's cpu_disable_intr() masks signals. We don't want
* our coprocessor thread taking any unix signals :-)
*/
crit_enter();
cpu_mask_all_signals();
pthread_create(&cotd->pthr, NULL, (void *)cothread_thread, cotd);
cpu_unmask_all_signals();
crit_exit();
return(cotd);
}
示例3: cache_destroy
NSAPI_PUBLIC void
cache_destroy(void *cache_ptr)
{
cache_t *cache = (cache_t *)cache_ptr;
cache_t *search, *last;
cache_entry_t *ptr;
SOLARIS_PROBE(cache_destroy_start, "cache");
#ifdef IRIX
NS_ASSERT(!cache->fast_mode);
#endif
NS_ASSERT(cache_crit);
NS_ASSERT(cache_ptr);
#ifdef CACHE_DEBUG
NS_ASSERT(cache->magic == CACHE_MAGIC);
#endif
crit_enter(cache_crit);
crit_enter(cache->lock);
ptr = cache->lru_head;
while(ptr) {
/* Caller MUST bump the access_count before calling delete
* We can do this since we hold the cache lock.
*/
cache_use_increment(cache, ptr);
cache_delete(cache, ptr, 0);
ptr = cache->lru_head;
}
PERM_FREE(cache->table);
cache->max_size = 0;
cache->hash_size = 0;
for ( last = NULL, search = cache_list; search; last = search,
search = search->next)
if (search == cache)
break;
if (search) {
if (last)
last->next = search->next;
else
cache_list = search->next;
}
else {
ereport(LOG_WARN, XP_GetAdminStr(DBT_cacheDestroyCacheTablesAppearCor_));
}
crit_exit(cache_crit);
crit_exit(cache->lock);
crit_terminate(cache->lock);
PERM_FREE(cache);
SOLARIS_PROBE(cache_destroy_end, "cache");
}
示例4: in6_rtqtimo
static void
in6_rtqtimo(void *rock)
{
struct radix_node_head *rnh = rock;
struct rtqk_arg arg;
struct timeval atv;
static time_t last_adjusted_timeout = 0;
arg.found = arg.killed = 0;
arg.rnh = rnh;
arg.nextstop = time_second + rtq_timeout;
arg.draining = arg.updating = 0;
crit_enter();
rnh->rnh_walktree(rnh, in6_rtqkill, &arg);
crit_exit();
/*
* Attempt to be somewhat dynamic about this:
* If there are ``too many'' routes sitting around taking up space,
* then crank down the timeout, and see if we can't make some more
* go away. However, we make sure that we will never adjust more
* than once in rtq_timeout seconds, to keep from cranking down too
* hard.
*/
if ((arg.found - arg.killed > rtq_toomany)
&& (time_second - last_adjusted_timeout >= rtq_timeout)
&& rtq_reallyold > rtq_minreallyold) {
rtq_reallyold = 2*rtq_reallyold / 3;
if (rtq_reallyold < rtq_minreallyold) {
rtq_reallyold = rtq_minreallyold;
}
last_adjusted_timeout = time_second;
#ifdef DIAGNOSTIC
log(LOG_DEBUG, "in6_rtqtimo: adjusted rtq_reallyold to %d",
rtq_reallyold);
#endif
arg.found = arg.killed = 0;
arg.updating = 1;
crit_enter();
rnh->rnh_walktree(rnh, in6_rtqkill, &arg);
crit_exit();
}
atv.tv_usec = 0;
atv.tv_sec = arg.nextstop;
callout_reset(&in6_rtqtimo_ch[mycpuid], tvtohz_high(&atv), in6_rtqtimo,
rock);
}
示例5: mark_buffer_dirty
/* this is supposed to mark a buffer dirty on ready for delayed writing
*/
void
mark_buffer_dirty(struct buf *bh)
{
crit_enter();
bh->b_flags |= B_DIRTY;
crit_exit();
}
示例6: uhub_child_detached
static void
uhub_child_detached(device_t self, device_t child)
{
struct uhub_softc *sc = device_get_softc(self);
usbd_device_handle devhub = sc->sc_hub;
usbd_device_handle dev = NULL;
int nports, port, i = 0;
crit_enter();
nports = devhub->hub->hubdesc.bNbrPorts;
for (port = 0; port < nports; port++) {
dev = devhub->hub->ports[port].device;
if (dev && dev->subdevs) {
for (i = 0; dev->subdevs[i]; ++i) {
if (dev->subdevs[i] == child)
goto found_dev;
}
}
}
crit_exit();
return;
found_dev:
#if 0
device_printf(dev->subdevs[i], "at %s", device_get_nameunit(self));
if (port != 0)
kprintf(" port %d", port);
kprintf(" (addr %d) disconnected\n", dev->address);
#endif
kfree(device_get_ivars(dev->subdevs[i]), M_USB);
dev->subdevs[i] = NULL;
crit_exit();
}
示例7: acpi_cpu_global_cx_lowest_sysctl
static int
acpi_cpu_global_cx_lowest_sysctl(SYSCTL_HANDLER_ARGS)
{
struct acpi_cpu_softc *sc;
char state[8];
int val, error, i;
ksnprintf(state, sizeof(state), "C%d", cpu_cx_lowest + 1);
error = sysctl_handle_string(oidp, state, sizeof(state), req);
if (error != 0 || req->newptr == NULL)
return (error);
if (strlen(state) < 2 || toupper(state[0]) != 'C')
return (EINVAL);
val = (int) strtol(state + 1, NULL, 10) - 1;
if (val < 0 || val > cpu_cx_count - 1)
return (EINVAL);
cpu_cx_lowest = val;
/* Update the new lowest useable Cx state for all CPUs. */
crit_enter();
for (i = 0; i < cpu_ndevices; i++) {
sc = device_get_softc(cpu_devices[i]);
error = acpi_cpu_set_cx_lowest(sc, val);
if (error) {
KKASSERT(i == 0);
break;
}
}
crit_exit();
return error;
}
示例8: mouse_cut_line
/* copy a line under the mouse pointer */
static void
mouse_cut_line(scr_stat *scp)
{
int i;
int j;
if (scp->status & MOUSE_VISIBLE) {
/* remove the current cut mark */
crit_enter();
if (scp->mouse_cut_start <= scp->mouse_cut_end) {
mark_for_update(scp, scp->mouse_cut_start);
mark_for_update(scp, scp->mouse_cut_end);
} else if (scp->mouse_cut_end >= 0) {
mark_for_update(scp, scp->mouse_cut_end);
mark_for_update(scp, scp->mouse_cut_start);
}
/* mark the entire line */
scp->mouse_cut_start =
(scp->mouse_pos / scp->xsize) * scp->xsize;
scp->mouse_cut_end = scp->mouse_cut_start + scp->xsize - 1;
mark_for_update(scp, scp->mouse_cut_start);
mark_for_update(scp, scp->mouse_cut_end);
crit_exit();
/* copy the line into the cut buffer */
for (i = 0, j = scp->mouse_cut_start; j <= scp->mouse_cut_end; ++j)
cut_buffer[i++] = sc_vtb_getc(&scp->vtb, j);
cut_buffer[i++] = '\r';
cut_buffer[i] = '\0';
scp->status |= MOUSE_CUTTING;
}
}
示例9: sFlushRxFIFO
/***************************************************************************
Function: sFlushRxFIFO
Purpose: Flush the Rx FIFO
Call: sFlushRxFIFO(ChP)
CHANNEL_T *ChP; Ptr to channel structure
Return: void
Comments: To prevent data from being enqueued or dequeued in the Tx FIFO
while it is being flushed the receive processor is stopped
and the transmitter is disabled. After these operations a
4 uS delay is done before clearing the pointers to allow
the receive processor to stop. These items are handled inside
this function.
Warnings: No context switches are allowed while executing this function.
*/
void sFlushRxFIFO(CHANNEL_T *ChP)
{
int i;
Byte_t Ch; /* channel number within AIOP */
int RxFIFOEnabled; /* TRUE if Rx FIFO enabled */
if(sGetRxCnt(ChP) == 0) /* Rx FIFO empty */
return; /* don't need to flush */
crit_enter();
RxFIFOEnabled = FALSE;
if(ChP->R[0x32] == 0x08) /* Rx FIFO is enabled */
{
RxFIFOEnabled = TRUE;
sDisRxFIFO(ChP); /* disable it */
for(i=0; i < 2000/200; i++) /* delay 2 uS to allow proc to disable FIFO*/
rp_readch1(ChP,_INT_CHAN); /* depends on bus i/o timing */
}
sGetChanStatus(ChP); /* clear any pending Rx errors in chan stat */
Ch = (Byte_t)sGetChanNum(ChP);
rp_writech1(ChP,_CMD_REG,Ch | RESRXFCNT); /* apply reset Rx FIFO count */
rp_writech1(ChP,_CMD_REG,Ch); /* remove reset Rx FIFO count */
rp_writech2(ChP,_INDX_ADDR,ChP->RxFIFOPtrs); /* clear Rx out ptr */
rp_writech2(ChP,_INDX_DATA,0);
rp_writech2(ChP,_INDX_ADDR,ChP->RxFIFOPtrs + 2); /* clear Rx in ptr */
rp_writech2(ChP,_INDX_DATA,0);
if(RxFIFOEnabled)
sEnRxFIFO(ChP); /* enable Rx FIFO */
crit_exit();
}
示例10: stghw_start_selection
static int
stghw_start_selection(struct stg_softc *sc, struct slccb *cb)
{
bus_space_tag_t iot = sc->sc_iot;
bus_space_handle_t ioh = sc->sc_ioh;
struct targ_info *ti = cb->ti;
u_int8_t stat;
sc->sc_tmaxcnt = cb->ccb_tcmax * 1000 * 1000;
sc->sc_dataout_timeout = 0;
sc->sc_ubf_timeout = 0;
stghw_bcr_write_1(sc, BCTL_BUSFREE);
bus_space_write_1(iot, ioh, tmc_ictl, sc->sc_icinit);
crit_enter();
stat = bus_space_read_1(iot, ioh, tmc_astat);
if ((stat & ASTAT_INT) != 0)
{
crit_exit();
return SCSI_LOW_START_FAIL;
}
bus_space_write_1(iot, ioh, tmc_scsiid, sc->sc_idbit);
bus_space_write_1(iot, ioh, tmc_fctl, sc->sc_fcRinit | FCTL_ARBIT);
crit_exit();
SCSI_LOW_SETUP_PHASE(ti, PH_ARBSTART);
return SCSI_LOW_START_OK;
}
示例11: cache_lock
NSAPI_PUBLIC void
cache_lock(cache_t *cache)
{
SOLARIS_PROBE(cache_lock_start, "cache");
crit_enter(cache->lock);
SOLARIS_PROBE(cache_lock_end, "cache");
}
示例12: sFlushTxFIFO
/***************************************************************************
Function: sFlushTxFIFO
Purpose: Flush the Tx FIFO
Call: sFlushTxFIFO(ChP)
CHANNEL_T *ChP; Ptr to channel structure
Return: void
Comments: To prevent data from being enqueued or dequeued in the Tx FIFO
while it is being flushed the receive processor is stopped
and the transmitter is disabled. After these operations a
4 uS delay is done before clearing the pointers to allow
the receive processor to stop. These items are handled inside
this function.
Warnings: No context switches are allowed while executing this function.
*/
void sFlushTxFIFO(CHANNEL_T *ChP)
{
int i;
Byte_t Ch; /* channel number within AIOP */
int TxEnabled; /* TRUE if transmitter enabled */
crit_enter();
if(sGetTxCnt(ChP) == 0) { /* Tx FIFO empty */
crit_exit();
return; /* don't need to flush */
}
TxEnabled = FALSE;
if(ChP->TxControl[3] & TX_ENABLE)
{
TxEnabled = TRUE;
sDisTransmit(ChP); /* disable transmitter */
}
sStopRxProcessor(ChP); /* stop Rx processor */
for(i = 0; i < 4000/200; i++) /* delay 4 uS to allow proc to stop */
rp_readch1(ChP,_INT_CHAN); /* depends on bus i/o timing */
Ch = (Byte_t)sGetChanNum(ChP);
rp_writech1(ChP,_CMD_REG,Ch | RESTXFCNT); /* apply reset Tx FIFO count */
rp_writech1(ChP,_CMD_REG,Ch); /* remove reset Tx FIFO count */
rp_writech2(ChP,_INDX_ADDR,ChP->TxFIFOPtrs); /* clear Tx in/out ptrs */
rp_writech2(ChP,_INDX_DATA,0);
if(TxEnabled)
sEnTransmit(ChP); /* enable transmitter */
sStartRxProcessor(ChP); /* restart Rx processor */
crit_exit();
}
示例13: sWriteTxPrioByte
/***************************************************************************
Function: sWriteTxPrioByte
Purpose: Write a byte of priority transmit data to a channel
Call: sWriteTxPrioByte(ChP,Data)
CHANNEL_T *ChP; Ptr to channel structure
Byte_t Data; The transmit data byte
Return: int: 1 if the bytes is successfully written, otherwise 0.
Comments: The priority byte is transmitted before any data in the Tx FIFO.
Warnings: No context switches are allowed while executing this function.
*/
int sWriteTxPrioByte(CHANNEL_T *ChP, Byte_t Data)
{
Byte_t DWBuf[4]; /* buffer for double word writes */
Word_t *WordPtr; /* must be far because Win SS != DS */
crit_enter();
if(sGetTxCnt(ChP) > 1) /* write it to Tx priority buffer */
{
rp_writech2(ChP,_INDX_ADDR,ChP->TxPrioCnt); /* get priority buffer status */
if(rp_readch1(ChP,_INDX_DATA) & PRI_PEND) {/* priority buffer busy */
crit_exit();
return(0); /* nothing sent */
}
WordPtr = (Word_t *)(&DWBuf[0]);
*WordPtr = ChP->TxPrioBuf; /* data byte address */
DWBuf[2] = Data; /* data byte value */
rp_writech4(ChP,_INDX_ADDR,*((DWord_t *)(&DWBuf[0]))); /* write it out */
*WordPtr = ChP->TxPrioCnt; /* Tx priority count address */
DWBuf[2] = PRI_PEND + 1; /* indicate 1 byte pending */
DWBuf[3] = 0; /* priority buffer pointer */
rp_writech4(ChP,_INDX_ADDR,*((DWord_t *)(&DWBuf[0]))); /* write it out */
}
else /* write it to Tx FIFO */
{
sWriteTxByte(ChP,sGetTxRxDataIO(ChP),Data);
}
crit_exit();
return(1); /* 1 byte sent */
}
示例14: spansarp_svcactive
/*
* SPANS ARP SVC activation notification
*
* This function is called when a previously opened SVC has successfully
* been connected.
*
* Arguments:
* ivp pointer to SVC's IPVCC control block
*
* Returns:
* 0 activation processing successful
* errno activation failed - reason indicated
*
*/
int
spansarp_svcactive(struct ipvcc *ivp)
{
struct spansarp *sap;
crit_enter();
/*
* Find an entry for the destination address
*/
SPANSARP_LOOKUP(ivp->iv_dst.s_addr, sap);
if (sap) {
/*
* IP is finished with entry, so remove IP VCC from chain
*/
UNLINK(ivp, struct ipvcc, sap->sa_ivp, iv_arpnext);
ivp->iv_arpent = NULL;
/*
* This seems like a reasonable reason to refresh the entry
*/
sap->sa_reftime = 0;
}
crit_exit();
return (0);
}
示例15: i4b_l4_connect_active_ind
/*---------------------------------------------------------------------------*
* send MSG_CONNECT_ACTIVE_IND message to userland
*---------------------------------------------------------------------------*/
void
i4b_l4_connect_active_ind(call_desc_t *cd)
{
struct mbuf *m;
crit_enter();
cd->last_active_time = cd->connect_time = SECOND;
NDBGL4(L4_TIMO, "last_active/connect_time=%ld", (long)cd->connect_time);
i4b_link_bchandrvr(cd);
(*cd->dlt->line_connected)(cd->driver_unit, (void *)cd);
i4b_l4_setup_timeout(cd);
crit_exit();
if((m = i4b_Dgetmbuf(sizeof(msg_connect_active_ind_t))) != NULL)
{
msg_connect_active_ind_t *mp = (msg_connect_active_ind_t *)m->m_data;
mp->header.type = MSG_CONNECT_ACTIVE_IND;
mp->header.cdid = cd->cdid;
mp->controller = cd->controller;
mp->channel = cd->channelid;
if(cd->datetime[0] != '\0')
strcpy(mp->datetime, cd->datetime);
else
mp->datetime[0] = '\0';
i4bputqueue(m);
}
}