Exemplo n.º 1
0
static int dynticks_start_timer(struct qemu_alarm_timer *t)
{
    struct sigevent ev;
    timer_t host_timer;
    struct sigaction act;

    sigfillset(&act.sa_mask);
    act.sa_flags = 0;
    act.sa_handler = host_alarm_handler;

#ifdef CONFIG_COREMU
    int signo;
    (void) ev;

    if (coremu_hw_thr_p()) {
        signo = COREMU_HARDWARE_ALARM;
        sigaction(COREMU_HARDWARE_ALARM, &act, NULL);
    } else {
        /* Core signal handler is registerd before running all core. */
        signo = COREMU_CORE_ALARM;
    }

    if (coremu_timer_create(signo, &host_timer)) {
        perror("timer_create");
        coremu_assert(0, "timer create failed");
        return -1;
    }
#else
    sigaction(SIGALRM, &act, NULL);

    /*
     * Initialize ev struct to 0 to avoid valgrind complaining
     * about uninitialized data in timer_create call
     */
    memset(&ev, 0, sizeof(ev));
    ev.sigev_value.sival_int = 0;
    ev.sigev_notify = SIGEV_SIGNAL;
    ev.sigev_signo = SIGALRM;

    if (timer_create(CLOCK_REALTIME, &ev, &host_timer)) {
        perror("timer_create");

        /* disable dynticks */
        fprintf(stderr, "Dynamic Ticks disabled\n");

        return -1;
    }
#endif
    t->priv = (void *)(long)host_timer;

    return 0;
}
Exemplo n.º 2
0
/* Send an interrupt and notify the accept core
 * Here we use apdaptive signal delay mechanism
 * But this mechanism seems to be wonderful when number of emulated
 * cores is more than 128 (test enviroment R900) */
void coremu_send_intr(void *e, int coreid)
{
    cm_assert(e, "interrupt argument is NULL");
    CMCore *core = coremu_get_core(coreid);

    if (!coremu_init_done_p())
        return;

    coremu_put_intr(core, e);

    /* Call event notifier directly if sending interrupt to self.
     * Note that we still need to put the interrupt in the queue, otherwise, the
     * core will lost this interrupt. */
    if (!coremu_hw_thr_p()) {
        if (core == coremu_get_core_self()) {
            event_notifier();
            return;
        }
    }
    coremu_send_signal(core);
}