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); }
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); }
ER wai_sem(ID semid) { SEMCB *p_semcb; WINFO_SEM winfo_sem; ER ercd; LOG_WAI_SEM_ENTER(semid); CHECK_DISPATCH(); CHECK_ID(VALID_SEMID(semid)); p_semcb = get_semcb(semid); lock_cpu_dsp(); if (p_semcb->p_seminib->sematr == TA_NOEXS) { ercd = E_NOEXS; } else if (p_runtsk->raster) { ercd = E_RASTER; } else if (p_semcb->semcnt >= 1) { p_semcb->semcnt -= 1; ercd = E_OK; } else { p_runtsk->tstat = TS_WAITING_SEM; wobj_make_wait((WOBJCB *) p_semcb, (WINFO_WOBJ *) &winfo_sem); dispatch(); ercd = winfo_sem.winfo.wercd; } unlock_cpu_dsp(); error_exit: LOG_WAI_SEM_LEAVE(ercd); return(ercd); }
ER tloc_mtx(ID mtxid, TMO tmout) { MTXCB *p_mtxcb; WINFO_MTX winfo_mtx; TMEVTB tmevtb; ER ercd; LOG_TLOC_MTX_ENTER(mtxid, tmout); CHECK_DISPATCH(); CHECK_ID(VALID_MTXID(mtxid)); CHECK_PAR(VALID_TMOUT(tmout)); p_mtxcb = get_mtxcb(mtxid); lock_cpu_dsp(); if (p_mtxcb->p_mtxinib->mtxatr == TA_NOEXS) { ercd = E_NOEXS; } else if (VIOLATE_ACPTN(p_mtxcb->p_mtxinib->acvct.acptn1)) { ercd = E_OACV; } else if (MTX_CEILING(p_mtxcb) && p_mtxcb->p_mtxinib->ceilpri < p_runtsk->p_dominib->minpriority && VIOLATE_ACPTN(p_runtsk->p_dominib->acvct.acptn2)) { ercd = E_OACV; /*[NGKI5124]*/ } else if (p_runtsk->raster) { ercd = E_RASTER; } else if (MTX_CEILING(p_mtxcb) && p_runtsk->bpriority < p_mtxcb->p_mtxinib->ceilpri) { ercd = E_ILUSE; } else if (p_mtxcb->p_loctsk == NULL) { mutex_acquire(p_runtsk, p_mtxcb); /* * 優先度上限ミューテックスをロックした場合,p_runtskの優先度 * が上がる可能性があるが,ディスパッチが必要になることはない. */ assert(p_runtsk == p_schedtsk); ercd = E_OK; } else if (p_mtxcb->p_loctsk == p_runtsk) { ercd = E_OBJ; } else if (tmout == TMO_POL) { ercd = E_TMOUT; } else { wobj_make_wait_tmout((WOBJCB *) p_mtxcb, TS_WAITING_MTX, (WINFO_WOBJ *) &winfo_mtx, &tmevtb, tmout); dispatch(); ercd = winfo_mtx.winfo.wercd; } unlock_cpu_dsp(); error_exit: LOG_TLOC_MTX_LEAVE(ercd); return(ercd); }
ER get_mpf(ID mpfid, void **p_blk) { MPFCB *p_mpfcb; WINFO_MPF winfo_mpf; ER ercd; LOG_GET_MPF_ENTER(mpfid, p_blk); CHECK_DISPATCH(); CHECK_ID(VALID_MPFID(mpfid)); p_mpfcb = get_mpfcb(mpfid); lock_cpu_dsp(); if (p_runtsk->raster) { ercd = E_RASTER; } else if (p_mpfcb->fblkcnt > 0) { get_mpf_block(p_mpfcb, p_blk); ercd = E_OK; } else { p_runtsk->tstat = TS_WAITING_MPF; wobj_make_wait((WOBJCB *) p_mpfcb, (WINFO_WOBJ *) &winfo_mpf); dispatch(); ercd = winfo_mpf.winfo.wercd; if (ercd == E_OK) { *p_blk = winfo_mpf.blk; } } unlock_cpu_dsp(); error_exit: LOG_GET_MPF_LEAVE(ercd, p_blk); return(ercd); }
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); }
ER tsnd_mbf(ID mbfid, const void *msg, uint_t msgsz, TMO tmout) { MBFCB *p_mbfcb; WINFO_SMBF winfo_smbf; TMEVTB tmevtb; ER ercd; LOG_TSND_MBF_ENTER(mbfid, msg, msgsz, tmout); CHECK_DISPATCH(); CHECK_ID(VALID_MBFID(mbfid)); CHECK_PAR(VALID_TMOUT(tmout)); CHECK_MACV_BUF_READ(msg, msgsz); CHECK_PAR(0 < msgsz); 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.acptn1)) { ercd = E_OACV; } else if (!(msgsz <= p_mbfcb->p_mbfinib->maxmsz)) { ercd = E_PAR; } else if (p_runtsk->raster) { ercd = E_RASTER; } else if (send_message(p_mbfcb, msg, msgsz)) { if (p_runtsk != p_schedtsk) { dispatch(); } ercd = E_OK; } else if (tmout == TMO_POL) { ercd = E_TMOUT; } else { winfo_smbf.msg = msg; winfo_smbf.msgsz = msgsz; wobj_make_wait_tmout((WOBJCB *) p_mbfcb, TS_WAITING_SMBF, (WINFO_WOBJ *) &winfo_smbf, &tmevtb, tmout); dispatch(); ercd = winfo_smbf.winfo.wercd; } unlock_cpu_dsp(); error_exit: LOG_TSND_MBF_LEAVE(ercd); return(ercd); }
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 tget_mpf(ID mpfid, void **p_blk, TMO tmout) { MPFCB *p_mpfcb; WINFO_MPF winfo_mpf; TMEVTB tmevtb; ER ercd; LOG_TGET_MPF_ENTER(mpfid, p_blk, tmout); CHECK_DISPATCH(); CHECK_ID(VALID_MPFID(mpfid)); CHECK_PAR(VALID_TMOUT(tmout)); p_mpfcb = get_mpfcb(mpfid); lock_cpu_dsp(); if (p_mpfcb->p_mpfinib->mpfatr == TA_NOEXS) { ercd = E_NOEXS; } else if (p_runtsk->raster) { ercd = E_RASTER; } else if (p_mpfcb->fblkcnt > 0) { get_mpf_block(p_mpfcb, p_blk); ercd = E_OK; } else if (tmout == TMO_POL) { ercd = E_TMOUT; } else { p_runtsk->tstat = TS_WAITING_MPF; wobj_make_wait_tmout((WOBJCB *) p_mpfcb, (WINFO_WOBJ *) &winfo_mpf, &tmevtb, tmout); dispatch(); ercd = winfo_mpf.winfo.wercd; if (ercd == E_OK) { *p_blk = winfo_mpf.blk; } } unlock_cpu_dsp(); error_exit: LOG_TGET_MPF_LEAVE(ercd, p_blk); return(ercd); }
ER tsnd_pdq(ID pdqid, intptr_t data, PRI datapri, TMO tmout) { PDQCB *p_pdqcb; WINFO_SPDQ winfo_spdq; TMEVTB tmevtb; ER ercd; LOG_TSND_PDQ_ENTER(pdqid, data, datapri, tmout); CHECK_DISPATCH(); CHECK_ID(VALID_PDQID(pdqid)); CHECK_PAR(VALID_TMOUT(tmout)); p_pdqcb = get_pdqcb(pdqid); CHECK_PAR(TMIN_DPRI <= datapri && datapri <= p_pdqcb->p_pdqinib->maxdpri); lock_cpu_dsp(); if (p_runtsk->raster) { ercd = E_RASTER; } else if (send_pridata(p_pdqcb, data, datapri)) { if (p_runtsk != p_schedtsk) { dispatch(); } ercd = E_OK; } else if (tmout == TMO_POL) { ercd = E_TMOUT; } else { winfo_spdq.data = data; winfo_spdq.datapri = datapri; p_runtsk->tstat = TS_WAITING_SPDQ; wobj_make_wait_tmout((WOBJCB *) p_pdqcb, (WINFO_WOBJ *) &winfo_spdq, &tmevtb, tmout); dispatch(); ercd = winfo_spdq.winfo.wercd; } unlock_cpu_dsp(); error_exit: LOG_TSND_PDQ_LEAVE(ercd); return(ercd); }
ER twai_sem(ID semid, TMO tmout) { SEMCB *p_semcb; WINFO_SEM winfo_sem; TMEVTB tmevtb; ER ercd; LOG_TWAI_SEM_ENTER(semid, tmout); CHECK_DISPATCH(); CHECK_ID(VALID_SEMID(semid)); CHECK_PAR(VALID_TMOUT(tmout)); p_semcb = get_semcb(semid); lock_cpu_dsp(); if (p_semcb->p_seminib->sematr == TA_NOEXS) { ercd = E_NOEXS; } else if (VIOLATE_ACPTN(p_semcb->p_seminib->acvct.acptn2)) { ercd = E_OACV; } else if (p_runtsk->raster) { ercd = E_RASTER; } else if (p_semcb->semcnt >= 1) { p_semcb->semcnt -= 1; ercd = E_OK; } else if (tmout == TMO_POL) { ercd = E_TMOUT; } else { wobj_make_wait_tmout((WOBJCB *) p_semcb, TS_WAITING_SEM, (WINFO_WOBJ *) &winfo_sem, &tmevtb, tmout); dispatch(); ercd = winfo_sem.winfo.wercd; } unlock_cpu_dsp(); error_exit: LOG_TWAI_SEM_LEAVE(ercd); return(ercd); }