SYSCALL ER sig_sem(ID semid) { SEMCB *semcb; TCB *tcb; ER ercd; LOG_SIG_SEM_ENTER(semid); CHECK_TSKCTX_UNL(); CHECK_SEMID(semid); semcb = get_semcb(semid); t_lock_cpu(); if (!(queue_empty(&(semcb->wait_queue)))) { tcb = (TCB *) queue_delete_next(&(semcb->wait_queue)); if (wait_complete(tcb)) { dispatch(); } ercd = E_OK; } else if (semcb->semcnt < semcb->seminib->maxsem) { semcb->semcnt += 1; ercd = E_OK; } else { ercd = E_QOVR; } t_unlock_cpu(); exit: LOG_SIG_SEM_LEAVE(ercd); return(ercd); }
ER sig_sem(ID semid) { SEMCB *p_semcb; TCB *p_tcb; ER ercd; LOG_SIG_SEM_ENTER(semid); CHECK_UNL(); CHECK_ID(VALID_SEMID(semid)); p_semcb = get_semcb(semid); lock_cpu(); if (p_semcb->p_seminib->sematr == TA_NOEXS) { ercd = E_NOEXS; } else if (VIOLATE_ACPTN(p_semcb->p_seminib->acvct.acptn1)) { ercd = E_OACV; } else if (!queue_empty(&(p_semcb->wait_queue))) { p_tcb = (TCB *) queue_delete_next(&(p_semcb->wait_queue)); wait_complete(p_tcb); if (p_runtsk != p_schedtsk) { if (!sense_context()) { dispatch(); } else { request_dispatch_retint(); } } ercd = E_OK; } else if (p_semcb->semcnt < p_semcb->p_seminib->maxsem) { p_semcb->semcnt += 1; ercd = E_OK; } else { ercd = E_QOVR; } unlock_cpu(); error_exit: LOG_SIG_SEM_LEAVE(ercd); return(ercd); }
ER sig_sem(ID semid) { SEMCB *p_semcb; TCB *p_tcb; ER ercd; LOG_SIG_SEM_ENTER(semid); CHECK_TSKCTX_UNL(); CHECK_SEMID(semid); p_semcb = get_semcb(semid); t_lock_cpu(); if (p_semcb->p_seminib->sematr == TA_NOEXS) { ercd = E_NOEXS; } else if (VIOLATE_ACPTN(p_semcb->p_seminib->acvct.acptn1)) { ercd = E_OACV; } else if (!queue_empty(&(p_semcb->wait_queue))) { p_tcb = (TCB *) queue_delete_next(&(p_semcb->wait_queue)); if (wait_complete(p_tcb)) { dispatch(); } ercd = E_OK; } else if (p_semcb->semcnt < p_semcb->p_seminib->maxsem) { p_semcb->semcnt += 1; ercd = E_OK; } else { ercd = E_QOVR; } t_unlock_cpu(); error_exit: LOG_SIG_SEM_LEAVE(ercd); return(ercd); }