Linux file system is a generalized file system, can be considered that the Linux system for any device and object operation is equivalent to the operation of the file.The Linux system abstracts all operational objects in a highly abstracted way,
Ioctl
Supported operations, such as
Simple Data transfer
Control actions, such as user space initiating pop-up media actions
Feedback the status of your hardware, such as reporting error messages
The function of a record lock is that when a process is reading or modifying a part of a file, it can prevent other processes from modifying the same file area. Record locks are actuallyA byte range lock, because it locks only one area of the file,
Linux Asynchronous notification Fasync Linux device driver induction Summary (three):7. Asynchronous Notification FasyncXxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxAsynchronous Notification Fasync is applied to
Reproduced.
To discuss the issue of writing to the same file by multiple processes in a concurrent environment, we will involve knowledge of file sharing. Before we begin, let's discuss some knowledge about file sharing.
1. File Sharing
UNIX
We often encounter the need to implement a complex functional module through C + + or other lower-level languages, and to build a Web-based demo and query data. Thanks to the power and simplicity of the Python language, the Flask framework and the
There are horizontal triggers in the IO multiplexing of Linux, and the edge triggers two modes, the difference between the two modes is as follows:Horizontal trigger: A notification is triggered if the file descriptor is ready to perform IO
OverviewThe IOCTL function is similar to the FCNTL function, and can be used to manipulate the descriptor, get or set the properties of the opened descriptor, but the two functions in the network programming related operation for different types,
Those who have used Winsock APIs know that WinSock programming is very convenient.Whether it is the underlying API wsaasyncselect () or the asynchronous socket class of MFC:Casyncsocket provides messages such as fd_accept, fd_read, and fd_close.For
LINUX serial port application developmentSerial Port OverviewThere are two basic data communication methods:Parallel Communication;Serial CommunicationSerial Communication is a commonly used computer interface, such as RS-232-C interface. This
Note: Only when epoll et (edge trigger) mode is used, you need to check whether the data has been read. When the select or epoll mode is used, you do not have to worry about whether the data has been read. If select/epoll detects that the data is
"Unix environment advanced programming" chapter 3rd-file I/O, unix environment Advanced Programming1. Introduction
For most Unix files, I/O only requires five functions: open, read, write, lseek, and close.
The functions described in this chapter
"Copyright Notice: respect for the original, reproduced please retain the source: blog.csdn.net/shallnet or .../gentleliu, the article is for learning communication only, do not use for commercial purposes"When there are multiple processes in a
Control socket file Descriptor Properties 1.set/getsockopt () modify socket properties int getsockopt (int __fd, int __level, int __optname, void *__ Restrict __optval, socklen_t *__restrict __optlen): Gets the properties of a socket. Success 0,
first, what is a file descriptor
Under Linux everything is file, for the kernel, all open files are referenced by file descriptor, the file descriptor is a non-negative integer, and when an existing file is opened or a new file is created, the
There are two to control the serial port blocking (while controlling read and write): One is when opening the serial port, the Open function is O_ndelay, and the second one can be controlled by the Fcntl () function after opening the serial
1. open the file in non-blocking mode
When you call open, use the o_nonblock option.
Instance:
// Noblock. c
# Include # Include # Include # Include # Include
# Deprecision Max 100000# Define Len 1024/* use the maximum macro buffer size */
Int
1. open the file kernel data structure
1. A process opens two files
File status flag: read, write, append, sync, non-blocking, etc.
2. A process opens the same file twice
3. Two processes open the same file
Example program:
C ++ code
Fcntl Functions
The fcntl function provides various control operations on file descriptors.
Another common system call to control file descriptor attributes and behaviors is ioctl, which can perform more control than fcntl.
However, the fcntl
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.