aturowski wrote on Friday, July 10, 2009:
Remember that you have to communicate this information to the other task(s) which can be running on totally different priority than flash task. To let scheduler deal with priorities and task preemption, the best way is use inter-process communication stuff in FreeRTOS - for example queues.
In general almost all real-time applications are event driven. This means that particular task should be woken when there is an event need to be processes by this task. Personally I prefer following architecture: each task has input queue and task main function blocks on waiting for this queue. If event comes, ISR or other task puts a message into these queue and task is woken if there all higher priority tasks completed their processing. When task is woken, then it processes messages in queues and automatically blocks, if there are no more messages. The example of this architecture you can find in https://freeecu.svn.sourceforge.net/svnroot/freeecu/trunk
Lets assume that your application follows above architecture. The task wanting to write something to flash puts pointer to buffer, buffer lenght and pointer to its own input queue handler into flash task input queue. Flash task does the write, frees the buffer memory and puts information that writing is finished/error etc. in writing task input queue by using handler pointer. The writing task is then woken, knows flash write status and decides, what to do next.
For flash reading the task writes the following to flash task input queue: flash address, read lenght and pointer to handler to its input queue. The flash task is then woken, allocates buffer in memory, does flash read and pass the pointer to buffer to reading task input queue. Reading task is woken, processes the data and frees buffer when done.
This way all tasks priorities are sorted by scheduler, no write/read request is lost, many tasks can write to flash flawlessly.
Hope that helps,