In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
atomic operation pread,pwirte
#include
ssize_t pread(int fd, void *buf, size_t nbytes, off_t offset);//Return value: Number of bytes read, 0 if it has reached the end of the file,-1 if it is wrong
ssize_t pwrite(int fd,const void *buf ,size_t nbytes, off_t offset);//Return value: If successful, return number of bytes written, if error, return cause-1
pread,pwirte is equivalent to calling lseek and read or write sequentially, but calling pread,pwrite cannot interrupt its positioning and reading and writing operations, and cannot update the file pointer.
od -c file: View the actual contents of file
File sharing:
File Descriptors: Each process has an entry in the process table. Each entry has an open file descriptor table (which is why it is necessary to copy file descriptors). Each file descriptor table entry is associated with: (a) file descriptor flags. (b)Pointer to a file table entry.
File table: The kernel maintains a file table for all open files, each file table entry containing: (a) file status flags (read, write, add, synchronous, non-blocking, etc.). (b)Offset of the current file. (c)Pointer to the v node table entry of the file.
v node: Every open file (or device) has a v node structure. Contains information about the file type and pointers to functions that perform various operations on the file. For most files, the v node also contains the i node (inode) of the file. This information is read from disk into memory when the file is opened, so all information about the file is quickly available. For example, the i node contains the owner of the file, the length of the file, the device on which the file resides, pointers to the actual data blocks used by the file on disk, and so on.
The fcntl function can change the properties of an already opened file.
int fcntl(int filedes, int cmd ,....);
cmd:
F_DUPFD copies an existing file descriptor.
F_GETFD or F_SETFD Get/Set File Descriptor Flags
F_GETFL or F_SETFL Get/set file status flags, i.e. several states of mode in the open function
F_GETOWN or F_SETOWN Get/set asynchronous I/0 permissions
F_GETLK,F_SETLK or F_SETLKW Get/Set Record Lock
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.