Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

Implementation of large arrays inter tasks

Posted 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 tasks

Posted 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 tasks

Posted 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 tasks

Posted 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.


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists