bool_t receive_pridata(PDQCB *p_pdqcb, intptr_t *p_data, PRI *p_datapri, bool_t *p_reqdsp) { TCB *p_tcb; intptr_t data; PRI datapri; if (p_pdqcb->count > 0U) { dequeue_pridata(p_pdqcb, p_data, p_datapri); if (!queue_empty(&(p_pdqcb->swait_queue))) { p_tcb = (TCB *) queue_delete_next(&(p_pdqcb->swait_queue)); data = ((WINFO_PDQ *)(p_tcb->p_winfo))->data; datapri = ((WINFO_PDQ *)(p_tcb->p_winfo))->datapri; enqueue_pridata(p_pdqcb, data, datapri); *p_reqdsp = wait_complete(p_tcb); } else { *p_reqdsp = false; } return(true); } else if (!queue_empty(&(p_pdqcb->swait_queue))) { p_tcb = (TCB *) queue_delete_next(&(p_pdqcb->swait_queue)); *p_data = ((WINFO_PDQ *)(p_tcb->p_winfo))->data; *p_datapri = ((WINFO_PDQ *)(p_tcb->p_winfo))->datapri; *p_reqdsp = wait_complete(p_tcb); return(true); } else { return(false); } }
bool_t receive_data(DTQCB *p_dtqcb, intptr_t *p_data, bool_t *p_reqdsp) { TCB *p_tcb; intptr_t data; if (p_dtqcb->count > 0U) { dequeue_data(p_dtqcb, p_data); if (!queue_empty(&(p_dtqcb->swait_queue))) { p_tcb = (TCB *) queue_delete_next(&(p_dtqcb->swait_queue)); data = ((WINFO_DTQ *)(p_tcb->p_winfo))->data; enqueue_data(p_dtqcb, data); *p_reqdsp = wait_complete(p_tcb); } else { *p_reqdsp = false; } return(true); } else if (!queue_empty(&(p_dtqcb->swait_queue))) { p_tcb = (TCB *) queue_delete_next(&(p_dtqcb->swait_queue)); *p_data = ((WINFO_DTQ *)(p_tcb->p_winfo))->data; *p_reqdsp = wait_complete(p_tcb); return(true); } else { return(false); } }
ER_UINT acre_flg(const T_CFLG *pk_cflg) { FLGCB *p_flgcb; FLGINIB *p_flginib; ER ercd; LOG_ACRE_FLG_ENTER(pk_cflg); CHECK_TSKCTX_UNL(); CHECK_RSATR(pk_cflg->flgatr, TA_TPRI|TA_WMUL|TA_CLR); t_lock_cpu(); if (tnum_flg == 0 || queue_empty(&free_flgcb)) { ercd = E_NOID; } else { p_flgcb = ((FLGCB *) queue_delete_next(&free_flgcb)); p_flginib = (FLGINIB *)(p_flgcb->p_flginib); p_flginib->flgatr = pk_cflg->flgatr; p_flginib->iflgptn = pk_cflg->iflgptn; queue_initialize(&(p_flgcb->wait_queue)); p_flgcb->flgptn = p_flgcb->p_flginib->iflgptn; ercd = FLGID(p_flgcb); } t_unlock_cpu(); error_exit: LOG_ACRE_FLG_LEAVE(ercd); return(ercd); }
ER_UINT acre_alm(const T_CALM *pk_calm) { ALMCB *p_almcb; ALMINIB *p_alminib; ER ercd; LOG_ACRE_ALM_ENTER(pk_calm); CHECK_TSKCTX_UNL(); CHECK_RSATR(pk_calm->almatr, TA_NULL); CHECK_ALIGN_FUNC(pk_calm->almhdr); CHECK_NONNULL_FUNC(pk_calm->almhdr); t_lock_cpu(); if (tnum_alm == 0 || queue_empty(&free_almcb)) { ercd = E_NOID; } else { p_almcb = ((ALMCB *)(((char *) queue_delete_next(&free_almcb)) - offsetof(ALMCB, tmevtb))); p_alminib = (ALMINIB *)(p_almcb->p_alminib); p_alminib->almatr = pk_calm->almatr; p_alminib->exinf = pk_calm->exinf; p_alminib->almhdr = pk_calm->almhdr; p_almcb->almsta = false; ercd = ALMID(p_almcb); } t_unlock_cpu(); error_exit: LOG_ACRE_ALM_LEAVE(ercd); return(ercd); }
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_UINT acre_sem(const T_CSEM *pk_csem) { SEMCB *p_semcb; SEMINIB *p_seminib; ER ercd; LOG_ACRE_SEM_ENTER(pk_csem); CHECK_TSKCTX_UNL(); CHECK_RSATR(pk_csem->sematr, TA_TPRI); CHECK_PAR(0 <= pk_csem->isemcnt && pk_csem->isemcnt <= pk_csem->maxsem); CHECK_PAR(1 <= pk_csem->maxsem && pk_csem->maxsem <= TMAX_MAXSEM); t_lock_cpu(); if (tnum_sem == 0 || queue_empty(&free_semcb)) { ercd = E_NOID; } else { p_semcb = ((SEMCB *) queue_delete_next(&free_semcb)); p_seminib = (SEMINIB *)(p_semcb->p_seminib); p_seminib->sematr = pk_csem->sematr; p_seminib->isemcnt = pk_csem->isemcnt; p_seminib->maxsem = pk_csem->maxsem; queue_initialize(&(p_semcb->wait_queue)); p_semcb->semcnt = p_semcb->p_seminib->isemcnt; ercd = SEMID(p_semcb); } t_unlock_cpu(); error_exit: LOG_ACRE_SEM_LEAVE(ercd); return(ercd); }
void mutex_release(MTXCB *p_mtxcb) { TCB *p_tcb; if (queue_empty(&(p_mtxcb->wait_queue))) { p_mtxcb->p_loctsk = NULL; } else { /* * ミューテックス待ちキューの先頭タスク(p_tcb)に,ミューテッ * クスをロックさせる. */ p_tcb = (TCB *) queue_delete_next(&(p_mtxcb->wait_queue)); wait_dequeue_tmevtb(p_tcb); p_tcb->p_winfo->wercd = E_OK; p_mtxcb->p_loctsk = p_tcb; p_mtxcb->p_prevmtx = p_tcb->p_lastmtx; p_tcb->p_lastmtx = p_mtxcb; if (MTX_CEILING(p_mtxcb)) { if (p_mtxcb->p_mtxinib->ceilpri < p_tcb->priority) { p_tcb->priority = p_mtxcb->p_mtxinib->ceilpri; } } make_non_wait(p_tcb); } }
JSP_L1_CODE SYSCALL ER isig_sem(ID semid) { SEMCB *semcb; TCB *tcb; ER ercd; LOG_ISIG_SEM_ENTER(semid); CHECK_INTCTX_UNL(); CHECK_SEMID(semid); semcb = get_semcb(semid); i_lock_cpu(); if (!queue_empty(&(semcb->wait_queue))) { tcb = (TCB *) queue_delete_next(&(semcb->wait_queue)); if (wait_complete(tcb)) { reqflg = TRUE; } ercd = E_OK; } else if (semcb->semcnt < semcb->seminib->maxsem) { semcb->semcnt += 1; ercd = E_OK; } else { ercd = E_QOVR; } i_unlock_cpu(); exit: LOG_ISIG_SEM_LEAVE(ercd); return(ercd); }
/* This function rotates the FIFO in the priority queue RDYQUE 'rq' for the supplied 'priority'. This involves removing the element from the head of the queue and then reinserting it at the tail/end of the queue. */ void ready_queue_rotate(RDYQUE *rq,INT priority) { QUEUE *entry, *queue; if ( !queue_empty_p(queue=&(rq->tskque[priority])) ) { entry = queue_delete_next(queue); queue_insert(entry, queue); } }
void init_wait_queue(QUEUE *p_wait_queue) { TCB *p_tcb; while (!queue_empty(p_wait_queue)) { p_tcb = (TCB *) queue_delete_next(p_wait_queue); wait_dequeue_tmevtb(p_tcb); p_tcb->p_winfo->wercd = E_DLT; make_non_wait(p_tcb); } }
ER_UINT acre_pdq(const T_CPDQ *pk_cpdq) { PDQCB *p_pdqcb; PDQINIB *p_pdqinib; ATR pdqatr; PDQMB *p_pdqmb; ER ercd; LOG_ACRE_PDQ_ENTER(pk_cpdq); CHECK_TSKCTX_UNL(); CHECK_RSATR(pk_cpdq->pdqatr, TA_TPRI); CHECK_DPRI(pk_cpdq->maxdpri); pdqatr = pk_cpdq->pdqatr; p_pdqmb = pk_cpdq->pdqmb; t_lock_cpu(); if (queue_empty(&free_pdqcb)) { ercd = E_NOID; } else { if (pk_cpdq->pdqcnt != 0 && p_pdqmb == NULL) { p_pdqmb = kernel_malloc(sizeof(PDQMB) * pk_cpdq->pdqcnt); pdqatr |= TA_MBALLOC; } if (pk_cpdq->pdqcnt != 0 && p_pdqmb == NULL) { ercd = E_NOMEM; } else { p_pdqcb = ((PDQCB *) queue_delete_next(&free_pdqcb)); p_pdqinib = (PDQINIB *)(p_pdqcb->p_pdqinib); p_pdqinib->pdqatr = pdqatr; p_pdqinib->pdqcnt = pk_cpdq->pdqcnt; p_pdqinib->maxdpri = pk_cpdq->maxdpri; p_pdqinib->p_pdqmb = p_pdqmb; queue_initialize(&(p_pdqcb->swait_queue)); queue_initialize(&(p_pdqcb->rwait_queue)); p_pdqcb->count = 0U; p_pdqcb->p_head = NULL; p_pdqcb->unused = 0U; p_pdqcb->p_freelist = NULL; ercd = PDQID(p_pdqcb); } } t_unlock_cpu(); error_exit: LOG_ACRE_PDQ_LEAVE(ercd); return(ercd); }
ER rel_mpf(ID mpfid, void *blk) { MPFCB *p_mpfcb; size_t blkoffset; uint_t blkidx; TCB *p_tcb; ER ercd; LOG_REL_MPF_ENTER(mpfid, blk); CHECK_TSKCTX_UNL(); CHECK_ID(VALID_MPFID(mpfid)); p_mpfcb = get_mpfcb(mpfid); lock_cpu(); if (p_mpfcb->p_mpfinib->mpfatr == TA_NOEXS) { ercd = E_NOEXS; } else { blkoffset = ((char *) blk) - (char *)(p_mpfcb->p_mpfinib->mpf); blkidx = (uint_t)(blkoffset / p_mpfcb->p_mpfinib->blksz); if (!(p_mpfcb->p_mpfinib->mpf <= blk) || !(blkoffset % p_mpfcb->p_mpfinib->blksz == 0U) || !(blkoffset / p_mpfcb->p_mpfinib->blksz < p_mpfcb->unused) || !((p_mpfcb->p_mpfinib->p_mpfmb + blkidx)->next == INDEX_ALLOC)) { ercd = E_PAR; } else if (!queue_empty(&(p_mpfcb->wait_queue))) { p_tcb = (TCB *) queue_delete_next(&(p_mpfcb->wait_queue)); ((WINFO_MPF *)(p_tcb->p_winfo))->blk = blk; wait_complete(p_tcb); if (p_runtsk != p_schedtsk) { dispatch(); } ercd = E_OK; } else { p_mpfcb->fblkcnt++; (p_mpfcb->p_mpfinib->p_mpfmb + blkidx)->next = p_mpfcb->freelist; p_mpfcb->freelist = blkidx; ercd = E_OK; } } unlock_cpu(); error_exit: LOG_REL_MPF_LEAVE(ercd); return(ercd); }
ER_UINT acre_isr(const T_CISR *pk_cisr) { ISRCB *p_isrcb; ISRINIB *p_isrinib; QUEUE *p_isr_queue; ER ercd; LOG_ACRE_ISR_ENTER(pk_cisr); CHECK_TSKCTX_UNL(); CHECK_MACV_READ(pk_cisr, T_CISR); CHECK_RSATR(pk_cisr->isratr, TARGET_ISRATR|TA_DOMMASK); CHECK_ATRDOMID_KERNEL(get_atrdomid(pk_cisr->isratr)); CHECK_INTNO_CREISR(pk_cisr->intno); CHECK_ALIGN_FUNC(pk_cisr->isr); CHECK_NONNULL_FUNC(pk_cisr->isr); CHECK_ISRPRI(pk_cisr->isrpri); CHECK_ACPTN(sysstat_acvct.acptn3); p_isr_queue = search_isr_queue(pk_cisr->intno); CHECK_OBJ(p_isr_queue != NULL); t_lock_cpu(); if (tnum_isr == 0 || queue_empty(&free_isrcb)) { ercd = E_NOID; } else { p_isrcb = ((ISRCB *) queue_delete_next(&free_isrcb)); p_isrinib = (ISRINIB *)(p_isrcb->p_isrinib); p_isrinib->isratr = pk_cisr->isratr; p_isrinib->exinf = pk_cisr->exinf; p_isrinib->intno = pk_cisr->intno; p_isrinib->p_isr_queue = p_isr_queue; p_isrinib->isr = pk_cisr->isr; p_isrinib->isrpri = pk_cisr->isrpri; p_isrinib->acvct.acptn1 = TACP_KERNEL; p_isrinib->acvct.acptn2 = TACP_KERNEL; p_isrinib->acvct.acptn3 = TACP_KERNEL | rundom; p_isrinib->acvct.acptn4 = TACP_KERNEL; enqueue_isr(p_isr_queue, p_isrcb); ercd = ISRID(p_isrcb); } t_unlock_cpu(); error_exit: LOG_ACRE_ISR_LEAVE(ercd); return(ercd); }
bool_t force_send_data(DTQCB *p_dtqcb, intptr_t data) { TCB *p_tcb; if (!queue_empty(&(p_dtqcb->rwait_queue))) { p_tcb = (TCB *) queue_delete_next(&(p_dtqcb->rwait_queue)); ((WINFO_DTQ *)(p_tcb->p_winfo))->data = data; return(wait_complete(p_tcb)); } else { force_enqueue_data(p_dtqcb, data); return(false); } }
ER_UINT acre_dtq(const T_CDTQ *pk_cdtq) { DTQCB *p_dtqcb; DTQINIB *p_dtqinib; ATR dtqatr; DTQMB *p_dtqmb; ER ercd; LOG_ACRE_DTQ_ENTER(pk_cdtq); CHECK_TSKCTX_UNL(); CHECK_RSATR(pk_cdtq->dtqatr, TA_TPRI); dtqatr = pk_cdtq->dtqatr; p_dtqmb = pk_cdtq->dtqmb; t_lock_cpu(); if (queue_empty(&free_dtqcb)) { ercd = E_NOID; } else { if (pk_cdtq->dtqcnt != 0 && p_dtqmb == NULL) { p_dtqmb = kernel_malloc(sizeof(DTQMB) * pk_cdtq->dtqcnt); dtqatr |= TA_MBALLOC; } if (pk_cdtq->dtqcnt != 0 && p_dtqmb == NULL) { ercd = E_NOMEM; } else { p_dtqcb = ((DTQCB *) queue_delete_next(&free_dtqcb)); p_dtqinib = (DTQINIB *)(p_dtqcb->p_dtqinib); p_dtqinib->dtqatr = dtqatr; p_dtqinib->dtqcnt = pk_cdtq->dtqcnt; p_dtqinib->p_dtqmb = p_dtqmb; queue_initialize(&(p_dtqcb->swait_queue)); queue_initialize(&(p_dtqcb->rwait_queue)); p_dtqcb->count = 0U; p_dtqcb->head = 0U; p_dtqcb->tail = 0U; ercd = DTQID(p_dtqcb); } } t_unlock_cpu(); error_exit: LOG_ACRE_DTQ_LEAVE(ercd); return(ercd); }
bool_t init_wait_queue(QUEUE *p_wait_queue) { TCB *p_tcb; bool_t dspreq = false; while (!queue_empty(p_wait_queue)) { p_tcb = (TCB *) queue_delete_next(p_wait_queue); wait_dequeue_tmevtb(p_tcb); p_tcb->p_winfo->wercd = E_DLT; if (make_non_wait(p_tcb)) { dspreq = true; }; } return(dspreq); }
ER_UINT acre_sem(const T_CSEM *pk_csem) { ID domid; SEMCB *p_semcb; SEMINIB *p_seminib; ACPTN acptn; ER ercd; LOG_ACRE_SEM_ENTER(pk_csem); CHECK_TSKCTX_UNL(); CHECK_MACV_READ(pk_csem, T_CSEM); CHECK_RSATR(pk_csem->sematr, TA_TPRI|TA_DOMMASK); domid = get_atrdomid(pk_csem->sematr); CHECK_ATRDOMID_INACTIVE(domid); CHECK_PAR(0 <= pk_csem->isemcnt && pk_csem->isemcnt <= pk_csem->maxsem); CHECK_PAR(1 <= pk_csem->maxsem && pk_csem->maxsem <= TMAX_MAXSEM); CHECK_ACPTN(sysstat_acvct.acptn3); t_lock_cpu(); if (tnum_sem == 0 || queue_empty(&free_semcb)) { ercd = E_NOID; } else { p_semcb = ((SEMCB *) queue_delete_next(&free_semcb)); p_seminib = (SEMINIB *)(p_semcb->p_seminib); p_seminib->sematr = pk_csem->sematr; p_seminib->isemcnt = pk_csem->isemcnt; p_seminib->maxsem = pk_csem->maxsem; acptn = default_acptn(domid); p_seminib->acvct.acptn1 = acptn; p_seminib->acvct.acptn2 = acptn; p_seminib->acvct.acptn3 = acptn | rundom; p_seminib->acvct.acptn4 = acptn; queue_initialize(&(p_semcb->wait_queue)); p_semcb->semcnt = p_semcb->p_seminib->isemcnt; ercd = SEMID(p_semcb); } t_unlock_cpu(); error_exit: LOG_ACRE_SEM_LEAVE(ercd); return(ercd); }
ER_UINT acre_cyc(const T_CCYC *pk_ccyc) { CYCCB *p_cyccb; CYCINIB *p_cycinib; ER ercd; LOG_ACRE_CYC_ENTER(pk_ccyc); CHECK_TSKCTX_UNL(); CHECK_RSATR(pk_ccyc->cycatr, TA_STA); CHECK_ALIGN_FUNC(pk_ccyc->cychdr); CHECK_NONNULL_FUNC(pk_ccyc->cychdr); CHECK_PAR(0 < pk_ccyc->cyctim && pk_ccyc->cyctim <= TMAX_RELTIM); CHECK_PAR(0 <= pk_ccyc->cycphs && pk_ccyc->cycphs <= TMAX_RELTIM); t_lock_cpu(); if (tnum_cyc == 0 || queue_empty(&free_cyccb)) { ercd = E_NOID; } else { p_cyccb = ((CYCCB *)(((char *) queue_delete_next(&free_cyccb)) - offsetof(CYCCB, tmevtb))); p_cycinib = (CYCINIB *)(p_cyccb->p_cycinib); p_cycinib->cycatr = pk_ccyc->cycatr; p_cycinib->exinf = pk_ccyc->exinf; p_cycinib->cychdr = pk_ccyc->cychdr; p_cycinib->cyctim = pk_ccyc->cyctim; p_cycinib->cycphs = pk_ccyc->cycphs; if ((p_cyccb->p_cycinib->cycatr & TA_STA) != 0U) { p_cyccb->cycsta = true; tmevtb_enqueue_cyc(p_cyccb, base_time + p_cyccb->p_cycinib->cycphs); } else { p_cyccb->cycsta = false; } ercd = CYCID(p_cyccb); } t_unlock_cpu(); error_exit: LOG_ACRE_CYC_LEAVE(ercd); return(ercd); }
ER_UINT acre_alm(const T_CALM *pk_calm) { ALMCB *p_almcb; ALMINIB *p_alminib; T_NFYINFO *p_nfyinfo; ER ercd, rercd; LOG_ACRE_ALM_ENTER(pk_calm); CHECK_TSKCTX_UNL(); CHECK_RSATR(pk_calm->almatr, TA_NULL); rercd = check_nfyinfo(&(pk_calm->nfyinfo)); if (rercd != E_OK) { ercd = rercd; goto error_exit; } lock_cpu(); if (tnum_alm == 0 || queue_empty(&free_almcb)) { ercd = E_NOID; } else { p_almcb = ((ALMCB *)(((char *) queue_delete_next(&free_almcb)) - offsetof(ALMCB, tmevtb))); p_alminib = (ALMINIB *)(p_almcb->p_alminib); p_alminib->almatr = pk_calm->almatr; if (pk_calm->nfyinfo.nfymode == TNFY_HANDLER) { p_alminib->exinf = pk_calm->nfyinfo.nfy.handler.exinf; p_alminib->nfyhdr = (NFYHDR)(pk_calm->nfyinfo.nfy.handler.tmehdr); } else { p_nfyinfo = &aalm_nfyinfo_table[p_alminib - aalminib_table]; *p_nfyinfo = pk_calm->nfyinfo; p_alminib->exinf = (intptr_t) p_nfyinfo; p_alminib->nfyhdr = notify_handler; } p_almcb->almsta = false; ercd = ALMID(p_almcb); } unlock_cpu(); error_exit: LOG_ACRE_ALM_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 snd_mbx(ID mbxid, T_MSG *pk_msg) { MBXCB *p_mbxcb; TCB *p_tcb; ER ercd; LOG_SND_MBX_ENTER(mbxid, pk_msg); CHECK_TSKCTX_UNL(); CHECK_MBXID(mbxid); p_mbxcb = get_mbxcb(mbxid); CHECK_PAR((p_mbxcb->p_mbxinib->mbxatr & TA_MPRI) == 0U || (TMIN_MPRI <= MSGPRI(pk_msg) && MSGPRI(pk_msg) <= p_mbxcb->p_mbxinib->maxmpri)); t_lock_cpu(); if (!queue_empty(&(p_mbxcb->wait_queue))) { p_tcb = (TCB *) queue_delete_next(&(p_mbxcb->wait_queue)); ((WINFO_MBX *)(p_tcb->p_winfo))->pk_msg = pk_msg; if (wait_complete(p_tcb)) { dispatch(); } ercd = E_OK; } else if ((p_mbxcb->p_mbxinib->mbxatr & TA_MPRI) != 0U) { enqueue_msg_pri(&(p_mbxcb->pk_head), pk_msg); ercd = E_OK; } else { pk_msg->pk_next = NULL; if (p_mbxcb->pk_head != NULL) { p_mbxcb->pk_last->pk_next = pk_msg; } else { p_mbxcb->pk_head = pk_msg; } p_mbxcb->pk_last = pk_msg; ercd = E_OK; } t_unlock_cpu(); error_exit: LOG_SND_MBX_LEAVE(ercd); return(ercd); }
ER_UINT acre_flg(const T_CFLG *pk_cflg) { ID domid; FLGCB *p_flgcb; FLGINIB *p_flginib; ACPTN acptn; ER ercd; LOG_ACRE_FLG_ENTER(pk_cflg); CHECK_TSKCTX_UNL(); CHECK_MACV_READ(pk_cflg, T_CFLG); CHECK_RSATR(pk_cflg->flgatr, TA_TPRI|TA_WMUL|TA_CLR|TA_DOMMASK); domid = get_atrdomid(pk_cflg->flgatr); CHECK_ATRDOMID_INACTIVE(domid); CHECK_ACPTN(sysstat_acvct.acptn3); t_lock_cpu(); if (tnum_flg == 0 || queue_empty(&free_flgcb)) { ercd = E_NOID; } else { p_flgcb = ((FLGCB *) queue_delete_next(&free_flgcb)); p_flginib = (FLGINIB *)(p_flgcb->p_flginib); p_flginib->flgatr = pk_cflg->flgatr; p_flginib->iflgptn = pk_cflg->iflgptn; acptn = default_acptn(domid); p_flginib->acvct.acptn1 = acptn; p_flginib->acvct.acptn2 = acptn; p_flginib->acvct.acptn3 = acptn | rundom; p_flginib->acvct.acptn4 = acptn; queue_initialize(&(p_flgcb->wait_queue)); p_flgcb->flgptn = p_flgcb->p_flginib->iflgptn; ercd = FLGID(p_flgcb); } t_unlock_cpu(); error_exit: LOG_ACRE_FLG_LEAVE(ercd); return(ercd); }
bool_t send_pridata(PDQCB *p_pdqcb, intptr_t data, PRI datapri) { TCB *p_tcb; if (!queue_empty(&(p_pdqcb->rwait_queue))) { p_tcb = (TCB *) queue_delete_next(&(p_pdqcb->rwait_queue)); ((WINFO_RPDQ *)(p_tcb->p_winfo))->data = data; ((WINFO_RPDQ *)(p_tcb->p_winfo))->datapri = datapri; wait_complete(p_tcb); return(true); } else if (p_pdqcb->count < p_pdqcb->p_pdqinib->pdqcnt) { enqueue_pridata(p_pdqcb, data, datapri); return(true); } else { return(false); } }
bool_t send_data(DTQCB *p_dtqcb, intptr_t data, bool_t *p_reqdsp) { TCB *p_tcb; if (!queue_empty(&(p_dtqcb->rwait_queue))) { p_tcb = (TCB *) queue_delete_next(&(p_dtqcb->rwait_queue)); ((WINFO_DTQ *)(p_tcb->p_winfo))->data = data; *p_reqdsp = wait_complete(p_tcb); return(true); } else if (p_dtqcb->count < p_dtqcb->p_dtqinib->dtqcnt) { enqueue_data(p_dtqcb, data); *p_reqdsp = false; return(true); } else { return(false); } }
bool_t send_message(MBFCB *p_mbfcb, const void *msg, uint_t msgsz) { TCB *p_tcb; if (!queue_empty(&(p_mbfcb->rwait_queue))) { p_tcb = (TCB *) queue_delete_next(&(p_mbfcb->rwait_queue)); memcpy(((WINFO_RMBF *)(p_tcb->p_winfo))->msg, msg, msgsz); wait_complete(p_tcb); p_tcb->p_winfo->wercd = (ER_UINT)(msgsz); return(true); } else if (queue_empty(&(p_mbfcb->swait_queue)) && enqueue_message(p_mbfcb, msg, msgsz)) { return(true); } else { return(false); } }
ER rel_mpf(ID mpfid, void *blk) { MPFCB *p_mpfcb; SIZE blkoffset; uint_t blkidx; TCB *p_tcb; ER ercd; LOG_REL_MPF_ENTER(mpfid, blk); CHECK_TSKCTX_UNL(); CHECK_MPFID(mpfid); p_mpfcb = get_mpfcb(mpfid); CHECK_PAR(p_mpfcb->p_mpfinib->mpf <= blk); blkoffset = ((char *) blk) - (char *)(p_mpfcb->p_mpfinib->mpf); CHECK_PAR(blkoffset % p_mpfcb->p_mpfinib->blksz == 0U); CHECK_PAR(blkoffset / p_mpfcb->p_mpfinib->blksz < p_mpfcb->unused); blkidx = (uint_t)(blkoffset / p_mpfcb->p_mpfinib->blksz); CHECK_PAR((p_mpfcb->p_mpfinib->p_mpfmb + blkidx)->next == INDEX_ALLOC); t_lock_cpu(); if (!queue_empty(&(p_mpfcb->wait_queue))) { p_tcb = (TCB *) queue_delete_next(&(p_mpfcb->wait_queue)); ((WINFO_MPF *)(p_tcb->p_winfo))->blk = blk; if (wait_complete(p_tcb)) { dispatch(); } ercd = E_OK; } else { p_mpfcb->fblkcnt++; (p_mpfcb->p_mpfinib->p_mpfmb + blkidx)->next = p_mpfcb->freelist; p_mpfcb->freelist = blkidx; ercd = E_OK; } t_unlock_cpu(); error_exit: LOG_REL_MPF_LEAVE(ercd); return(ercd); }
ER_UINT acre_isr(const T_CISR *pk_cisr) { ISRCB *p_isrcb; ISRINIB *p_isrinib; QUEUE *p_isr_queue; ER ercd; LOG_ACRE_ISR_ENTER(pk_cisr); CHECK_TSKCTX_UNL(); CHECK_RSATR(pk_cisr->isratr, TARGET_ISRATR); CHECK_INTNO_CREISR(pk_cisr->intno); CHECK_ALIGN_FUNC(pk_cisr->isr); CHECK_NONNULL_FUNC(pk_cisr->isr); CHECK_ISRPRI(pk_cisr->isrpri); p_isr_queue = search_isr_queue(pk_cisr->intno); CHECK_OBJ(p_isr_queue != NULL); t_lock_cpu(); if (tnum_isr == 0 || queue_empty(&free_isrcb)) { ercd = E_NOID; } else { p_isrcb = ((ISRCB *) queue_delete_next(&free_isrcb)); p_isrinib = (ISRINIB *)(p_isrcb->p_isrinib); p_isrinib->isratr = pk_cisr->isratr; p_isrinib->exinf = pk_cisr->exinf; p_isrinib->intno = pk_cisr->intno; p_isrinib->p_isr_queue = p_isr_queue; p_isrinib->isr = pk_cisr->isr; p_isrinib->isrpri = pk_cisr->isrpri; enqueue_isr(p_isr_queue, p_isrcb); ercd = ISRID(p_isrcb); } t_unlock_cpu(); error_exit: LOG_ACRE_ISR_LEAVE(ercd); return(ercd); }
bool_t send_message(MBFCB *p_mbfcb, const void *msg, uint_t msgsz, bool_t *p_dspreq) { TCB *p_tcb; if (!queue_empty(&(p_mbfcb->rwait_queue))) { p_tcb = (TCB *) queue_delete_next(&(p_mbfcb->rwait_queue)); memcpy(((WINFO_MBF *)(p_tcb->p_winfo))->msg, msg, msgsz); ((WINFO_MBF *)(p_tcb->p_winfo))->msgsz = msgsz; *p_dspreq = wait_complete(p_tcb); return(true); } else if (have_precedence(p_mbfcb) && enqueue_message(p_mbfcb, msg, msgsz)) { *p_dspreq = false; return(true); } else { return(false); } }
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); }
uint_t receive_message(MBFCB *p_mbfcb, void *msg, bool_t *p_dspreq) { TCB *p_tcb; uint_t msgsz; if (p_mbfcb->smbfcnt > 0) { msgsz = dequeue_message(p_mbfcb, msg); *p_dspreq = messagebuf_signal(p_mbfcb); return(msgsz); } else if (!queue_empty(&(p_mbfcb->swait_queue))) { p_tcb = (TCB *) queue_delete_next(&(p_mbfcb->swait_queue)); msgsz = ((WINFO_MBF *)(p_tcb->p_winfo))->msgsz; memcpy(msg, ((WINFO_MBF *)(p_tcb->p_winfo))->msg, msgsz); *p_dspreq = wait_complete(p_tcb); return(msgsz); } else { return(0U); } }