-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do you implement thread saftey? #20
Comments
Not implemented. I see what do you mean ... This is a wrapper of the wrapper. Perhaps @BrianPugh can take a look in future. |
Dang, I guess I misinterpreted that. Thanks anyway! |
@MSmithDev if you're curious, basically upon filesystem initialization, I just allocate a FreeRTOS I didn't know that littlefs added thread safety internally; we could migrate to that, but I don't really see a benefit at the moment. |
@BrianPugh Thanks, I will definitely look into that, I personally haven't done much with Mutex and Semaphores so I need to read up on that first. |
Did anyone solve the Thread Safe issue? |
There is no thread safety built in currently. You have to handle the tasks in your code and make sure it can't happen. |
All actions are guarded by mutexs, I implemented this before upstream littlefs had support. What exact use case is causing errors? |
@BrianPugh I don't know exactly where is the colision but I seems to be when some task is writing or reading in Core0 and ESPAsyncWebServer request on Core1 accessing to some datafile. |
I am currently writting a wrapper for LITTLEFS using SemaphoreHandle_t at open() and close() functions my header file:
Cpp file:
Now I have an issue with the wrapper I don't know how to handle the close() function using/capturing the "File" pointer at close action to trigger the fs_unlock() Any idea? I am not a .cpp expert |
I think you might be misguided, this is already builtin: https://github.com/lorol/LITTLEFS/blob/master/src/esp_littlefs.c#L662 Is your issue related to this? joltwallet/esp_littlefs#18 Basically its an upstream issue that having two filedescriptors open for the same file will run into issues. |
@BrianPugh @lorol It seems that esp_littlefs.c is not used everything is linked to FS.cpp so now I am fully misunderstanding how LITTLEFS is working. Regarding the two filedescriptors open is possible that that is my problem, to make the code thread safe will be enough to put the sem_take() before the File pointer is linked to LITTLEFS library, is it? Reminder, my scenario: core0 working on readwrite stuff and core1 used by ESPAsyncWebServer to server and return written data by core0. It can occur that one file can be reading by core1 while core0 is already writing/reading on it. |
I saw that Thread Safety was added back in December, Is there any documentation on this? how do you implement it?
The text was updated successfully, but these errors were encountered: