示例#1
0
文件: native.c 项目: rcn-ee/xenomai-3
int rt_alarm_wait(RT_ALARM *alarm)
{
    struct threadobj *current = threadobj_current();
    struct sched_param_ex param_ex;
    struct trank_alarm_wait *aw;
    struct alchemy_alarm *acb;
    int ret, prio, pulses;

    acb = find_alarm(alarm);
    if (acb == NULL)
        return -EINVAL;

    threadobj_lock(current);
    prio = threadobj_get_priority(current);
    if (prio != threadobj_irq_prio) {
        param_ex.sched_priority = threadobj_irq_prio;
        /* Working on self, so -EIDRM can't happen. */
        threadobj_set_schedparam(current, SCHED_FIFO, &param_ex);
    }
    threadobj_unlock(current);

    aw = acb->arg;

    /*
     * Emulate the original behavior: wait for the next pulse (no
     * event buffering, broadcast to all waiters), while
     * preventing spurious wakeups.
     */
    __RT(pthread_mutex_lock(&aw->lock));

    pulses = aw->alarm_pulses;

    for (;;) {
        ret = -__RT(pthread_cond_wait(&aw->event, &aw->lock));
        if (ret || aw->alarm_pulses != pulses)
            break;
    }

    __RT(pthread_mutex_unlock(&aw->lock));

    return __bt(ret);
}
示例#2
0
void delete_alarm(QALARM *q, pthread_t tid)
{
    QTHREAD *qt;

    pthread_mutex_lock(&(q->q_mutex));

    qt = find_alarm(q, tid);
    if ((qt->prev))
        qt->prev->next = qt->next;
    else
        q->threads = qt->next;

    if ((qt->next))
        qt->next->prev = qt->prev;

    pthread_mutex_unlock(&(q->q_mutex));

    Delete_Queue(qt->queue);
    free(qt);
}
示例#3
0
文件: native.c 项目: rcn-ee/xenomai-3
int rt_alarm_delete(RT_ALARM *alarm)
{
    struct trank_alarm_wait *aw;
    struct alchemy_alarm *acb;
    int ret;

    acb = find_alarm(alarm);
    if (acb == NULL)
        return -EINVAL;

    aw = acb->arg;
    ret = __CURRENT(rt_alarm_delete(alarm));
    if (ret)
        return ret;

    __RT(pthread_cond_destroy(&aw->event));
    __RT(pthread_mutex_destroy(&aw->lock));
    xnfree(aw);

    return 0;
}