How recently did the system handle this issue when a customer asked about how different users were working on the same file. This article will briefly introduce the process of multiple processes under Linux "and at the same time" operation of the same file. Suppose there are three processes A, B, and C that operate on the file a.txt file. A process should read the first to 100 characters of the file, process B should read the line containing the aa character in the file, and C should write to the a.txt file ”ABC”. The starting sequence of the three processes is A, B, and C.
[正文]
A hypothetical condition
1.1 Three processes
1, Suppose there are three processes A, B, C operate on the file a.txt file 2, A process to read the first 1 to 100 characters of the file; 3, process B to read the line containing the aa character in the file; 4, C to write to a.txt file & rdquo; ABC & rdquo;; H2>1.2 Process startup sequence
1. The startup sequence of the three processes is A, B, C;
Two processes
2.1 A process startup
The code execution steps of process A are as follows:
2.2 B process startup
Process B code execution steps are as follows:
2.3 C process startup
Process C code execution steps are as follows:
2.4 Process wakeup
At this time, processes A, B, and C are in a state of waiting for the buffer to be unlocked after the data is loaded, that is, the suspended state. After the data is loaded, the hard disk generation & rdquo; data transmission is completed & interrupt; the system informs that the system data has been loaded. After the system receives the interrupt, it unlocks the buffer and wakes up the processes in the queue. At this point, the system will wake up process C at the beginning of the team and set the C process to the ready state. Then start executing the "Write Data" code, start timing, and set the B process to the ready state. When the timing is over, the C process is completed and exits. The B process starts executing ” reads the data & rdquo; code, starts timing, and sets the A process to the ready state. When the timing is over, the B process is completed and exits. The A process starts executing ”read the code”, starts the model timing, and sets the queue to ”NULL”. When the timing is over, the A process is completed and exits. At this point, all three processes are completed.
Three Summary
From the above process, we can see that when three processes operate on one file at the same time, although the startup order of the process is A, B, C, but finally when the data is loaded into the buffer After the zone is completed, the execution order is based on the queue head of the waiting queue to the end of the team, namely C, B, and A. After the execution of the ABC three processes, the data modification is actually only in the buffer, and is not immediately written to the hard disk, but the buffer data is synchronized to the hard disk through the subsequent update process. Due to the limited space, we will not introduce them here. The readers are interested in researching on their own.
As a Linux enthusiast, after several determinations, he gave up the dual system and installed Linux
With Windows for a long time, it will inevitably start to lack freshness, so some people will try to
Find the virtual machine settings, set as shown below (additional figure: must be 3.0 u disk and pl
After VPN connection is established, need to make the following settings: 1, click & ldquo; att
Linux to view memory commands and their interpretation of the command display
The three query methods for the last reboot time of the Linux system
Solve the disk space is full, making it impossible to read and write to the disk!
Basic configuration after Centos installation
NetWare Client Easy Installation Instructions for Linux
Seven points of advice on learning Linux
Rsync installation configuration basic tutorial
vmware linux system with Internet settings
Interserver VPS ovz architecture assumes that VPN
How to let CentOS automatically install rar and unrar
Vmware 9 installation Mac 10.8 OS
Redhat5 installation network card error, can not be installed properly
Win10 virtual machine can not connect to the network solution
Windows7 system restores the default settings of the firewall (graphic tutorial)
Modify the XP settings skill set desktop adjustment
How to deal with the yellow sigh on the Win7 system device manager CD-ROM drive?
Windows 7 can not be activated by flashing the certificate. How to do
Win7 system plan backup function quick enable method
The problem of the pipeline being closed by the acceptor in the Linux system is solved