linux 文件区域锁
来源:互联网 发布:在电脑上怎么开淘宝店 编辑:程序博客网 时间:2024/05/16 19:53
F_GETLK, F_SETLK and F_SETLKW are used to acquire, release, and test
for the existence of record locks (also known as file-segment or file-
region locks). The third argument, lock, is a pointer to a structure
that has at least the following fields (in unspecified order).
struct flock {
...
short l_type; /* Type of lock: F_RDLCK,
F_WRLCK, F_UNLCK */
short l_whence; /* How to interpret l_start:
SEEK_SET, SEEK_CUR, SEEK_END */
off_t l_start; /* Starting offset for lock */
off_t l_len; /* Number of bytes to lock */
pid_t l_pid; /* PID of process blocking our lock
(F_GETLK only) */
...
};
Specifying 0 for l_len has the special
meaning: lock all bytes starting at the location specified by l_whence
and l_start through to the end of file, no matter how large the file
grows.
Any number of processes may hold a read lock
(shared lock) on a file region, but only one process may hold a write
lock (exclusive lock).
A single process can hold only one type of
lock on a file region;
Each byte in a file can have only a single type of lock on it at any one time, and may be locked for shared
access, locked for exclusive access, or unlocked.
l_type Either F_RDLCK for a shared (read-only) lock or F_WRLCK for an exclusive
(write) lock
on the same (or overlapping) regions of the file. If any process has a shared
lock, then no process will be able to get an exclusive lock on that region. In
order to obtain a shared lock, the file must have been opened with read or
read/write access.
F_UNLCK Unlock; used for clearing locks
F_WRLCK An exclusive (or “write”) lock. Only a single process may have an exclusive
lock on any particular region of a file. Once a process has such a lock, no other
process will be able to get any sort of lock on the region. To obtain an exclusive
lock, the file must have been opened with write or read/write access.
- linux 文件区域锁
- Linux文件(区域)锁函数 -- open()、fcntl()
- 文件区域锁
- Linux下面文件内容到内存区域的映射
- linux 区域截图 screenshot
- 区域锁
- linux中线程同步之区域锁(Scoped locking)
- linux 下区域语音设置
- linux下 指定区域截图
- Linux文件---文件锁
- 区域锁(Scoped locking)
- 区域
- AD9 PCB文件黑色区域如何改变?
- ECSHOP 模版文件中的编辑区域
- 区域网计算机高级共享文件
- linux内存管理之存储器区域
- linux内存管理之存储器区域
- 14.linux内核内存区域Zone
- xml的读写时的乱码问题
- Portlet开发例子HelloWorld
- 数兔子 bjfu 1144 动态规划
- Android拦截一个拨出去的电话
- JAVA筆記-wait()、notify()、notifyAll() 執行緒間的等待與喚醒機制的互動
- linux 文件区域锁
- POJ 3252 Round Numbers
- vc多线程编程
- 编程之美——精确表达浮点数
- Yii Framework 开发教程(1) 第一个应用Hello World
- POJ3259 回到过去(带负权的单源最短路径)
- Shape Drawable Xml的background
- C++学习笔记(面向对象化程序设计的类)
- oracle函数大全