Find the answer to your Linux question:
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 ...
  1. #1
    Just 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?

  2. #2
    Linux Enthusiast Bemk's Avatar
    Join Date
    Sep 2008
    Location
    Oosterhout-NB, Netherlands
    Posts
    522
    1. If I do not run any command, is any IDLE thread running?
    When 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.
    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 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.

    When the application is finished, the thread shuts down and the shell pops back into the foreground.
    3. What happens if I run another application from background?
    The application will run as normal, but will have no screen to do its output, or a keyboard/mouse to get its input.

    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.

  3. #3
    Just 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?

  4. #4
    Just 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.

  5. #5
    Linux Enthusiast Bemk's Avatar
    Join Date
    Sep 2008
    Location
    Oosterhout-NB, Netherlands
    Posts
    522
    Thanks for the excellent reply on Shell.
    You're welcome.

    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?
    The shell is a process of its own. If I am right, fork() is a LibC module which communicates with the kernel process manager.

    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.

    For every application (again assume no thread creation / fork within application) executed from command line, does shell create processes always?
    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.

    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.
    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.

  6. #6
    Linux Enthusiast Bemk's Avatar
    Join Date
    Sep 2008
    Location
    Oosterhout-NB, Netherlands
    Posts
    522
    Quote Originally Posted by blackfin_dsp_uclinux View Post
    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?
    what do you mean by polling?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...