PxMcRequest_EvWait()
Create a memory class object while waiting for events.
- APPLIES TO
-
1.0.0
- SYNOPSIS
-
PxMcEvent_t PxMcRequest_EvWait (PxMcType_t mctype, PxSize_t size, PxOpool_t OpoolId, PxEvents_t events); - ARGUMENTS
|
|
|
|
|
|
|
- RETURN VALUES
-
-
Valid memory class handle on success
-
Invalid memory class handle on failure
-
Event mask that caused the call return
-
- ERROR CODES
-
PXERR_ACCESS_RIGHTthe calling task has not the right to access the object pool
PXERR_OPOOL_ILLOPOOLopoolidis not a valid object poolPXERR_OBJ_ABORTEDRequest aborted by an event
PXERR_OBJ_NOOBJNo free object is available
PXERR_GLOBAL_ILLEGAL_COREThe requested object pool is not on the same core
PXERR_OBJ_ILLOBJThe passed object handle is not valid
PXERR_MC_ILLTYPEIllegal MC type
PXERR_MC_ILLSIZEInsufficient block size
PXERR_MC_ILLALIGNInvalid memory block or size alignment in memory insert
PXERR_INTERNAL_INCONSISTENCYInconsistency of internal structures
PXERR_UNSUPPORTED_MCTYPEmctypeis not supported (IfmctypeisPXMcVarsized,PXMcVarsizedAligned,PXMcVarsizedAdjusted)PXERR_EVENT_ZEROThe given event mask is zero
- DESCRIPTION
-
The
PxMcRequest_EvWaitfunction creates a memory class of typemctypeby converting a generic object from object poolOpoolId. The memory class object handle is returned. If there is no free object available, thePxMcRequest_EvWaitwaits until a free object is available or until an event from the mask of events occurs. For each memory class type the size parameter has different meaning.The following memory class types exist:
-
PXMcFixsized
-
PXMcBuddyMemory
The
PXMcFixsizedmemory class can only manage memory blocks of the same size. The size parameter is set during memory class creation and defines the (common) size of any memory block managed by the memory class. The size parameter can be read byPxMcGetSizefunction.The PXMcBuddyMemory classes can manage memory blocks of different power of two sizes. Each block in the memory class is aligned to its size. The minimum block size is 32 bytes.
-
- IMPLEMENTATION GUIDELINES
-
- Before call
-
-
The memory class type given in
mctypemust be of typePxMcType_tand may have one of the following values (V):-
PXMcFixsized -
PXMcVarsized -
PXMcVarsizedAligned -
PXMcVarsizedAdjusted
-
-
The
sizeparameter must have a plausible value (V). -
OpoolIdmust be a valid PXROS-HR object pool and the calling task must have the access right to take objects from this object pool (V). The validity ofOpoolIdmay also be checked by thePxOpoolIsValidmacro (F). The object pool must be created on the same core as the caller runs on. The creator core id can be read with the macroPxOpoolCoreIdand the own core id withPxGetCoreId(C). Typically the task’s default object poolPXOpoolTaskdefaultis used for this purpose. -
The parameter
eventscontains a bitmask of events awaited and should not be zero. Typically the event mask is a constant (V). -
The calling task must have the access right to create new resources (V).
-
- After call
-
-
The returned value is a structure of type
PxMcEvent_t. The received events are stored in theeventspart, the memory class id is given in themcpart of the structure. This id may be checked with one of the following macros:-
PxMcIdIsValid()must be true. -
PxMcIdGet()must not be_PXIllegalObjId. -
PxMcIdError()must bePXERR_NOERRORotherwise the returned error code has to be interpreted (C).
-
-
- Best Practice
-
-
PxMcRequest_EvWaitmay block, if no PXROS-HR object is available and no instance (task or handler) sends an event. If blocking calls are prohibited,PxMcRequest_NoWaitshould be used instead or the call should be monitored by the PXROS-HRPxTomechanism. -
PxMcRequest_EvWaitshould only be called during initialization to ensure the availability of the memory class.
-
- SEE ALSO
- USAGE
-
#include "pxdef.h" PxMcEvent_t mcEv = PxMcRequest_EvWait(64, PXMcFixsized, OpoolId, MY_EVENT_MASK) if (!PxMcIdIsValid(mcEv.msg) || (mcEv.events != MY_EVENT_MASK)) { // Report error } else { // Handle event }