I’m using a FAT system (FatsFS and STM32Cube lib)
I’m not sure how FatFS (by ChaN) will behave if you open the same file two times: once in read- and once in write-mode.
FreeRTOS’ own +FAT library has decided to either allow to open a file by:
- a single task using “w” or “w+” mode
- multiples tasks all using “r” mode
In other words: there may be many readers but just one writer.
Writing data to a file is often the realisation of a transaction. It may be a payment, a reservation, a commitment. Now if you think of it as transactions, it becomes more meaningful to introduce a third party (task) who can do the transactions. This task will handle one transaction at a time without getting interrupted
, you make that sure by design.
One product I make has four FM tuners. It is very easy to send some SPI data to a tuner and change the frequency. I have several tasks which must interact with the tuners somehow, in read- and/or write-more. Doing that directly gave problems at some point, and so I also introduced a separate
void vTunerTask( void *pvParameters )
which handles request for all four FM tuners, and that works well.