Exemplo n.º 1
0
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);
}
Exemplo n.º 2
0
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);
}
Exemplo n.º 3
0
ER_UINT
acre_sem(const T_CSEM *pk_csem)
{
	SEMCB			*p_semcb;
	SEMINIB			*p_seminib;
	ATR				sematr;
	uint_t			isemcnt, maxsem;
	ID				domid;
	const DOMINIB	*p_dominib;
	ACPTN			acptn;
	ER				ercd;

	LOG_ACRE_SEM_ENTER(pk_csem);
	CHECK_TSKCTX_UNL();
	CHECK_MACV_READ(pk_csem, T_CSEM);

	sematr = pk_csem->sematr;
	isemcnt = pk_csem->isemcnt;
	maxsem = pk_csem->maxsem;

	CHECK_VALIDATR(sematr, TA_TPRI|TA_DOMMASK);
	CHECK_PAR(0 <= isemcnt && isemcnt <= maxsem);
	CHECK_PAR(1 <= maxsem && maxsem <= TMAX_MAXSEM);
	domid = get_atrdomid(sematr);
	if (domid == TDOM_SELF) {
		if (rundom == TACP_KERNEL) {
			domid = TDOM_KERNEL;
		}
		else {
			domid = p_runtsk->p_tinib->domid;
		}
		sematr = set_atrdomid(sematr, domid);
	}
	switch (domid) {
	case TDOM_KERNEL:
		p_dominib = &dominib_kernel;
		break;
	case TDOM_NONE:
		p_dominib = &dominib_none;
		break;
	default:
		CHECK_RSATR(VALID_DOMID(domid));
		p_dominib = get_dominib(domid);
		break;
	}
	CHECK_ACPTN(p_dominib->acvct.acptn1);

	lock_cpu();
	if (tnum_sem == 0 || queue_empty(&(p_dominib->p_domcb->free_semcb))) {
		ercd = E_NOID;
	}
	else {
		p_semcb = (SEMCB *)
					queue_delete_next(&(p_dominib->p_domcb->free_semcb));
		p_seminib = (SEMINIB *)(p_semcb->p_seminib);
		p_seminib->sematr = sematr;
		p_seminib->isemcnt = isemcnt;
		p_seminib->maxsem = maxsem;

		acptn = default_acptn(domid);
		p_seminib->acvct.acptn1 = acptn;
		p_seminib->acvct.acptn2 = acptn;
		p_seminib->acvct.acptn3 = p_dominib->acvct.acptn1;
		p_seminib->acvct.acptn4 = acptn;

		queue_initialize(&(p_semcb->wait_queue));
		p_semcb->semcnt = isemcnt;
		ercd = SEMID(p_semcb);
	}
	unlock_cpu();

  error_exit:
	LOG_ACRE_SEM_LEAVE(ercd);
	return(ercd);
}