ER wup_tsk(ID tskid) { TCB *p_tcb; ER ercd; LOG_WUP_TSK_ENTER(tskid); CHECK_TSKCTX_UNL(); CHECK_TSKID_SELF(tskid); p_tcb = get_tcb_self(tskid); t_lock_cpu(); if (TSTAT_DORMANT(p_tcb->tstat)) { ercd = E_OBJ; } else if (TSTAT_WAIT_SLP(p_tcb->tstat)) { if (wait_complete(p_tcb)) { dispatch(); } ercd = E_OK; } else if (!(p_tcb->wupque)) { p_tcb->wupque = true; ercd = E_OK; } else { ercd = E_QOVR; } t_unlock_cpu(); error_exit: LOG_WUP_TSK_LEAVE(ercd); return(ercd); }
ER iwup_tsk(ID tskid) { TCB *p_tcb; ER ercd; LOG_IWUP_TSK_ENTER(tskid); CHECK_INTCTX_UNL(); CHECK_TSKID(tskid); p_tcb = get_tcb(tskid); i_lock_cpu(); if (TSTAT_DORMANT(p_tcb->tstat)) { ercd = E_OBJ; } else if (TSTAT_WAIT_SLP(p_tcb->tstat)) { if (wait_complete(p_tcb)) { reqflg = true; } ercd = E_OK; } else if (!(p_tcb->wupque)) { p_tcb->wupque = true; ercd = E_OK; } else { ercd = E_QOVR; } i_unlock_cpu(); error_exit: LOG_IWUP_TSK_LEAVE(ercd); return(ercd); }
ER get_pri(ID tskid, PRI *p_tskpri) { TCB *p_tcb; ER ercd; LOG_GET_PRI_ENTER(tskid, p_tskpri); CHECK_TSKCTX_UNL(); /*[NGKI1203][NGKI1204]*/ if (tskid == TSK_SELF) { p_tcb = p_runtsk; /*[NGKI1211]*/ } else { CHECK_ID(VALID_TSKID(tskid)); /*[NGKI1205]*/ p_tcb = get_tcb(tskid); } lock_cpu(); if (TSTAT_DORMANT(p_tcb->tstat)) { ercd = E_OBJ; /*[NGKI1209]*/ } else { *p_tskpri = EXT_TSKPRI(p_tcb->priority); /*[NGKI1210]*/ ercd = E_OK; } unlock_cpu(); error_exit: LOG_GET_PRI_LEAVE(ercd, p_tskpri); return(ercd); }
SYSCALL ER iwup_tsk(ID tskid) { TCB *tcb; UINT tstat; ER ercd; LOG_IWUP_TSK_ENTER(tskid); CHECK_INTCTX_UNL(); CHECK_TSKID(tskid); tcb = get_tcb(tskid); i_lock_cpu(); if (TSTAT_DORMANT(tstat = tcb->tstat)) { ercd = E_OBJ; } else if ((tstat & TS_WAIT_SLEEP) != 0) { if (wait_complete(tcb)) { reqflg = TRUE; } ercd = E_OK; } else if (!(tcb->wupcnt)) { tcb->wupcnt = TRUE; ercd = E_OK; } else { ercd = E_QOVR; } i_unlock_cpu(); exit: LOG_IWUP_TSK_LEAVE(ercd); return(ercd); }
SYSCALL ER_UINT can_wup(ID tskid) { TCB *tcb; ER_UINT ercd; LOG_CAN_WUP_ENTER(tskid); CHECK_TSKCTX_UNL(); CHECK_TSKID_SELF(tskid); tcb = get_tcb_self(tskid); t_lock_cpu(); if (TSTAT_DORMANT(tcb->tstat)) { ercd = E_OBJ; } else { ercd = tcb->wupcnt ? 1 : 0; tcb->wupcnt = FALSE; } t_unlock_cpu(); exit: LOG_CAN_WUP_LEAVE(ercd); return(ercd); }
ER_UINT can_wup(ID tskid) { TCB *p_tcb; ER_UINT ercd; LOG_CAN_WUP_ENTER(tskid); CHECK_TSKCTX_UNL(); CHECK_TSKID_SELF(tskid); p_tcb = get_tcb_self(tskid); t_lock_cpu(); if (TSTAT_DORMANT(p_tcb->tstat)) { ercd = E_OBJ; } else { ercd = p_tcb->wupque ? 1 : 0; p_tcb->wupque = false; } t_unlock_cpu(); error_exit: LOG_CAN_WUP_LEAVE(ercd); return(ercd); }
ER iact_tsk(ID tskid) { TCB *p_tcb; ER ercd; LOG_IACT_TSK_ENTER(tskid); CHECK_INTCTX_UNL(); CHECK_TSKID(tskid); p_tcb = get_tcb(tskid); i_lock_cpu(); if (TSTAT_DORMANT(p_tcb->tstat)) { if (make_active(p_tcb)) { reqflg = true; } ercd = E_OK; } else if (!(p_tcb->actque)) { p_tcb->actque = true; ercd = E_OK; } else { ercd = E_QOVR; } i_unlock_cpu(); error_exit: LOG_IACT_TSK_LEAVE(ercd); return(ercd); }
JSP_L1_CODE SYSCALL ER ras_tex(ID tskid, TEXPTN rasptn) { TCB *tcb; ER ercd; LOG_RAS_TEX_ENTER(tskid, rasptn); CHECK_TSKCTX_UNL(); CHECK_TSKID_SELF(tskid); CHECK_PAR(rasptn != 0); tcb = get_tcb_self(tskid); t_lock_cpu(); if (TSTAT_DORMANT(tcb->tstat) || tcb->tinib->texrtn == NULL) { ercd = E_OBJ; } else { tcb->texptn |= rasptn; if (tcb == runtsk && runtsk->enatex) { call_texrtn(); } ercd = E_OK; } t_unlock_cpu(); exit: LOG_RAS_TEX_LEAVE(ercd); return(ercd); }
SYSCALL ER iact_tsk(ID tskid) { TCB *tcb; ER ercd; LOG_IACT_TSK_ENTER(tskid); CHECK_INTCTX_UNL(); CHECK_TSKID(tskid); tcb = get_tcb(tskid); i_lock_cpu(); if (TSTAT_DORMANT(tcb->tstat)) { if (make_active(tcb)) { reqflg = TRUE; } ercd = E_OK; } else if (!(tcb->actcnt)) { tcb->actcnt = TRUE; ercd = E_OK; } else { ercd = E_QOVR; } i_unlock_cpu(); exit: LOG_IACT_TSK_LEAVE(ercd); return(ercd); }
ER get_pri(ID tskid, PRI *p_tskpri) { TCB *p_tcb; ER ercd; PCB *p_pcb; LOG_GET_PRI_ENTER(tskid, p_tskpri); CHECK_TSKCTX_UNL(); CHECK_TSKID_SELF(tskid); t_lock_cpu(); p_tcb = get_tcb_self(tskid, get_my_p_pcb()); p_pcb = t_acquire_tsk_lock(p_tcb); if (TSTAT_DORMANT(p_tcb->tstat)) { ercd = E_OBJ; } else { *p_tskpri = EXT_TSKPRI(p_tcb->priority); ercd = E_OK; } release_tsk_lock(p_pcb); t_unlock_cpu(); error_exit: LOG_GET_PRI_LEAVE(ercd, *p_tskpri); return(ercd); }
SYSCALL ER get_pri(ID tskid, PRI *p_tskpri) { TCB *tcb; ER ercd; LOG_GET_PRI_ENTER(tskid, p_tskpri); CHECK_TSKCTX_UNL(); CHECK_TSKID_SELF(tskid); tcb = get_tcb_self(tskid); t_lock_cpu(); if (TSTAT_DORMANT(tcb->tstat)) { ercd = E_OBJ; } else { *p_tskpri = EXT_TSKPRI(tcb->priority); ercd = E_OK; } t_unlock_cpu(); exit: LOG_GET_PRI_LEAVE(ercd, *p_tskpri); return(ercd); }
SYSCALL ER act_tsk(ID tskid) { TCB *tcb; ER ercd; LOG_ACT_TSK_ENTER(tskid); CHECK_TSKCTX_UNL(); CHECK_TSKID_SELF(tskid); tcb = get_tcb_self(tskid); t_lock_cpu(); if (TSTAT_DORMANT(tcb->tstat)) { if (make_active(tcb)) { dispatch(); } ercd = E_OK; } else if (!(tcb->actcnt)) { tcb->actcnt = TRUE; ercd = E_OK; } else { ercd = E_QOVR; } t_unlock_cpu(); exit: LOG_ACT_TSK_LEAVE(ercd); return(ercd); }
ER ena_wai(ID tskid) { TCB *p_tcb; ER ercd; LOG_ENA_WAI_ENTER(tskid); CHECK_TSKCTX_UNL(); CHECK_TSKID_SELF(tskid); p_tcb = get_tcb_self(tskid); t_lock_cpu(); if (p_tcb->p_tinib->tskatr == TA_NOEXS) { ercd = E_NOEXS; } else if (VIOLATE_ACPTN(p_tcb->p_tinib->acvct.acptn2)) { ercd = E_OACV; } else if (TSTAT_DORMANT(p_tcb->tstat) || !(p_tcb->waifbd)) { ercd = E_OBJ; } else { p_tcb->waifbd = false; ercd = E_OK; } t_unlock_cpu(); error_exit: LOG_ENA_WAI_LEAVE(ercd); return(ercd); }
ER iena_wai(ID tskid) { TCB *p_tcb; ER ercd; LOG_IENA_WAI_ENTER(tskid); CHECK_INTCTX_UNL(); CHECK_TSKID(tskid); p_tcb = get_tcb(tskid); i_lock_cpu(); if (p_tcb->p_tinib->tskatr == TA_NOEXS) { ercd = E_NOEXS; } else if (TSTAT_DORMANT(p_tcb->tstat) || !(p_tcb->waifbd)) { ercd = E_OBJ; } else { p_tcb->waifbd = false; ercd = E_OK; } i_unlock_cpu(); error_exit: LOG_IENA_WAI_LEAVE(ercd); return(ercd); }
JSP_L1_CODE SYSCALL ER iras_tex(ID tskid, TEXPTN rasptn) { TCB *tcb; ER ercd; LOG_IRAS_TEX_ENTER(tskid, rasptn); CHECK_INTCTX_UNL(); CHECK_TSKID(tskid); CHECK_PAR(rasptn != 0); tcb = get_tcb(tskid); i_lock_cpu(); if (TSTAT_DORMANT(tcb->tstat) || tcb->tinib->texrtn == NULL) { ercd = E_OBJ; } else { tcb->texptn |= rasptn; if (tcb == runtsk && runtsk->enatex) { reqflg = TRUE; } ercd = E_OK; } i_unlock_cpu(); exit: LOG_IRAS_TEX_LEAVE(ercd); return(ercd); }
ER idis_wai(ID tskid) { TCB *p_tcb; ER ercd; LOG_IDIS_WAI_ENTER(tskid); CHECK_INTCTX_UNL(); CHECK_TSKID(tskid); p_tcb = get_tcb(tskid); i_lock_cpu(); if (p_tcb->p_tinib->tskatr == TA_NOEXS) { ercd = E_NOEXS; } else if (TSTAT_DORMANT(p_tcb->tstat)) { ercd = E_OBJ; } else if (p_tcb->waifbd) { ercd = E_QOVR; } else if (i_sense_texmask(p_tcb)) { p_tcb->waifbd = true; ercd = E_OK; } else { ercd = E_OBJ; } i_unlock_cpu(); error_exit: LOG_IDIS_WAI_LEAVE(ercd); return(ercd); }
ER chg_pri(ID tskid, PRI tskpri) { TCB *p_tcb; uint_t newpri; ER ercd; LOG_CHG_PRI_ENTER(tskid, tskpri); CHECK_TSKCTX_UNL(); CHECK_TSKID_SELF(tskid); CHECK_TPRI_INI(tskpri); p_tcb = get_tcb_self(tskid); newpri = (tskpri == TPRI_INI) ? p_tcb->p_tinib->ipriority : INT_PRIORITY(tskpri); t_lock_cpu(); if (TSTAT_DORMANT(p_tcb->tstat)) { ercd = E_OBJ; } else { if (change_priority(p_tcb, newpri)) { dispatch(); } ercd = E_OK; } t_unlock_cpu(); error_exit: LOG_CHG_PRI_LEAVE(ercd); return(ercd); }
ER_UINT can_wup(ID tskid) { TCB *p_tcb; ER_UINT ercd; LOG_CAN_WUP_ENTER(tskid); CHECK_TSKCTX_UNL(); CHECK_TSKID_SELF(tskid); p_tcb = get_tcb_self(tskid); t_lock_cpu(); if (p_tcb->p_tinib->tskatr == TA_NOEXS) { ercd = E_NOEXS; } else if (VIOLATE_ACPTN(p_tcb->p_tinib->acvct.acptn1)) { ercd = E_OACV; } else if (TSTAT_DORMANT(p_tcb->tstat)) { ercd = E_OBJ; } else { ercd = p_tcb->wupque ? 1 : 0; p_tcb->wupque = false; } t_unlock_cpu(); error_exit: LOG_CAN_WUP_LEAVE(ercd); return(ercd); }
ER_UINT can_wup(ID tskid) { TCB *p_tcb; ER_UINT ercd; LOG_CAN_WUP_ENTER(tskid); CHECK_TSKCTX_UNL(); if (tskid == TSK_SELF) { p_tcb = p_runtsk; } else { CHECK_ID(VALID_TSKID(tskid)); p_tcb = get_tcb(tskid); } lock_cpu(); if (p_tcb->p_tinib->tskatr == TA_NOEXS) { ercd = E_NOEXS; } else if (TSTAT_DORMANT(p_tcb->tstat)) { ercd = E_OBJ; } else { ercd = p_tcb->wupque ? 1 : 0; p_tcb->wupque = false; } unlock_cpu(); error_exit: LOG_CAN_WUP_LEAVE(ercd); return(ercd); }
ER act_tsk(ID tskid) { TCB *p_tcb; ER ercd; LOG_ACT_TSK_ENTER(tskid); CHECK_TSKCTX_UNL(); CHECK_TSKID_SELF(tskid); p_tcb = get_tcb_self(tskid); t_lock_cpu(); if (TSTAT_DORMANT(p_tcb->tstat)) { if (make_active(p_tcb)) { dispatch(); } ercd = E_OK; } else if (!(p_tcb->actque)) { p_tcb->actque = true; ercd = E_OK; } else { ercd = E_QOVR; } t_unlock_cpu(); error_exit: LOG_ACT_TSK_LEAVE(ercd); return(ercd); }
ER get_pri(ID tskid, PRI *p_tskpri) { TCB *p_tcb; ER ercd; LOG_GET_PRI_ENTER(tskid, p_tskpri); CHECK_TSKCTX_UNL(); CHECK_TSKID_SELF(tskid); CHECK_MACV_WRITE(p_tskpri, PRI); p_tcb = get_tcb_self(tskid); t_lock_cpu(); if (p_tcb->p_tinib->tskatr == TA_NOEXS) { ercd = E_NOEXS; } else if (VIOLATE_ACPTN(p_tcb->p_tinib->acvct.acptn4)) { ercd = E_OACV; } else if (TSTAT_DORMANT(p_tcb->tstat)) { ercd = E_OBJ; } else { *p_tskpri = EXT_TSKPRI(p_tcb->priority); ercd = E_OK; } t_unlock_cpu(); error_exit: LOG_GET_PRI_LEAVE(ercd, *p_tskpri); return(ercd); }
SYSCALL ER wup_tsk(ID tskid) { TCB *tcb; UINT tstat; ER ercd; LOG_WUP_TSK_ENTER(tskid); CHECK_TSKCTX_UNL(); CHECK_TSKID_SELF(tskid); tcb = get_tcb_self(tskid); t_lock_cpu(); if (TSTAT_DORMANT(tstat = tcb->tstat)) { ercd = E_OBJ; } else if ((tstat & TS_WAIT_SLEEP) != 0) { if (wait_complete(tcb)) { dispatch(); } ercd = E_OK; } else if (!(tcb->wupcnt)) { tcb->wupcnt = TRUE; ercd = E_OK; } else { ercd = E_QOVR; } t_unlock_cpu(); exit: LOG_WUP_TSK_LEAVE(ercd); return(ercd); }
ER ter_tsk(ID tskid) { TCB *p_tcb; bool_t dspreq = false; ER ercd; LOG_TER_TSK_ENTER(tskid); CHECK_TSKCTX_UNL(); CHECK_TSKID(tskid); p_tcb = get_tcb(tskid); CHECK_NONSELF(p_tcb); t_lock_cpu(); if (p_tcb->p_tinib->tskatr == TA_NOEXS) { ercd = E_NOEXS; } else if (VIOLATE_ACPTN(p_tcb->p_tinib->acvct.acptn2)) { ercd = E_OACV; } else if (TSTAT_DORMANT(p_tcb->tstat)) { ercd = E_OBJ; } else { if (TSTAT_RUNNABLE(p_tcb->tstat)) { /* * p_tcbは自タスクでないため,(シングルプロセッサでは)実 * 行状態でなく,make_non_runnable(p_tcb)でタスクディスパッ * チが必要になることはない. */ (void) make_non_runnable(p_tcb); } else if (TSTAT_WAITING(p_tcb->tstat)) { wait_dequeue_wobj(p_tcb); wait_dequeue_tmevtb(p_tcb); } if (!queue_empty(&(p_tcb->mutex_queue))) { if ((*mtxhook_release_all)(p_tcb)) { dspreq = true; } } make_dormant(p_tcb); if (p_tcb->actque) { p_tcb->actque = false; if (make_active(p_tcb)) { dspreq = true; } } if (dspreq) { dispatch(); } ercd = E_OK; } t_unlock_cpu(); error_exit: LOG_TER_TSK_LEAVE(ercd); return(ercd); }
ER sus_tsk(ID tskid) { TCB *p_tcb; ER ercd; LOG_SUS_TSK_ENTER(tskid); CHECK_TSKCTX_UNL(); /*[NGKI1299][NGKI1300]*/ if (tskid == TSK_SELF) { p_tcb = p_runtsk; /*[NGKI1310]*/ } else { CHECK_ID(VALID_TSKID(tskid)); /*[NGKI1302]*/ p_tcb = get_tcb(tskid); } lock_cpu(); if (p_tcb == p_runtsk && !dspflg) { /*[NGKI1311][NGKI3604]*/ ercd = E_CTX; } else if (p_tcb->p_tinib->tskatr == TA_NOEXS) { ercd = E_NOEXS; /*[NGKI1303]*/ } else if (TSTAT_DORMANT(p_tcb->tstat)) { ercd = E_OBJ; /*[NGKI1305]*/ } else if (p_tcb->raster) { ercd = E_RASTER; /*[NGKI3605]*/ } else if (TSTAT_RUNNABLE(p_tcb->tstat)) { /* * 実行できる状態から強制待ち状態への遷移[NGKI1307] */ p_tcb->tstat = TS_SUSPENDED; LOG_TSKSTAT(p_tcb); make_non_runnable(p_tcb); if (p_runtsk != p_schedtsk) { dispatch(); } ercd = E_OK; } else if (TSTAT_SUSPENDED(p_tcb->tstat)) { ercd = E_QOVR; /*[NGKI1306]*/ } else { /* * 待ち状態から二重待ち状態への遷移[NGKI1308] */ p_tcb->tstat |= TS_SUSPENDED; LOG_TSKSTAT(p_tcb); ercd = E_OK; } unlock_cpu(); error_exit: LOG_SUS_TSK_LEAVE(ercd); return(ercd); }
ER sus_tsk(ID tskid) { TCB *p_tcb; ER ercd; LOG_SUS_TSK_ENTER(tskid); CHECK_TSKCTX_UNL(); CHECK_TSKID_SELF(tskid); p_tcb = get_tcb_self(tskid); t_lock_cpu(); if (p_tcb == p_runtsk && !dspflg) { ercd = E_CTX; } else if (p_tcb->p_tinib->tskatr == TA_NOEXS) { ercd = E_NOEXS; } else if (VIOLATE_ACPTN(p_tcb->p_tinib->acvct.acptn2)) { ercd = E_OACV; } else if (TSTAT_DORMANT(p_tcb->tstat)) { ercd = E_OBJ; } else if (TSTAT_RUNNABLE(p_tcb->tstat)) { /* * 実行できる状態から強制待ち状態への遷移 */ p_tcb->tstat = TS_SUSPENDED; LOG_TSKSTAT(p_tcb); if (make_non_runnable(p_tcb)) { dispatch(); } ercd = E_OK; } else if (TSTAT_SUSPENDED(p_tcb->tstat)) { ercd = E_QOVR; } else { /* * 待ち状態から二重待ち状態への遷移 */ p_tcb->tstat |= TS_SUSPENDED; LOG_TSKSTAT(p_tcb); ercd = E_OK; } t_unlock_cpu(); error_exit: LOG_SUS_TSK_LEAVE(ercd); return(ercd); }
ER chg_pri(ID tskid, PRI tskpri) { TCB *p_tcb; uint_t newbpri; ER ercd; LOG_CHG_PRI_ENTER(tskid, tskpri); CHECK_TSKCTX_UNL(); CHECK_TSKID_SELF(tskid); CHECK_TPRI_INI(tskpri); p_tcb = get_tcb_self(tskid); t_lock_cpu(); if (p_tcb->p_tinib->tskatr == TA_NOEXS) { ercd = E_NOEXS; } else if (VIOLATE_ACPTN(p_tcb->p_tinib->acvct.acptn2)) { ercd = E_OACV; } else if (TSTAT_DORMANT(p_tcb->tstat)) { ercd = E_OBJ; } else { newbpri = (tskpri == TPRI_INI) ? p_tcb->p_tinib->ipriority : INT_PRIORITY(tskpri); if (!(newbpri >= p_runtsk->p_tinib->p_dominib->minpriority)) { ercd = E_ILUSE; } else if ((!queue_empty(&(p_tcb->mutex_queue)) || TSTAT_WAIT_MTX(p_tcb->tstat)) && !((*mtxhook_check_ceilpri)(p_tcb, newbpri))) { ercd = E_ILUSE; } else { p_tcb->bpriority = newbpri; if (queue_empty(&(p_tcb->mutex_queue)) || !((*mtxhook_scan_ceilmtx)(p_tcb))) { if (change_priority(p_tcb, newbpri, false)) { dispatch(); } } ercd = E_OK; } } t_unlock_cpu(); error_exit: LOG_CHG_PRI_LEAVE(ercd); return(ercd); }
ER chg_pri(ID tskid, PRI tskpri) { TCB *p_tcb; uint_t newbpri; ER ercd; LOG_CHG_PRI_ENTER(tskid, tskpri); CHECK_TSKCTX_UNL(); /*[NGKI1184][NGKI1185]*/ if (tskid == TSK_SELF) { p_tcb = p_runtsk; /*[NGKI1198]*/ } else { CHECK_ID(VALID_TSKID(tskid)); /*[NGKI1187]*/ p_tcb = get_tcb(tskid); } if (tskpri == TPRI_INI) { newbpri = p_tcb->p_tinib->ipriority; /*[NGKI1199]*/ } else { CHECK_PAR(VALID_TPRI(tskpri)); /*[NGKI1188]*/ newbpri = INT_PRIORITY(tskpri); } lock_cpu(); if (p_tcb->p_tinib->tskatr == TA_NOEXS) { ercd = E_NOEXS; /*[NGKI1189]*/ } else if (TSTAT_DORMANT(p_tcb->tstat)) { ercd = E_OBJ; /*[NGKI1191]*/ } else if ((p_tcb->p_lastmtx != NULL || TSTAT_WAIT_MTX(p_tcb->tstat)) && !((*mtxhook_check_ceilpri)(p_tcb, newbpri))) { ercd = E_ILUSE; /*[NGKI1201]*/ } else { p_tcb->bpriority = newbpri; /*[NGKI1192]*/ if (p_tcb->p_lastmtx == NULL || !((*mtxhook_scan_ceilmtx)(p_tcb))) { change_priority(p_tcb, newbpri, false); /*[NGKI1193]*/ if (p_runtsk != p_schedtsk) { dispatch(); } /*[NGKI1197]*/ } ercd = E_OK; } unlock_cpu(); error_exit: LOG_CHG_PRI_LEAVE(ercd); return(ercd); }
ER get_tst(ID tskid, STAT *p_tskstat) { TCB *p_tcb; uint_t tstat; ER ercd; LOG_GET_TST_ENTER(tskid, p_tskstat); CHECK_TSKCTX_UNL(); /*[NGKI3614][NGKI3615]*/ if (tskid == TSK_SELF) { p_tcb = p_runtsk; /*[NGKI3621]*/ } else { CHECK_ID(VALID_TSKID(tskid)); /*[NGKI3616]*/ p_tcb = get_tcb(tskid); } lock_cpu(); tstat = p_tcb->tstat; if (p_tcb->p_tinib->tskatr == TA_NOEXS) { ercd = E_NOEXS; /*[NGKI3617]*/ } else if (TSTAT_DORMANT(tstat)) { /*[NGKI3620]*/ *p_tskstat = TTS_DMT; } else if (TSTAT_SUSPENDED(tstat)) { if (TSTAT_WAITING(tstat)) { *p_tskstat = TTS_WAS; } else { *p_tskstat = TTS_SUS; } } else if (TSTAT_WAITING(tstat)) { *p_tskstat = TTS_WAI; } else if (p_tcb == p_runtsk) { *p_tskstat = TTS_RUN; } else { *p_tskstat = TTS_RDY; } ercd = E_OK; unlock_cpu(); error_exit: LOG_GET_TST_LEAVE(ercd, p_tskstat); return(ercd); }
ER wup_tsk(ID tskid) { TCB *p_tcb; ER ercd; LOG_WUP_TSK_ENTER(tskid); CHECK_UNL(); if (tskid == TSK_SELF && !sense_context()) { p_tcb = p_runtsk; } else { CHECK_ID(VALID_TSKID(tskid)); p_tcb = get_tcb(tskid); } lock_cpu(); if (p_tcb->p_tinib->tskatr == TA_NOEXS) { ercd = E_NOEXS; } else if (TSTAT_DORMANT(p_tcb->tstat)) { ercd = E_OBJ; } else if (TSTAT_WAIT_SLP(p_tcb->tstat)) { wait_complete(p_tcb); if (p_runtsk != p_schedtsk) { if (!sense_context()) { dispatch(); } else { request_dispatch(); } } ercd = E_OK; } else if (!(p_tcb->wupque)) { p_tcb->wupque = true; ercd = E_OK; } else { ercd = E_QOVR; } unlock_cpu(); error_exit: LOG_WUP_TSK_LEAVE(ercd); return(ercd); }
SYSCALL ER sus_tsk(ID tskid) { TCB *tcb; UINT tstat; ER ercd; LOG_SUS_TSK_ENTER(tskid); CHECK_TSKCTX_UNL(); CHECK_TSKID_SELF(tskid); tcb = get_tcb_self(tskid); t_lock_cpu(); if (tcb == runtsk && !(enadsp)) { ercd = E_CTX; } else if (TSTAT_DORMANT(tstat = tcb->tstat)) { ercd = E_OBJ; } else if (TSTAT_RUNNABLE(tstat)) { /* * 実行できる状態から強制待ち状態への遷移 */ tcb->tstat = TS_SUSPENDED; LOG_TSKSTAT(tcb); if (make_non_runnable(tcb)) { dispatch(); } ercd = E_OK; } else if (TSTAT_SUSPENDED(tstat)) { ercd = E_QOVR; } else { /* * 待ち状態から二重待ち状態への遷移 */ tcb->tstat |= TS_SUSPENDED; LOG_TSKSTAT(tcb); ercd = E_OK; } t_unlock_cpu(); exit: LOG_SUS_TSK_LEAVE(ercd); return(ercd); }