FreeRTOS+FAT thread safety

FreeRTOS+FAT mentions that it is Fully thread aware. I have some doubts regarding this.

  • What does Fully thread aware exactly mean?
  • How does it differ from thread safe?
  • Is it safe to use in multi threaded environment?

Tried looking around on web but could not find a clear difference.

I can’t help you with your first two questions, but I’ve been using it in heavily multi-threaded applications for a long time. If you compare it to FatFs, for example, FatFs has some support for “re-entrancy” or thread safety, but it does not appear to have sufficient FAT and directory locking in FatFs to make operations like f_mkdir, f_chdir and f_getcwd thread safe, whereas FreeRTOS+FAT does.

Take a look at ff_locking.c and vMultiTaskStdioWithCWDTest in ff_stdio_tests_with_cwd.c.

Also, see Announcement: FreeRTOS Symmetric Multiprocessing (SMP) +FAT running on Raspberry Pi Pico for an example.

1 Like

I think thread aware and thread safety are used interchangeably i.e. you can use this library in multi-threaded environment.

1 Like

One possible semantic difference might be regarding performance. I can imagine a “thread safe” implementation that just serializes all access to the file system with a single mutex. However, this would perform poorly in a multi-tasking, multi-processing, multi-“disk” environment; you’d really want finer-grained locking that maximizes concurrency.