Shell Introduction
The shell is the user interface of the system and provides an interface for users to interoperate with the kernel. It receives the command entered by the user and feeds it into the kernel to execute.
Running background
A basic Linux system architecture
B. As can be seen, the shell is at the middle level in the system. He provides a way for users and kernel to interact with the program.
C. A number of advantages with regard to hierarchies:
1, the developer can only focus on the entire structure of one of the layers;
2, can easily use the new implementation to replace the original level of implementation;
3. Can reduce the dependence between layer and layer;
4, in favor of standardization;
5, facilitate the reuse of the logic of each layer.
Disadvantages:
1, reduce the performance of the system.
2. Sometimes cascade changes are caused
Shell command Execution principle
Surface understanding of our general practice is: Open the terminal, enter the command, hit enter, wait for the command to run , to get results
So, the process of detailed analysis, and what is included?
Open terminal, enter command, hit enter----IO interrupt
Wait process:
Shell parsing commands and parameters----shell (an explanatory program for an end location)
Fork copy near PCB related resources, prepare for command execution----system call
EXEC executes commands in the sub-process that the fork gets
Execution complete, return result----stack protection, stack frame Note: When executing commands such as LS &
The & symbol indicates that the command executes in the background, and when the command is executed, we cannot just enter the command, because the parent process executes the wait-wait child process while the fork executes the shell command, unless the user actively CTRL + C aborts the command execution or CTRL + Z is placed in the background execution.
Reference http://my.oschina.net/u/866271/blog/232840
Linux Shell Execution principle