/* * ======== GateProcessSupport_enter ======== */ IArg GateProcessSupport_enter(GateProcessSupport_Handle gate) { GateMutexPri_Handle bios6gate; bios6gate = GateProcessSupport_Instance_State_gate(gate); return (GateMutexPri_enter(bios6gate)); }
void mutex_lock(mutex_t *m) { #ifdef POSIX pthread_mutex_lock(m); #elif defined(SYSBIOS) m->key = GateMutexPri_enter(m->gate); #else EnterCriticalSection(m); #endif }
/* ========================================================================== */ TIMM_OSAL_ERRORTYPE TIMM_OSAL_SemaphoreCreate(TIMM_OSAL_PTR *pSemaphore, TIMM_OSAL_U32 uInitCount) { TIMM_OSAL_ERRORTYPE bReturnStatus = TIMM_OSAL_ERR_NONE; TIMM_OSAL_SEMAPHORE *pHandle = TIMM_OSAL_NULL; Semaphore_Params params; IArg keyOSALgate; *pSemaphore = TIMM_OSAL_NULL; pHandle = (TIMM_OSAL_SEMAPHORE *) TIMM_OSAL_Malloc(sizeof(TIMM_OSAL_SEMAPHORE), TIMM_OSAL_TRUE, 0, TIMMOSAL_MEM_SEGMENT_EXT); if(TIMM_OSAL_NULL == pHandle) { bReturnStatus = TIMM_OSAL_ERR_ALLOC; goto EXIT; } /* Generate name of the semaphore */ keyOSALgate = GateMutexPri_enter(gOSALgate); sprintf(pHandle->name, "SEM%lu", gUniqueSemNameCnt++); /*To prevent array overflow*/ if(gUniqueSemNameCnt == 9999) gUniqueSemNameCnt = 0; GateMutexPri_leave(gOSALgate, keyOSALgate); /*Initialize with default values*/ Semaphore_Params_init(¶ms); params.instance->name = (xdc_String)(pHandle->name); params.mode = Semaphore_Mode_COUNTING; pHandle->sem = Semaphore_create(uInitCount,¶ms,NULL); if(pHandle->sem == NULL) { TIMM_OSAL_Free(pHandle); bReturnStatus = TIMM_OSAL_ERR_UNKNOWN; } /* Update sem counter */ gSemCnt++; *pSemaphore = (TIMM_OSAL_PTR)pHandle; EXIT: return bReturnStatus; }