当有多个文件在等待锁定时,flock是否会维护队列



如果有人能帮助我理解flock是如何工作的,那就太好了。假设我有以下场景:

process A opens the lock file, finds it does not exists, so it creates it.
process A acquires the lock
process B opens the lock (finds it already exists)
process B tries to acquire the lock but has to wait-- Wait 1
process C opens the lock (finds it already exists)
process C tries to acquire the lock but has to wait-- Wait 2
process D opens the lock (finds it already exists)
process D tries to acquire the lock but has to wait-- Wait 3

基于上述场景,有三个进程正在等待获取锁。我的问题是,一旦进程A释放了锁,等待的作业将如何处理?它是先进先出吗?

谢谢,Kavin

我尝试用一个工作示例脚本测试这个场景,发现等待的作业是以随机的方式处理的。

最新更新