Download 6 - Diversant Software
Transcript
RTX-51 / RTX-251
89
os_free_block
Task function
The system operation, os_free_block, returns a memory block to the associated
pool. After calling this function, the calling task must not execute any more
operations in this memory block.
Prototype:
signed char os_free_block (unsigned int block_size,
void xdata *block)
Parameter:
block_size is the actual block size. A pool must exist which
contains the blocks of the required size.
block designates the returned block.
Return Value:
OK (0):
Block was returned correctly.
NOT_OK (-1):
Block could not be returned. One of the following exceptions
occurred:
n
n
Invalid block address.
Block was never referenced with "os_get_block".
See Also:
os_create_pool, os_get_block, os_check_pool
Note:
The system operation ‘os_free_block’has limited capabilities
to detect wrong block addresses. Because of this a return
value of OK may be returned, even if an invalid block address
was specified.
Example:
#include <rtx51.h>
/* Use rtx251.h for RTX-251 */
void pool_task (void) _task_ 0 _priority_ 0 {
int xdata *new_ptr;
/* Request an element */
if ((new_ptr = os_get_block (2)) == 0) {
... error handling
}
/* Assign value 3291 to the received block */
*new_ptr = 3291;
4