예제 #1
0
파일: eventflag.c 프로젝트: Han40/spamOSEK
SYSCALL ER
iset_flg(ID flgid, FLGPTN setptn)
{
    FLGCB	*flgcb;
    TCB	*tcb;
    WINFO_FLG *winfo;
    ER	ercd;

    LOG_ISET_FLG_ENTER(flgid, setptn);
    CHECK_INTCTX_UNL();
    CHECK_FLGID(flgid);
    flgcb = get_flgcb(flgid);

    i_lock_cpu();
    flgcb->flgptn |= setptn;
    if (!(queue_empty(&(flgcb->wait_queue)))) {
        tcb = (TCB *)(flgcb->wait_queue.next);
        winfo = (WINFO_FLG *)(tcb->winfo);
        if (eventflag_cond(flgcb, winfo->waiptn,
                           winfo->wfmode, &(winfo->flgptn))) {
            queue_delete(&(tcb->task_queue));
            if (wait_complete(tcb)) {
                reqflg = TRUE;
            }
        }
    }
    ercd = E_OK;
    i_unlock_cpu();

exit:
    LOG_ISET_FLG_LEAVE(ercd);
    return(ercd);
}
예제 #2
0
파일: eventflag.c 프로젝트: inouema/toppers
ER
iset_flg(ID flgid, FLGPTN setptn)
{
	FLGCB	*p_flgcb;
	QUEUE	*p_queue;
	TCB		*p_tcb;
	WINFO_FLG *p_winfo_flg;
	ER		ercd;
	PCB		*p_pcb;

	LOG_ISET_FLG_ENTER(flgid, setptn);
	CHECK_INTCTX_UNL();
	CHECK_FLGID(flgid);
	p_flgcb = get_flgcb(flgid);

	i_lock_cpu();
	i_acquire_obj_lock(&GET_OBJLOCK(p_flgcb));
	p_flgcb->flgptn |= setptn;
	p_queue = p_flgcb->wait_queue.p_next;
	while (p_queue != &(p_flgcb->wait_queue)) {
		p_tcb = (TCB *) p_queue;
		/* フラグのセットを非破壊コードにできないため,リトライしない */
		p_pcb = acquire_nested_tsk_lock_without_preemption(p_tcb);
		p_queue = p_queue->p_next;
		p_winfo_flg = (WINFO_FLG *)(&(p_tcb->winfo_obj));
		if (check_flg_cond(p_flgcb, p_winfo_flg->waiptn,
							p_winfo_flg->wfmode, &(p_winfo_flg->flgptn))) {
			queue_delete(&(p_tcb->task_queue));
			if (wait_complete(p_tcb)) {
				if (dispatch_request(p_pcb)){
					(get_my_p_pcb())->reqflg = true;
				}
			}
			if ((p_flgcb->p_flginib->flgatr & TA_CLR) != 0U) {
				release_nested_tsk_lock(p_pcb);
				break;
			}
		}
		release_nested_tsk_lock(p_pcb);
	}
	ercd = E_OK;
	release_obj_lock(&GET_OBJLOCK(p_flgcb));
	i_unlock_cpu();

  error_exit:
	LOG_ISET_FLG_LEAVE(ercd);
	return(ercd);
}
ER
iset_flg(ID flgid, FLGPTN setptn)
{
	FLGCB	*p_flgcb;
	QUEUE	*p_queue;
	TCB		*p_tcb;
	WINFO_FLG *p_winfo_flg;
	ER		ercd;

	LOG_ISET_FLG_ENTER(flgid, setptn);
	CHECK_INTCTX_UNL();
	CHECK_FLGID(flgid);
	p_flgcb = get_flgcb(flgid);

	i_lock_cpu();
	if (p_flgcb->p_flginib->flgatr == TA_NOEXS) {
		ercd = E_NOEXS;
	}
	else {
		p_flgcb->flgptn |= setptn;
		p_queue = p_flgcb->wait_queue.p_next;
		while (p_queue != &(p_flgcb->wait_queue)) {
			p_tcb = (TCB *) p_queue;
			p_queue = p_queue->p_next;
			p_winfo_flg = (WINFO_FLG *)(p_tcb->p_winfo);
			if (check_flg_cond(p_flgcb, p_winfo_flg->waiptn,
							p_winfo_flg->wfmode, &(p_winfo_flg->flgptn))) {
				queue_delete(&(p_tcb->task_queue));
				if (wait_complete(p_tcb)) {
					reqflg = true;
				}
				if ((p_flgcb->p_flginib->flgatr & TA_CLR) != 0U) {
					break;
				}
			}
		}
		ercd = E_OK;
	}
	i_unlock_cpu();

  error_exit:
	LOG_ISET_FLG_LEAVE(ercd);
	return(ercd);
}