Skip to content
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

Multi-thread safety about disk #91

Open
coolyjg opened this issue Apr 12, 2024 · 2 comments
Open

Multi-thread safety about disk #91

coolyjg opened this issue Apr 12, 2024 · 2 comments

Comments

@coolyjg
Copy link

coolyjg commented Apr 12, 2024

It seems that this implementation do not guarantee multi-thread safety?
Since in struct FileSystem, the disk field is wrapped by RefCell which would panic if two thread call borrow_mut() (considering multi-core scenario).
By the way, if fatfs do not guarantee multi-thread safety, I think it at least should not panic, but keep related data dirty.

@rafalh
Copy link
Owner

rafalh commented Apr 12, 2024

AFAIK FileSystem is not Send so you can't share it between threads . To use it in a multi-threaded application you have to wrap it in a Mutex. Therefore there is no risk of borrow_mut panicking.
If I'm wrong please provide an example where it could panic.

@coolyjg
Copy link
Author

coolyjg commented Apr 15, 2024

We tried to use rust-fatfs for our own operating system in non-std scenario.
A mutex for the whole file system could work, but every fs operation is serialized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants