Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

How should one implement reader/writer locks on files?

0
Posted

How should one implement reader/writer locks on files?

0

> How should one implement reader/writer locks on files? > The locks should work accross threads and processes. The only way to lock “a file” is to use the fcntl() file locking functions. Check your man page. HOWEVER, there’s a big IF… these locks are held by the PROCESS, not by the THREAD. You can’t use them to control access between multiple threads within a process. If you are interested in a mechanism outside the file system, you could use UNIX98 read/write locks, with the pshared option to make them useful between processes (when placed in shared memory accessible to all the processes). However, UNIX98 read/write locks are not currently available on most UNIX implementations, so you’d have to wait a while. Of course you’d have to work out a way to communicate your shared memory section and the address of the read/write lock(s) to all of the processes interested in synchronizing. Also, while there are ways to make fcntl() locking mandatory instead of advisory (at least, on most s

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123