File segment/section/record locks in Linux threads

前端 未结 4 1749
萌比男神i
萌比男神i 2021-01-28 16:42

I have a multi-threaded process where a file is shared (read and written) by multiple threads. Is there any way a thread can lock one file segment so that other threads cannot a

4条回答
  •  花落未央
    2021-01-28 17:15

    If you don't need file locks between different processes, avoid the file locks (which are one of the worst designed parts of the POSIX API) and just use mutexes or other shared memory concurrency primitives.

提交回复
热议问题