Welcome to the VirtuQ Forums.
Results 1 to 5 of 5
  1. #1
    Member
    Join Date
    Oct 2011
    Location
    Allahabad, India
    Posts
    245

    Working of fg and bg command

    Hi,

    Firstly, Shell is an interface to Kernel for entering and running the commands, as per the slide in "3-1 Unix Shell interface". So how when a process is running in background does it lose control of the Shell control, which is helping in running it? This is as per the slides in "3-2 Unix Shell Interface (contd)-1".

    Regards
    Anon10020
    Last edited by anup; 13-10-2011 at 06:41 AM.

  2. #2
    VirtuQ™ Moderator
    Join Date
    Jul 2011
    Location
    Bangalore, India
    Posts
    1,044
    Blog Entries
    2
    Edited the post to fix some simple typos.

    Anon10020,

    This is a good question. The point here is that shell is only helping it in running and not actually running it. Recall the slide on multi-user and multi-tasking operating systems. If you were running this on DOS, then of course once you left control of the shell, the process would not have been able to do anything as the core operating system has no notion of a process. This is not the case for multi-tasking operating systems. The shell helps invoke the process and post that it is the kernel which is actually scheduling and running the process. The process might need to interact with the shell (loosely speaking) when it tries to do input/output but other than that it is on its own interacting with the kernel.

    Cheers,

    Anup

  3. #3
    Member
    Join Date
    Oct 2011
    Location
    Allahabad, India
    Posts
    245
    Hi,

    Thanks For the Reply.
    How TSR (in DOS) work in UNIX?

    Regards
    Anon10020
    Last edited by anon10020; 13-10-2011 at 05:18 PM.

  4. #4
    VirtuQ™ Moderator
    Join Date
    Jul 2011
    Location
    Bangalore, India
    Posts
    1,044
    Blog Entries
    2
    Anon10020,

    Every program in UNIX behaves like a TSR if it is running as it will get scheduled at its appropriate time. In DOS this process scheduling was missing (actually there was no notion of a process at all) and hence you needed something like TSRs. The way they worked were:
    1. Start program to load TSR.
    2. Program loads at a free location.
    3. Program hooks on to the timer interrupt handler as this interrupt is generated at regular intervals.
    4. Loader exits.
    5. Now whenever the timer interrupt handler gets called, the TSR will be called, so it has found a way to be executed repeatedly. Do note that if the TSR ever got stuck, the whole computer will *freeze*, as there is no one to come and kill this stuck TSR.


    In UNIX, every program gets scheduled at regular intervals as it is a separate process. If a program ever gets stuck, you can simply go ahead and kill it. In case the program starts consuming too much resources e.g. memory, then the kernel can decide to kill it too.

    Cheers,

    Anup

  5. #5
    Member
    Join Date
    Oct 2011
    Location
    Allahabad, India
    Posts
    245
    Hi,

    Thanks for the reply

    Regards
    Anon10020


 

Posting Permissions

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