文件锁定和pthread [英] File locking and pthreads

查看:99
本文介绍了文件锁定和pthread的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在开发一个用于考试的多线程TFTP服务器,但是在寻找一种方法来锁定适用于pthread的文件(就像fcntl,flock和lockf对进程所做的那样)时,我遇到了很多问题.我认为这是一个典型的问题,因此我希望有人可以提出一个简单"的解决方案.

Hi,
I''m developing a multithreaded TFTP server for an exam, but i''m running into a lot of problems in finding a way to lock files (just as fcntl, flock and lockf do for processes) that works for pthreads. I think this is a typical problem, so i hope someone can suggest a "simple" solution.

推荐答案

只需使用提供的POSIX线程同步机制(如互斥锁,条件变量).
Just use the provided POSIX thread synchronization mechanism (like mutex, condition variables).


这篇关于文件锁定和pthread的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆