Threadsafety

From FullFAT
Jump to: navigation, search

FullFAT is a thread-safe filesystem implementation.

That is multiple files can be used from multiple threads simultaneously. However there are some restrictions.

NOTE THREAD SAFETY MUST BE CAREFULLY CONFIGURED DURING INTEGRATION OF FULLFAT

Low Level Data I/O

FullFAT assumes that the underlying data I/O functions provided by the developer are thread-safe. That is, FullFAT can call the provided FF_WRITE_BLOCKS and FF_READ_BLOCKS interface functions at any point in time, regardless of whether a read or write operation is currently being performed.

If these functions are not thread-safe, then thread-safety is not possible.

(Versions 1.0.1 will wrap these functions with a thread-safety layer, making thread-safe integration easier (As a build option)).

File I/O Transactions

File I/O is not thread-safe by nature, neither is it thread-safe in Windows or Linux. However for version 1.0.1, FullFAT will add extra thread-safety to file I/O operations as a build option.

!DO NOT USE FILE I/O IN MORE THAN A SINGLE THREAD!

This won't stop data corruption, but it will stop any undefined behaviour or crashes when FullFAT is used in this way.

It simply prevents the internal state of the FF_FILE object from being corrupted.

There will also be another build option, to define complete thread-safety of file I/O within FullFAT. This will be for commercially licensed users only. It will allow a single file to be opened from multiple threads safely. However, it still doesn't guarantee against data corruption.

Personal tools