STATUS semQueueInit
    (
    SEMAPHORE * pSemaphore,             /* pointer to semaphore to init */
    int         options,                /* semaphore options */
    int         initialCount            /* initial count */
    )
    {
    if ((options & ~(SEM_CNT_OPTIONS_MASK)) != 0)
	{
	/* coverity[NULL_RETURNS] */
	errno = S_semLib_INVALID_OPTION;
	return (ERROR);
	}

    if (initialCount < 0)
	{
	/* coverity[NULL_RETURNS] */
	errno = S_semLib_INVALID_INITIAL_COUNT;
	return (ERROR);
	}

    if (semQInit (pSemaphore, options) != OK)		/* initialize queue */
	return (ERROR);

    pSemaphore->semCount = (unsigned int)initialCount;		/* initialize count */
    pSemaphore->recurse  = 0;				/* no recursive takes */
    pSemaphore->options  = options;			/* stow away options *//*lint !e734*/
    pSemaphore->semType  = SEM_TYPE_COUNTING;		/* type is counting */

    /* initialize the events structure */

    pSemaphore->events.taskId     = (int)NULL;
    pSemaphore->events.registered = 0x0;
    pSemaphore->events.options    = 0x0;

#ifdef _WRS_CONFIG_OBJECT_LIB
    /* initialize the semaphore object core information */

    objCoreInit (&pSemaphore->objCore, semClassId);
#else
    /*
     * Make the pObjClass point to a unique class structure. The class
     * structure itself is uninitialized without objLib being present.
     * By having a unique value, it is ensured that all semaphores have
     * the same unique pObjClass value.
     */

    pSemaphore->objCore.pObjClass = semClassId;
#endif	/* _WRS_CONFIG_OBJECT_LIB */

    return (OK);
    }	
예제 #2
0
STATUS semBInit(SEMAPHORE* pSemaphore, int options, SEM_B_STATE initialState)
{
	if((!semBLibInstalled)&&(OK!=semBLibInit()))
	{
		return (ERROR);
	}

	if(OK != semQInit(pSemaphore, options))
	{
		return (ERROR);
	}

	return semBCoreInit(pSemaphore, options, initialState);
}
예제 #3
0
파일: semBLib.c 프로젝트: phoboz/vmx
STATUS semBInit(
    SEM_ID      semId,
    int         options,
    SEM_B_STATE state
    )
{
    STATUS status;

    /* Check if lib is installed */
    if (semBLibInstalled != TRUE)
    {
        errnoSet(S_semLib_NOT_INSTALLED);
        status = ERROR;
    }
    else
    {
        if (options & SEM_DELETE_SAFE)
        {
            errnoSet(S_semLib_INVALID_OPTION);
            status = ERROR;
        }
        else
        {
            /* Initialize semaphore queue */
            if (semQInit(&semId->qHead, options) != OK)
            {
                status = ERROR;
            }
            else
            {
                /* Initialize semaphore queue */
                if (semBCoreInit(semId, options, state) != OK)
                {
                    status = ERROR;
                }
                else
                {
                    status = OK;
                }
            }
        }
    }

    return status;
}