2012年3月21日星期三

beats by dre saleHarbin University of Science and Technology softwareengineering 08-7 Li Wanpeng

Harbin University of Science and Technology softwareengineering 08-7 Li Wanpeng original works ,the reprint please indicate the source of common Linuxshell allows redirection ,and redirect is the use of the pipeline .
For example :$LS PR LPR LS ( command to list the files in a directory ) output through a conduit connected to the command input on PR standard paging .Finally,beats by dre sale, the command PR standard output is connected through a pipeline to the command LPR standard input ,resulting in the default printer to print out the results of .
The process does not feel this redirection ,and their usual work .It was built by shell process between the temporary pipe .Pipeline is one-way ,FIFO ,unstructured ,fixed size byte stream ,it to the standard output of one process and another process standard input connected together .
Write process at the trailing end of the pipe to write data ,read process in the pipeline and the head end of read data .Data read from pipe will be removed ,other reading process can read the data .
Pipeline provides a simple flow control mechanism .The process of attempting to read the air pipeline ,the data is written to the pipeline ,processes will have been blocked .Similarly, the pipeline had full, process and attempt to write the pipeline ,UGGs Clearance,in other process from the pipeline to remove data before ,writing process will have been blocked .
Traditionally there are many piping method ,such as the use of the file system ,the use of socket ( sockets ) ,using flow .In Linux, using a two file data structure to achieve the pipeline .
The two file data structure of f_inode ( f_dentry ) to create a temporary pointers point to the same node VFSI ,and the VFSI node itself and to the memory to a physical page ,as shown in figure 5.
1 .A two file data structure in f_op pointer to point to a different file routines vector table :one for the lines to write ,another for read from pipe .This method covers the underlying implementation differences ,from the process point of view ,read and write pipeline system calls and read / write ordinary file system calls are no different from ordinary .
When the write process in the pipeline to write, byte is copied to the shared data page ,when the read process from the pipeline read, byte is from the shared page copy .Linux must be synchronized for pipeline access ,must ensure that the write and read keep step with pipeline .
Linux use lock ,UGG Boots Clearance,the waiting queue and signal ( locks ,waitqueues and signals ) to achieve synchronization .Fig 5.1 schematic diagram of pipeline . See Synonyms at include / Linux / inode_fs.
h when the writing process to the pipeline at the time of writing ,it uses the standard write library function .The library function ( read ,write ) requires passing a file descriptor as a parameter .
The file descriptor is the file corresponding to the file data structure in the process of file data structure index in the array ,each representing an open file, in this case ,open pipeline .
Linux system call is used to describe the pipeline file data structure in f_op by means of write routines ,the write routine use represents a pipeline VFSI nodes stored information ,Nike Factory,to manage the write request .
If the shared data page has enough space to put all the bytes are written in the pipeline ,and the pipeline were not read process lock ,Linux is in the pipeline for the write lock ,and the bytes from the address space of the process are copied to the shared data page .
If the pipeline read process lock or shared data page there is not enough space in the current process ,is forced to sleep ,it hangs in the pipeline I node waiting waiting in the queue ,and then call the dispatcher ,so another process to run .
Sleep write process can be interrupted ( interruptible ) ,so it can receive signals .When the pipe has enough space to write data ,or when the lock is released, the write process will read process wake .
When the data is finished, the VFSI pipeline node on the lock release ,in pipeline I node wait queue to wait for all the read process will be awakened .See FS / pipe.cpipe_write ( ) read from pipe data and write the data are very similar .
Linux allows a process to read files without blocking or pipe ( dependent on their open files or pipe mode ) ,then ,if no data readable or pipe is locked ,the system call will return an error .
This implies a process may continue to run .Another way is to block read ,i.e. process in pipeline I node waiting waiting in the queue ,until the write process is complete .If all the processes have completed their pipeline operation ,the pipe I nodes and the corresponding shared data page will be abandoned .
See FS / pipe.cpipe_read ) ( Linux also support the named pipe (also called FIFO ,because the pipeline work the first-in-first-out principle, first write pipeline data was also the first to be read out data ) .
And pipes of different ,FIFO is not a temporary object file system ,they are real ,Coach Bags,you can use the mkfifo command to create .As long as the appropriate access permissions ,you can use FIFO process .
FIFO open the way and pipe slightly different .A pipeline ( two of its file data structures ,VFSI nodes and shared data page) is a one-time created ,while FIFO already exists ,it can be opened and closed by the user .
Linux must deal with in the writing process to open the FIFO prior to the read process for its open ,also must deal with in the writing process and write data read process on the pipeline before read .
In addition ,FIFO almost and conduit treated with exactly the same ,and they use the same data structure and operation .From the perspective of IPC ,pipe is provided from a process to another process data transmission method .
Related articles:

没有评论:

发表评论