本文整理汇总了C++中intr_disable函数的典型用法代码示例。如果您正苦于以下问题:C++ intr_disable函数的具体用法?C++ intr_disable怎么用?C++ intr_disable使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了intr_disable函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sema_up
/* Up or "V" operation on a semaphore. Increments SEMA's value
and wakes up one thread of those waiting for SEMA, if any.
This function may be called from an interrupt handler. */
void
sema_up (struct semaphore *sema)
{
enum intr_level old_level;
ASSERT (sema != NULL);
old_level = intr_disable ();
if (!list_empty (&(sema->waiters))) {
thread_unblock (list_entry (list_pop_highest_priority (&(sema->waiters)),
struct thread, elem));
}
示例2: serial_init_queue
/*! Initializes the serial port device for queued interrupt-driven
I/O. With interrupt-driven I/O we don't waste CPU time
waiting for the serial device to become ready. */
void serial_init_queue(void) {
enum intr_level old_level;
if (mode == UNINIT)
init_poll();
ASSERT(mode == POLL);
intr_register_ext(0x20 + 4, serial_interrupt, "serial");
mode = QUEUE;
old_level = intr_disable();
write_ier();
intr_set_level(old_level);
}
示例3: timer_sleep
/*! Sleeps for approximately TICKS timer ticks. Interrupts must
be turned on. */
void timer_sleep(int64_t ticks) {
int64_t start = timer_ticks();
enum intr_level old_level;
ASSERT(intr_get_level() == INTR_ON);
old_level = intr_disable();
thread_sleep();
thread_current()->wake_time = start + ticks;
thread_block();
intr_set_level(old_level);
}
示例4: __mp_unlock
void
__mp_unlock(struct __mp_lock *mpl)
{
struct __mp_lock_cpu *cpu = &mpl->mpl_cpus[cpu_number()];
u_int64_t s;
s = intr_disable();
if (--cpu->mplc_depth == 0) {
mpl->mpl_ticket++;
sparc_membar(StoreStore | LoadStore);
}
intr_restore(s);
}
示例5: timer_sleep
/* Sleeps for approximately TICKS timer ticks. Interrupts must
be turned on. */
void
timer_sleep (int64_t ticks)
{
ASSERT (intr_get_level () == INTR_ON);
enum intr_level level = intr_disable();
if(ticks > 0)
{
thread_current()->sleep_time = ticks;
thread_block();
}
intr_set_level(level);
}
示例6: sema_up
/* Up or "V" operation on a semaphore. Increments SEMA's value
and wakes up one thread of those waiting for SEMA, if any.
This function may be called from an interrupt handler. */
void
sema_up (struct semaphore *sema)
{
enum intr_level old_level;
ASSERT (sema != NULL);
old_level = intr_disable ();
if (!list_empty (&sema->waiters)) {
list_sort (&sema->waiters, (list_less_func *) &compare_priority, NULL);
struct thread *waiter_thread = list_entry (list_pop_front (&sema->waiters),
struct thread, elem);
thread_unblock (waiter_thread);
}
示例7: spinlock_enter
void
spinlock_enter(void)
{
struct thread *td;
td = curthread;
if (td->td_md.md_spinlock_count == 0) {
td->td_md.md_spinlock_count = 1;
td->td_md.md_saved_sstatus_ie = intr_disable();
} else
td->td_md.md_spinlock_count++;
critical_enter();
}
示例8: main
int main(void) {
// register exception handlers
for (unsigned i = 0; i < 32; i++) {
exc_register(i, &fault_handler);
}
exc_register(8, &trap_handler);
exc_register(18, &intr_handler);
exc_register(19, &intr_handler);
exc_register(20, &intr_handler);
exc_register(21, &intr_handler);
// unmask interrupts
intr_unmask_all();
// clear pending flags
intr_clear_all_pending();
// enable interrupts
intr_enable();
// a that prints "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_" N times and does some self-checking
volatile unsigned starts = 0;
volatile unsigned ends = 0;
volatile unsigned sent = 0;
for (unsigned k = 0; k < N; k++) {
starts++;
for (unsigned i = 0; i < 32; i++) {
putchar('@'+i);
sent+=i;
}
putchar('\n');
ends++;
if (sent != 496*(k+1) || starts != ends) {
LEDS = 0x55;
abort();
}
}
// diable interrupts again
intr_disable();
// call exception vector number 8
trap(8);
// trigger illegal operation fault
asm volatile(".word 0xffffffff"); // illegal operation
// trigger illegal memory access fault, never reached
(*((volatile _IODEV unsigned *)0xffffffff)) = 0;
return 0;
}
示例9: __mp_release_all_but_one
int
__mp_release_all_but_one(struct __mp_lock *mpl)
{
struct __mp_lock_cpu *cpu = &mpl->mpl_cpus[cpu_number()];
u_int64_t s;
int rv;
s = intr_disable();
rv = cpu->mplc_depth;
cpu->mplc_depth = 1;
intr_restore(s);
return (rv - 1);
}
示例10: __mp_lock
void
__mp_lock(struct __mp_lock *mpl)
{
struct __mp_lock_cpu *cpu = &mpl->mpl_cpus[cpu_number()];
u_int64_t s;
s = intr_disable();
if (cpu->mplc_depth++ == 0)
cpu->mplc_ticket = atomic_inc_int_nv(&mpl->mpl_users);
intr_restore(s);
__mp_lock_spin(mpl, cpu->mplc_ticket);
sparc_membar(LoadLoad | LoadStore);
}
示例11: timer_sleep
/* Sleeps for approximately TICKS timer ticks. Interrupts must
be turned on. */
void
timer_sleep (int64_t ticks)
{
int64_t start = timer_ticks ();
ASSERT (intr_get_level () == INTR_ON);
enum intr_level old_level = intr_disable ();
// sleep the thread for `ticks` seconds,
// until the tick becomes [start + ticks]
thread_sleep_until (start + ticks);
intr_set_level (old_level);
}
示例12: dismiss_alarm
/* dismiss the alarm and unblock the thread */
static void
dismiss_alarm (struct alarm *alrm)
{
enum intr_level old_level;
ASSERT (is_alarm (alrm));
/* remove from alarm_list, critical section */
old_level = intr_disable ();
list_remove (&alrm->elem);
thread_unblock (alrm->thrd); /* unblock the thread */
intr_set_level (old_level);
}
示例13: sema_down
/*! Down or "P" operation on a semaphore. Waits for SEMA's value
to become positive and then atomically decrements it.
This function may sleep, so it must not be called within an
interrupt handler. This function may be called with
interrupts disabled, but if it sleeps then the next scheduled
thread will probably turn interrupts back on. */
void sema_down(struct semaphore *sema) {
enum intr_level old_level;
ASSERT(sema != NULL);
ASSERT(!intr_context());
old_level = intr_disable();
while (sema->value == 0) {
list_push_back(&sema->waiters, &thread_current()->elem);
thread_block();
}
sema->value--;
intr_set_level(old_level);
}
示例14: timer_sleep
/* Sleeps for approximately TICKS timer ticks. Interrupts must
be turned on. */
void
timer_sleep (int64_t ticks)
{
enum intr_level old_level;
ASSERT (intr_get_level () == INTR_ON);
if (ticks > 0)
{
thread_current ()->sleep_ticks = ticks;
old_level = intr_disable ();
thread_block ();
intr_set_level (old_level);
}
}
示例15: timer_sleep
/* Sleeps for approximately TICKS timer ticks. Interrupts must
be turned on. */
void
timer_sleep (int64_t ticks)
{
ASSERT (intr_get_level () == INTR_ON);
/* ousiri */
if(ticks>0)
{
struct thread *cur = thread_current ();
cur->sleeping_ticks = ticks;
enum intr_level old_intr_level = intr_disable ();
thread_block ();
intr_set_level (old_intr_level);
}
}