FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [September 2013 Threads] Implementation of large arrays inter tasksPosted by Damien Etienne on September 11, 2013 Hello,
I'm quite new with rtos and I have a question because I'm facing a sensitive problem
I've implemented a task that handle a SD Card. Other task can write read and perform several action on the sd card.
My problem is how to safely transfer the data, since I'm limited in ram, I cannot make a queue that has all the required array.
I'm based on the freertos UDP/IP example http://www.freertos.org/Pend-on-multiple-rtos-objects.html
Passing a pointer to an array is not a problem, although how to safely do it is a big headache. I've made a structure with different pointers to the required arrays and also few flags to avoid double access but even in that case, some array may be accessed by two tasks at the same time.
The point is that my SDCard task should not have large array but only access by pointers to arrays given by other tasks.
What would be the best way to do that ?
Thanks
RE: Implementation of large arrays inter tasksPosted by Richard on September 11, 2013 The simplest way would be to simply guard access to the SD card with a semaphore. For example:
void MyReadFunction() { /* Wait to get the seamphore. */ if( xSemaphoreTake() == pdPASS ) { /* Got the semaphore, can access the card here. */ ....
/* Must give the semaphore back so other tasks waiting to access the card can do so. */ xSemaphoreGive(); } }
and likewise for the Write function.
Regards.
RE: Implementation of large arrays inter tasksPosted by Damien Etienne on September 11, 2013 I cannot access directly the SD cards from task due to memory limitation, that's why i have a separated task to avoid having big depth of stack calls. The card is already protected against double access by semaphore.
The problem I'm facing is not the sd card access but the handling of large array inter task without having to recopy the arrays (what queue does).
So far the solution I consider might be a queue with a pointer to a structure that contain a pointer to the array also as a mutex flag and checking this struct through critical code execution to check and set the mutex flag of the struct...
RE: Implementation of large arrays inter tasksPosted by Richard Damon on September 12, 2013 The way to avoid copying large buffers is to pass the address of the buffer in the queue rather than the buffer itself. When the receiving task is done with it, it needs to return the buffer to where it came from so the originating task can use it again.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|