示例#1
0
static void privilege_task(uint_32 initial_data) 
{
    _mqx_uint msg[MSG_SIZE];
    _lwmem_pool_id mem_pool_id;
    LWMEM_POOL_STRUCT mem_pool;
    pointer mem_pool_start;
    
    LWMEM_POOL_STRUCT_PTR usr_pool_ptr;
    pointer usr_pool_start;
    
    /* memory pool: Read-Only for User tasks */
    mem_pool_start = _mem_alloc(1024);
    mem_pool_id = _lwmem_create_pool(&mem_pool, mem_pool_start, 1024);
    _mem_set_pool_access(mem_pool_id, POOL_USER_RO_ACCESS);

    /* message queue to communicate between this task and User tasks */
    que = (uint_32*)_mem_alloc_from(mem_pool_id, sizeof(LWMSGQ_STRUCT) + NUM_MESSAGES * MSG_SIZE * sizeof(_mqx_uint));
    _usr_lwmsgq_init((pointer)que, NUM_MESSAGES, MSG_SIZE);

    /* memory pool: Read-Write for user tasks */
    usr_pool_ptr = _usr_mem_alloc(sizeof(LWMEM_POOL_STRUCT));
    usr_pool_start = _mem_alloc(1024);
    usr_pool_id = _lwmem_create_pool(usr_pool_ptr, usr_pool_start, 1024);
    _mem_set_pool_access(usr_pool_id, POOL_USER_RW_ACCESS);

    /* create the user "main" task, whcih then creates the others */
    _task_create(0, USR_MAIN_TASK, USR_TASK_CNT);

    /* receive messages from user tasks and print */
    while (1) {
        _lwmsgq_receive((pointer)que, msg, LWMSGQ_RECEIVE_BLOCK_ON_EMPTY, 0, 0);
        printf(" %c \n", msg[0]);
    }
}
示例#2
0
/*!
 * \brief
 *
 * \param size
 *
 * \return void *
 */
void *MFS_mem_alloc(_mem_size size)
{
    if (_MFS_pool_id)
    {
        return _mem_alloc_from(_MFS_pool_id, size);
    }
    else
    {
        return _mem_alloc(size);
    }
}
示例#3
0
/*FUNCTION*-----------------------------------------------------
* 
* Function Name    : _mem_alloc_uncached
* Returned Value   : pointer. NULL is returned upon error.
* Comments         : allocates a block of memory
*
*END*---------------------------------------------------------*/
pointer _mem_alloc_uncached
    (
        /* [IN] the size of the memory block */
        _mem_size size
    )
{
    KERNEL_DATA_STRUCT_PTR  kernel_data;
    pointer                 result;

    _GET_KERNEL_DATA(kernel_data);
    //_KLOGE2(KLOG_mem_alloc_uncached, req_size);

    result  = _mem_alloc_from(&kernel_data->UNCACHED_POOL, size);

   //_KLOGX3(KLOG_mem_alloc_uncached, result, kernel_data->UNCACHED_POOL.POOL_BLOCK_IN_ERROR);
    
    return result;
}