Sample Header Ad - 728x90

How does the Kernel implement synchronisation techniques on file access

0 votes
1 answer
267 views
I've read that the kernel implements synchronisation mechanisms when accessing files. For example, if we try and write or read to a file in the file system using read() or write() from different processes at the same time, the kernel will prevent race conditions. How exactly is this implemented? I have used Mutexes and Semaphores when writing code before which prevents different threads or processes executing a certain part of the code at the same time. In this case, I assume that the kernel should only implement a locking mechanism when more than one process or thread tries to read or write to the same file descriptor, not any time read() or write() is called, which could be for any file descriptor. How would this be achieved?
Asked by Engineer999 (1233 rep)
Nov 30, 2022, 11:03 AM
Last activity: Nov 30, 2022, 11:49 AM