

All threads suspended waiting for a memory block from this pool are resumed and given a TX_DELETED return status. This service deletes the specified block-memory pool. tx_block_pool_prioritize, tx_block_releaseĭelete memory block pool Prototype UINT tx_block_pool_delete(TX_BLOCK_POOL *pool_ptr).tx_block_pool_info_get, tx_block_pool_performance_info_get.tx_block_allocate, tx_block_pool_delete.The reason there are not 20 blocks in the pool isīecause of the one overhead pointer associated with each block. * If status equals TX_SUCCESS, my_pool contains 18 memory blocks Status = tx_block_pool_create(&my_pool, "my_pool_name", Each block in this pool is defined to be 50 bytes * Create a memory pool whose total size is 1000 bytes starting atĪddress 0x100000. Initialization and threads Preemption Possible TX_SIZE_ERROR (0x05) Size of pool is invalid.TX_CALLER_ERROR (0x13) Invalid caller of this service.TX_PTR_ERROR (0x03) Invalid starting address of the pool.Either the pointer is NULL or the pool is already created. TX_POOL_ERROR (0x02) Invalid memory block pool pointer.TX_SUCCESS (0x00) Successful memory block pool creation.pool_size* Total number of bytes available for the memory block pool.The starting address must be aligned to the size of the ULONG data type.


*Each memory block contains one pointer of overhead that is invisible to the user and is represented by the "sizeof(void )" in the preceding formula. The memory area specified is divided into as many fixed-size memory blocks as possible using the formula: This service creates a pool of fixed-size memory blocks. tx_block_pool_performance_system_info_getĬreate pool of fixed-size memory blocks Prototype UINT tx_block_pool_create(.* If status equals TX_SUCCESS, memory_ptr contains the address of Status = tx_block_allocate(&my_pool, (VOID **) &memory_ptr, Assume that the pool hasĪlready been created with a call to tx_block_pool_create. Initialization, threads, timers, and ISRs Preemption Possible TX_PTR_ERROR (0x03) Invalid pointer to destination pointer.TX_WAIT_ERROR (0x04)Ě wait option other than TX_NO_WAIT was specified on a call from a nonthread.TX_WAIT_ABORTED (0x1A) Suspension was aborted by another thread, timer or ISR.TX_NO_MEMORY (0x10) Service was unable to allocate a block of memory within the specified time to wait.TX_DELETED (0x01) Memory block pool was deleted while thread was suspended.TX_SUCCESS (0x00) Successful memory block allocation.timeout value (0x00000001 through 0xFFFFFFFE) - Selecting a numeric value (1-0xFFFFFFFE) specifies the maximum number of timer-ticks to stay suspended while waiting for a memory block.TX_WAIT_FOREVER (0xFFFFFFF) - Selecting TX_WAIT_FOREVER causes the calling thread to suspend indefinitely until a memory block is available.This is the only valid option if the service is called from a non-thread e.g., Initialization, timer, or ISR. TX_NO_WAIT (0x00000000) - Selecting TX_NO_WAIT results in an immediate return from this service regardless if it was successful or not.On successful allocation, the address of the allocated memory block is placed where this parameter points.ĭefines how the service behaves if there are no memory blocks available. Pointer to a previously created memory block pool. The results are unpredictable and often fatal! Parameters If this happens, corruption occurs in an adjacent (usually subsequent) memory block.
#Queue anylogic enable preemption code
It is important to ensure application code does not write outside the allocated memory block.
