2

I have a question regarding PHP flock() function:

How PHP flock() can prevent starvation of a process?

If there is a process R constantly wanting to read a file and a process W that wants to write in the file whenever reading is complete (wants an Exclusive Lock). How does it make process W not starve?

Is there a way to use flock() and make process W not starve in PHP?

Long Le
  • 404
  • 5
  • 18
  • 1
    you can tell flock to wait (aka block) until the lock can be granted. but nothing in and of itself in flock can prevent starvation. if a file is constantly locked, then anything waiting to get its own lock on that file will be busy doing nothing but waiting. – Marc B Apr 20 '16 at 17:53

0 Answers0