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 dly_tsk(RELTIM dlytim) { WINFO winfo; TMEVTB tmevtb; ER ercd; LOG_DLY_TSK_ENTER(dlytim); CHECK_DISPATCH(); CHECK_PAR(dlytim <= TMAX_RELTIM); t_lock_cpu(); if (p_runtsk->waifbd) { ercd = E_RLWAI; } else { p_runtsk->tstat = (TS_WAITING | TS_WAIT_DLY); (void) make_non_runnable(p_runtsk); p_runtsk->p_winfo = &winfo; winfo.p_tmevtb = &tmevtb; tmevtb_enqueue(&tmevtb, dlytim, (CBACK) wait_tmout_ok, (void *) p_runtsk); LOG_TSKSTAT(p_runtsk); dispatch(); ercd = winfo.wercd; } t_unlock_cpu(); error_exit: LOG_DLY_TSK_LEAVE(ercd); return(ercd); }
ER tslp_tsk(TMO tmout) { WINFO winfo; TMEVTB tmevtb; ER ercd; LOG_TSLP_TSK_ENTER(tmout); CHECK_DISPATCH(); CHECK_PAR(VALID_TMOUT(tmout)); lock_cpu_dsp(); if (p_runtsk->raster) { ercd = E_RASTER; } else if (p_runtsk->wupque) { p_runtsk->wupque = false; ercd = E_OK; } else if (tmout == TMO_POL) { ercd = E_TMOUT; } else { p_runtsk->tstat = TS_WAITING_SLP; make_wait_tmout(&winfo, &tmevtb, tmout); LOG_TSKSTAT(p_runtsk); dispatch(); ercd = winfo.wercd; } unlock_cpu_dsp(); error_exit: LOG_TSLP_TSK_LEAVE(ercd); return(ercd); }
SYSCALL ER dly_tsk(RELTIM dlytim) { WINFO winfo; TMEVTB tmevtb; ER ercd; LOG_DLY_TSK_ENTER(dlytim); CHECK_DISPATCH(); CHECK_PAR(dlytim <= TMAX_RELTIM); t_lock_cpu(); runtsk->tstat = TS_WAITING; make_non_runnable(runtsk); runtsk->winfo = &winfo; winfo.tmevtb = &tmevtb; tmevtb_enqueue(&tmevtb, dlytim, (CBACK) wait_tmout_ok, (VP) runtsk); LOG_TSKSTAT(runtsk); dispatch(); ercd = winfo.wercd; t_unlock_cpu(); exit: LOG_DLY_TSK_LEAVE(ercd); return(ercd); }
ER tslp_tsk(TMO tmout) { WINFO winfo; TMEVTB tmevtb; ER ercd; LOG_TSLP_TSK_ENTER(tmout); CHECK_DISPATCH(); CHECK_TMOUT(tmout); t_lock_cpu(); if (p_runtsk->wupque) { p_runtsk->wupque = false; ercd = E_OK; } else if (tmout == TMO_POL) { ercd = E_TMOUT; } else if (p_runtsk->waifbd) { ercd = E_RLWAI; } else { p_runtsk->tstat = (TS_WAITING | TS_WAIT_SLP); make_wait_tmout(&winfo, &tmevtb, tmout); LOG_TSKSTAT(p_runtsk); dispatch(); ercd = winfo.wercd; } t_unlock_cpu(); error_exit: LOG_TSLP_TSK_LEAVE(ercd); return(ercd); }
ER slp_tsk(void) { WINFO winfo; ER ercd; LOG_SLP_TSK_ENTER(); CHECK_DISPATCH(); t_lock_cpu(); if (p_runtsk->wupque) { p_runtsk->wupque = false; ercd = E_OK; } else if (p_runtsk->waifbd) { ercd = E_RLWAI; } else { p_runtsk->tstat = (TS_WAITING | TS_WAIT_SLP); make_wait(&winfo); LOG_TSKSTAT(p_runtsk); dispatch(); ercd = winfo.wercd; } t_unlock_cpu(); error_exit: LOG_SLP_TSK_LEAVE(ercd); return(ercd); }
SYSCALL ER slp_tsk() { WINFO winfo; ER ercd; LOG_SLP_TSK_ENTER(); CHECK_DISPATCH(); t_lock_cpu(); if (runtsk->wupcnt) { runtsk->wupcnt = FALSE; ercd = E_OK; } else { runtsk->tstat = (TS_WAITING | TS_WAIT_SLEEP); make_wait(&winfo); LOG_TSKSTAT(runtsk); dispatch(); ercd = winfo.wercd; } t_unlock_cpu(); exit: LOG_SLP_TSK_LEAVE(ercd); return(ercd); }
SYSCALL ER tslp_tsk(TMO tmout) { WINFO winfo; TMEVTB tmevtb; ER ercd; LOG_TSLP_TSK_ENTER(tmout); CHECK_DISPATCH(); CHECK_TMOUT(tmout); t_lock_cpu(); if (runtsk->wupcnt) { runtsk->wupcnt = FALSE; ercd = E_OK; } else if (tmout == TMO_POL) { ercd = E_TMOUT; } else { runtsk->tstat = (TS_WAITING | TS_WAIT_SLEEP); make_wait_tmout(&winfo, &tmevtb, tmout); LOG_TSKSTAT(runtsk); dispatch(); ercd = winfo.wercd; } t_unlock_cpu(); exit: LOG_TSLP_TSK_LEAVE(ercd); return(ercd); }
ER dly_tsk(RELTIM dlytim) { WINFO winfo; TMEVTB tmevtb; ER ercd; LOG_DLY_TSK_ENTER(dlytim); CHECK_DISPATCH(); CHECK_PAR(VALID_RELTIM(dlytim)); lock_cpu_dsp(); if (p_runtsk->raster) { ercd = E_RASTER; } else { p_runtsk->tstat = TS_WAITING_DLY; make_non_runnable(p_runtsk); p_runtsk->p_winfo = &winfo; winfo.p_tmevtb = &tmevtb; tmevtb.callback = (CBACK) wait_tmout_ok; tmevtb.arg = (void *) p_runtsk; tmevtb_enqueue(&tmevtb, dlytim); LOG_TSKSTAT(p_runtsk); dispatch(); ercd = winfo.wercd; } unlock_cpu_dsp(); error_exit: LOG_DLY_TSK_LEAVE(ercd); return(ercd); }
ER slp_tsk(void) { WINFO winfo; ER ercd; LOG_SLP_TSK_ENTER(); CHECK_DISPATCH(); lock_cpu_dsp(); if (p_runtsk->raster) { ercd = E_RASTER; } else if (p_runtsk->wupque) { p_runtsk->wupque = false; ercd = E_OK; } else { p_runtsk->tstat = TS_WAITING_SLP; make_wait(&winfo); LOG_TSKSTAT(p_runtsk); dispatch(); ercd = winfo.wercd; } unlock_cpu_dsp(); error_exit: LOG_SLP_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); }
void wobj_make_wait(WOBJCB *p_wobjcb, WINFO_WOBJ *p_winfo_wobj) { make_wait((WINFO *) p_winfo_wobj); wobj_queue_insert(p_wobjcb); p_winfo_wobj->p_wobjcb = p_wobjcb; LOG_TSKSTAT(p_runtsk); }
void wobj_make_wait(WOBJCB *p_wobjcb, uint_t tstat, WINFO_WOBJ *p_winfo_wobj) { make_wait(tstat, &(p_winfo_wobj->winfo)); wobj_queue_insert(p_wobjcb); p_winfo_wobj->p_wobjcb = p_wobjcb; LOG_TSKSTAT(p_runtsk); }
ER rsm_tsk(ID tskid) { TCB *p_tcb; ER ercd; LOG_RSM_TSK_ENTER(tskid); CHECK_TSKCTX_UNL(); CHECK_TSKID(tskid); p_tcb = get_tcb(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_SUSPENDED(p_tcb->tstat)) { ercd = E_OBJ; } else if (!TSTAT_WAITING(p_tcb->tstat)) { /* * 強制待ち状態から実行できる状態への遷移 */ p_tcb->tstat = TS_RUNNABLE; LOG_TSKSTAT(p_tcb); if (make_runnable(p_tcb)) { dispatch(); } ercd = E_OK; } else { /* * 二重待ち状態から待ち状態への遷移 */ p_tcb->tstat &= ~TS_SUSPENDED; LOG_TSKSTAT(p_tcb); ercd = E_OK; } t_unlock_cpu(); error_exit: LOG_RSM_TSK_LEAVE(ercd); return(ercd); }
void wobj_make_wait_tmout(WOBJCB *p_wobjcb, WINFO_WOBJ *p_winfo_wobj, TMEVTB *p_tmevtb, TMO tmout) { make_wait_tmout((WINFO *) p_winfo_wobj, p_tmevtb, tmout); wobj_queue_insert(p_wobjcb); p_winfo_wobj->p_wobjcb = p_wobjcb; LOG_TSKSTAT(p_runtsk); }
void wobj_make_wait(WOBJCB *wobjcb, WINFO_WOBJ *winfo) { runtsk->tstat = (TS_WAITING | TS_WAIT_WOBJ | TS_WAIT_WOBJCB); make_wait(&(winfo->winfo)); wobj_queue_insert(wobjcb); winfo->wobjcb = wobjcb; LOG_TSKSTAT(runtsk); }
ER rsm_tsk(ID tskid) { TCB *p_tcb; ER ercd; LOG_RSM_TSK_ENTER(tskid); CHECK_TSKCTX_UNL(); 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_SUSPENDED(p_tcb->tstat)) { ercd = E_OBJ; } else if (!TSTAT_WAITING(p_tcb->tstat)) { /* * 強制待ち状態から実行できる状態への遷移 */ p_tcb->tstat = TS_RUNNABLE; LOG_TSKSTAT(p_tcb); make_runnable(p_tcb); if (p_runtsk != p_schedtsk) { dispatch(); } ercd = E_OK; } else { /* * 二重待ち状態から待ち状態への遷移 */ p_tcb->tstat &= ~TS_SUSPENDED; LOG_TSKSTAT(p_tcb); ercd = E_OK; } unlock_cpu(); error_exit: LOG_RSM_TSK_LEAVE(ercd); return(ercd); }
ER trcv_pdq(ID pdqid, intptr_t *p_data, PRI *p_datapri, TMO tmout) { PDQCB *p_pdqcb; WINFO_PDQ winfo_pdq; TMEVTB tmevtb; bool_t dspreq; ER ercd; LOG_TRCV_PDQ_ENTER(pdqid, p_data, p_datapri, tmout); CHECK_DISPATCH(); CHECK_PDQID(pdqid); CHECK_MACV_WRITE(p_data, intptr_t); CHECK_MACV_WRITE(p_datapri, PRI); CHECK_TMOUT(tmout); p_pdqcb = get_pdqcb(pdqid); t_lock_cpu(); if (p_pdqcb->p_pdqinib->pdqatr == TA_NOEXS) { ercd = E_NOEXS; } else if (VIOLATE_ACPTN(p_pdqcb->p_pdqinib->acvct.acptn2)) { ercd = E_OACV; } else if (receive_pridata(p_pdqcb, p_data, p_datapri, &dspreq)) { if (dspreq) { dispatch(); } ercd = E_OK; } else if (tmout == TMO_POL) { ercd = E_TMOUT; } else if (p_runtsk->waifbd) { ercd = E_RLWAI; } else { p_runtsk->tstat = (TS_WAITING | TS_WAIT_RPDQ); make_wait_tmout(&(winfo_pdq.winfo), &tmevtb, tmout); queue_insert_prev(&(p_pdqcb->rwait_queue), &(p_runtsk->task_queue)); winfo_pdq.p_pdqcb = p_pdqcb; LOG_TSKSTAT(p_runtsk); dispatch(); ercd = winfo_pdq.winfo.wercd; if (ercd == E_OK) { *p_data = winfo_pdq.data; *p_datapri = winfo_pdq.datapri; } } t_unlock_cpu(); error_exit: LOG_TRCV_PDQ_LEAVE(ercd, *p_data, *p_datapri); return(ercd); }
void wobj_make_wait_tmout(WOBJCB *wobjcb, WINFO_WOBJ *winfo, TMEVTB *tmevtb, TMO tmout) { runtsk->tstat = (TS_WAITING | TS_WAIT_WOBJ | TS_WAIT_WOBJCB); make_wait_tmout(&(winfo->winfo), tmevtb, tmout); wobj_queue_insert(wobjcb); winfo->wobjcb = wobjcb; LOG_TSKSTAT(runtsk); }
ER trcv_mbf(ID mbfid, void *msg, TMO tmout) { MBFCB *p_mbfcb; WINFO_RMBF winfo_rmbf; TMEVTB tmevtb; uint_t msgsz; ER_UINT ercd; LOG_TRCV_MBF_ENTER(mbfid, msg, tmout); CHECK_DISPATCH(); CHECK_ID(VALID_MBFID(mbfid)); CHECK_PAR(VALID_TMOUT(tmout)); p_mbfcb = get_mbfcb(mbfid); lock_cpu_dsp(); if (p_mbfcb->p_mbfinib->mbfatr == TA_NOEXS) { ercd = E_NOEXS; } else if (VIOLATE_ACPTN(p_mbfcb->p_mbfinib->acvct.acptn2)) { ercd = E_OACV; } else if (!KERNEL_PROBE_BUF_WRITE(msg, p_mbfcb->p_mbfinib->maxmsz)) { ercd = E_MACV; } else if (p_runtsk->raster) { ercd = E_RASTER; } else if ((msgsz = receive_message(p_mbfcb, msg)) > 0U) { if (p_runtsk != p_schedtsk) { dispatch(); } ercd = (ER_UINT) msgsz; } else if (tmout == TMO_POL) { ercd = E_TMOUT; } else { make_wait_tmout(TS_WAITING_RMBF, &(winfo_rmbf.winfo), &tmevtb, tmout); queue_insert_prev(&(p_mbfcb->rwait_queue), &(p_runtsk->task_queue)); winfo_rmbf.p_mbfcb = p_mbfcb; winfo_rmbf.msg = msg; LOG_TSKSTAT(p_runtsk); dispatch(); ercd = winfo_rmbf.winfo.wercd; } unlock_cpu_dsp(); error_exit: LOG_TRCV_MBF_LEAVE(ercd, msg); return(ercd); }
/* * 待ち解除のためのタスク状態の更新 * * p_tcbで指定されるタスクを,待ち解除するようタスク状態を更新する. * 待ち解除するタスクが実行できる状態になる場合は,レディキューにつな * ぐ.また,ディスパッチが必要な場合にはtrueを返す. */ Inline bool_t make_non_wait(TCB *p_tcb) { assert(TSTAT_WAITING(p_tcb->tstat)); if (!TSTAT_SUSPENDED(p_tcb->tstat)) { /* * 待ち状態から実行できる状態への遷移 */ p_tcb->tstat = TS_RUNNABLE; LOG_TSKSTAT(p_tcb); return(make_runnable(p_tcb)); } else { /* * 二重待ち状態から強制待ち状態への遷移 */ p_tcb->tstat = TS_SUSPENDED; LOG_TSKSTAT(p_tcb); return(false); } }
ER trcv_pdq(ID pdqid, intptr_t *p_data, PRI *p_datapri, TMO tmout) { PDQCB *p_pdqcb; WINFO_RPDQ winfo_rpdq; TMEVTB tmevtb; ER ercd; LOG_TRCV_PDQ_ENTER(pdqid, p_data, p_datapri, tmout); CHECK_DISPATCH(); CHECK_ID(VALID_PDQID(pdqid)); CHECK_PAR(VALID_TMOUT(tmout)); p_pdqcb = get_pdqcb(pdqid); lock_cpu_dsp(); if (p_runtsk->raster) { ercd = E_RASTER; } else if (receive_pridata(p_pdqcb, p_data, p_datapri)) { if (p_runtsk != p_schedtsk) { dispatch(); } ercd = E_OK; } else if (tmout == TMO_POL) { ercd = E_TMOUT; } else { p_runtsk->tstat = TS_WAITING_RPDQ; make_wait_tmout(&(winfo_rpdq.winfo), &tmevtb, tmout); queue_insert_prev(&(p_pdqcb->rwait_queue), &(p_runtsk->task_queue)); winfo_rpdq.p_pdqcb = p_pdqcb; LOG_TSKSTAT(p_runtsk); dispatch(); ercd = winfo_rpdq.winfo.wercd; if (ercd == E_OK) { *p_data = winfo_rpdq.data; *p_datapri = winfo_rpdq.datapri; } } unlock_cpu_dsp(); error_exit: LOG_TRCV_PDQ_LEAVE(ercd, p_data, p_datapri); return(ercd); }
ER trcv_mbf(ID mbfid, void *msg, TMO tmout) { MBFCB *p_mbfcb; WINFO_MBF winfo_mbf; TMEVTB tmevtb; uint_t msgsz; bool_t dspreq; ER_UINT ercd; LOG_TRCV_MBF_ENTER(mbfid, msg, tmout); CHECK_DISPATCH(); CHECK_MBFID(mbfid); CHECK_TMOUT(tmout); p_mbfcb = get_mbfcb(mbfid); t_lock_cpu(); if ((msgsz = receive_message(p_mbfcb, msg, &dspreq)) > 0U) { if (dspreq) { dispatch(); } ercd = (ER_UINT) msgsz; } else if (tmout == TMO_POL) { ercd = E_TMOUT; } else { p_runtsk->tstat = (TS_WAITING | TS_WAIT_RMBF); make_wait_tmout(&(winfo_mbf.winfo), &tmevtb, tmout); queue_insert_prev(&(p_mbfcb->rwait_queue), &(p_runtsk->task_queue)); winfo_mbf.p_mbfcb = p_mbfcb; winfo_mbf.msg = msg; LOG_TSKSTAT(p_runtsk); dispatch(); ercd = winfo_mbf.winfo.wercd; if (ercd == E_OK) { ercd = (ER_UINT)(winfo_mbf.msgsz); } } t_unlock_cpu(); error_exit: LOG_TRCV_MBF_LEAVE(ercd, msg); return(ercd); }
ER trcv_dtq(ID dtqid, intptr_t *p_data, TMO tmout) { DTQCB *p_dtqcb; WINFO_DTQ winfo_dtq; TMEVTB tmevtb; bool_t reqdsp; ER ercd; LOG_TRCV_DTQ_ENTER(dtqid, p_data, tmout); CHECK_DISPATCH(); CHECK_DTQID(dtqid); CHECK_TMOUT(tmout); p_dtqcb = get_dtqcb(dtqid); t_lock_cpu(); if (receive_data(p_dtqcb, p_data, &reqdsp)) { if (reqdsp) { dispatch(); } ercd = E_OK; } else if (tmout == TMO_POL) { ercd = E_TMOUT; } else { p_runtsk->tstat = (TS_WAITING | TS_WAIT_RDTQ); make_wait_tmout(&(winfo_dtq.winfo), &tmevtb, tmout); queue_insert_prev(&(p_dtqcb->rwait_queue), &(p_runtsk->task_queue)); winfo_dtq.p_dtqcb = p_dtqcb; LOG_TSKSTAT(p_runtsk); dispatch(); ercd = winfo_dtq.winfo.wercd; if (ercd == E_OK) { *p_data = winfo_dtq.data; } } t_unlock_cpu(); error_exit: LOG_TRCV_DTQ_LEAVE(ercd, *p_data); return(ercd); }
ER rcv_pdq(ID pdqid, intptr_t *p_data, PRI *p_datapri) { PDQCB *p_pdqcb; WINFO_PDQ winfo_pdq; bool_t reqdsp; ER ercd; LOG_RCV_PDQ_ENTER(pdqid, p_data, p_datapri); CHECK_DISPATCH(); CHECK_PDQID(pdqid); p_pdqcb = get_pdqcb(pdqid); t_lock_cpu(); if (p_pdqcb->p_pdqinib->pdqatr == TA_NOEXS) { ercd = E_NOEXS; } else if (receive_pridata(p_pdqcb, p_data, p_datapri, &reqdsp)) { if (reqdsp) { dispatch(); } ercd = E_OK; } else { p_runtsk->tstat = (TS_WAITING | TS_WAIT_RPDQ); make_wait(&(winfo_pdq.winfo)); queue_insert_prev(&(p_pdqcb->rwait_queue), &(p_runtsk->task_queue)); winfo_pdq.p_pdqcb = p_pdqcb; LOG_TSKSTAT(p_runtsk); dispatch(); ercd = winfo_pdq.winfo.wercd; if (ercd == E_OK) { *p_data = winfo_pdq.data; *p_datapri = winfo_pdq.datapri; } } t_unlock_cpu(); error_exit: LOG_RCV_PDQ_LEAVE(ercd, *p_data, *p_datapri); return(ercd); }
/* * 待ち解除のためのタスク状態の更新 * * tcb で指定されるタスクを,待ち解除するようタスク状態を更新する.待 * ち解除するタスクが実行できる状態になる場合は,レディキューにつなぐ. * また,ディスパッチが必要な場合には TRUE を返す. */ Inline BOOL make_non_wait(TCB *tcb) { assert(TSTAT_WAITING(tcb->tstat)); if (!(TSTAT_SUSPENDED(tcb->tstat))) { /* * 待ち状態から実行できる状態への遷移 */ return(make_runnable(tcb)); } else { /* * 二重待ち状態から強制待ち状態への遷移 */ tcb->tstat = TS_SUSPENDED; LOG_TSKSTAT(tcb); return(FALSE); } }
SYSCALL ER rsm_tsk(ID tskid) { TCB *tcb; UINT tstat; ER ercd; LOG_RSM_TSK_ENTER(tskid); CHECK_TSKCTX_UNL(); CHECK_TSKID(tskid); tcb = get_tcb(tskid); t_lock_cpu(); if (!(TSTAT_SUSPENDED(tstat = tcb->tstat))) { ercd = E_OBJ; } else if (!(TSTAT_WAITING(tstat))) { /* * 強制待ち状態から実行できる状態への遷移 */ if (make_runnable(tcb)) { dispatch(); } ercd = E_OK; } else { /* * 二重待ち状態から待ち状態への遷移 */ tcb->tstat &= ~TS_SUSPENDED; LOG_TSKSTAT(tcb); ercd = E_OK; } t_unlock_cpu(); exit: LOG_RSM_TSK_LEAVE(ercd); return(ercd); }