Results 1 to 6 of 6
How does Shell invoke a process, when an application is executed?
I am newbie, so what I want to visualize is:-
1. If I do not run any command, is ...
- 05-19-2009 #1Just Joined!
- Join Date
- May 2009
- Posts
- 11
How does Shell invoke a process, when an application is executed?
How does Shell invoke a process, when an application is executed?
I am newbie, so what I want to visualize is:-
1. If I do not run any command, is any IDLE thread running?
2. Next, when I run an application, what exactly is happening? Assume that I do not touch threads or process from within the application.
3. What happens if I run another application from background?
- 05-20-2009 #2When you don't run any command, the shell is polling for input all the time. The CPU never does nothing. When there are no instructions for the CPU available the kernel will run dummy instructions, to keep the computer from shutting down.1. If I do not run any command, is any IDLE thread running?
When you start an application through the shell, you will fork the shell thread, and one of the threads will be pushed to the background, and the other will load the application, you asked for. What happens next depends on the application.2. Next, when I run an application, what exactly is happening? Assume that I do not touch threads or process from within the application.
When the application is finished, the thread shuts down and the shell pops back into the foreground.
The application will run as normal, but will have no screen to do its output, or a keyboard/mouse to get its input.3. What happens if I run another application from background?
Server applications generally run in the background, and most of the time those will do their outputs to a log file. That way the administrator generally knows what's going on and can adjust the computers course if necessary, by adjusting configuration files, and restarting the server application.
- 05-22-2009 #3Just Joined!
- Join Date
- May 2009
- Posts
- 11
Hi Bemk
Everywhere I see the polling mechanism.......
1. User has to poll for event occurrence in driver.
2. Shell polls the command line...
Just trying to understand, is polling a great idea (I am coming from non-Unix background)? Or AM I missing something to visualize?
- 05-22-2009 #4Just Joined!
- Join Date
- May 2009
- Posts
- 11
Hi Bemk
Thanks for the excellent reply on Shell.
Is shell treated as another process? When you say fork the shell, where is the fork() exactly executed? I am also a little confused, are we talking of only process or threads also, when shell executes an application?
For every application (again assume no thread creation / fork within application) executed from command line, does shell create processes always?
So it is always better to have 2 threads (for my audio and video as example), rather than run one in background. because with former, process switching is done and with latter, thread switching (less latency for system) is done.
- 05-22-2009 #5You're welcome.Thanks for the excellent reply on Shell.
The shell is a process of its own. If I am right, fork() is a LibC module which communicates with the kernel process manager.Is shell treated as another process? When you say fork the shell, where is the fork() exactly executed? I am also a little confused, are we talking of only process or threads also, when shell executes an application?
Fork copies the process to another process ID, and lets the one with the new ID load in the binary code for the command being executed. The one with the old ID just goes on as if nothing has happened.
Most of the time. I don't think the shell will create new processes for commands like CD(that would mean too much work), but for example echo is already a new thread, just like ls.
For every application (again assume no thread creation / fork within application) executed from command line, does shell create processes always?
I don't know. I thought that if you were running a video, for example in MPlayer, you would use both the libraries for sound, as for video, within the same process.So it is always better to have 2 threads (for my audio and video as example), rather than run one in background. because with former, process switching is done and with latter, thread switching (less latency for system) is done.
- 05-22-2009 #6


Reply With Quote
