And the Linux operating system call interface

Linux operating system contains the following subsystems:

 

 

 

System call subsystems: the operating system function calls the same entrance;

Process management subsystem: life cycle and resource management for the execution of the program;

Memory management subsystem: system memory management, distribution, recovery, isolation;

File subsystem    : internal system everything is a file, the file management;

Device subsystems    : manages the input and output devices;

Network Subsystem    : responsible for foreign exchange, network protocol stack and send and receive network packets.

Core structure is as follows:

 

 

 

1. Virtual File System VFS

  DETAILED located in user space and kernel files between systems, a variety of specific abstraction layer extracted file system, to provide users with a standard file system call interface. Specific data structure of the file system abstract, unified interface to process the call ( the Read , Open ).

 

 

 

1.  System IO operation (interface)

Including : a. Basic file operations: Open , the Read , the Write and so on ; b. A file lock (to avoid multiple user processes compete operations on the same file, fcntl () for file locking), to solve the problem of file sharing;   c. Multiple multiplexing: solving I / O multiplexing problems (reusable system interface)

2.1. Linux IO model ( 5 species)

Should be: synchronous blocking IO , synchronous non-blocking IO , multiplexed IO , the drive signal IO , asynchronous IO

  Blocking IO model: the system call IO ( Interface ) function is not completed, would have been blocked pending until the completion of data copy ;

  Non-blocking IO model: No matter whether the application is complete when the system call, return immediately!

  Multiplexing IO model: the system call is not completed, the function waits system IO can also operate other function calls; (multifunctional)

  Asynchronous IO : let the kernel to complete the process of IO operation, the kernel has finished in the notification process operation; (lane)

The first four are synchronized IO , only the last is asynchronous IO .

2.2 multiplexing the IO ( the epoll , poll , SELECT function)

  select and poll is basically about the same, in addition to select there listening event the number of restrictions ( 1024 Ge) , and other poll is not much difference. The user program each time to listen, listen for events must be set from user mode to kernel mode execution copy, and then return to user mode , once an event is triggered only by traversing the way to find a trigger event, a large overhead.

  EPol L finest multiplexing mechanism! Monitoring no upper limit, when registering a new event only once to copy all listening events to the kernel can , epoll is concerned only with active fd , via a callback mechanism unordered traversal and improve efficiency.

3 standard IO operations

  The basic IO operations ( Read , Write , Open no buffer space, the user program must switch from user mode to kernel mode, performs a corresponding operation command, and then proceed to return to user mode code -> efficiency to improve the user program, Linux also provides a standard IO operations ( the fopen () , fread () , fwrite () , the gets () , the puts () , etc., R & lt, RB +, w.wb + ). with the buffer, the buffer based on the flow, the data as much as possible multi write buffer and then read in one time, reducing the user mode - kernel mode - user mode switching, to improve the efficiency of program execution.

Guess you like

Origin www.cnblogs.com/hjh-666/p/11449451.html