文件夹锁定和过程同步
我有两个过程(我们称它们为P1& p2)。 P1从文件夹中读取数据,P2更新该文件夹。当P2想要更新该文件夹(使用 rsync )时,必须等待P1是否正在阅读,反之亦然(P1必须等待P2是否正在更新该文件夹)。我试图使用静音/信号量等...但是我有一些问题,例如:如果P2在更新时崩溃,那么P1将继续等待Mutex/Semaphore发布。 是否有一种方法或构建的Linux可以使同步这样的同步:文件夹本身允许P1读取数据,而P2等待更新,如果P1崩溃,则没有等待的过程,因此P2可以更新? 还是您还有其他建议?
I have 2 processes (let's call them P1 & P2). P1 reads data from a folder and P2 updates that folder. When P2 wants to update that folder (using rsync), it has to wait if P1 is reading and vice versa (P1 has to wait if P2 is updating the folder). I tried to use mutexes/semaphores and others... but I have a few problems like: if P2 crash while updating, then P1 will keep waiting for mutex/semaphore release.
Is there a way or something build-in linux to make the synchronization like this: the folder itself allow P1 to read data, while P2 wait to update, and if P1 crash, then there's no process to wait for, so P2 can update?
Or you have other suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论