问题描述
如果有人能帮助我了解 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
基于上面的场景,有3个进程在等待获取锁。我的问题是,一旦进程 A 释放锁,等待的作业将如何处理?是先进先出吗?
谢谢, 凯文
解决方法
我尝试用一个工作示例脚本测试这个场景,我发现等待的作业是以随机方式处理的。