Username: Save?
Password:
Home Forum Links Search Login Register*
    News: Keep The TechnoWorldInc.com Community Clean: Read Guidelines Here.
Recent Updates
[April 24, 2024, 11:48:22 AM]

[April 24, 2024, 11:48:22 AM]

[April 24, 2024, 11:48:22 AM]

[April 24, 2024, 11:48:22 AM]

[April 03, 2024, 06:11:00 PM]

[April 03, 2024, 06:11:00 PM]

[April 03, 2024, 06:11:00 PM]

[April 03, 2024, 06:11:00 PM]

[March 06, 2024, 02:45:27 PM]

[March 06, 2024, 02:45:27 PM]

[March 06, 2024, 02:45:27 PM]

[March 06, 2024, 02:45:27 PM]

[February 14, 2024, 02:00:39 PM]
Subscriptions
Get Latest Tech Updates For Free!
Resources
   Travelikers
   Funistan
   PrettyGalz
   Techlap
   FreeThemes
   Videsta
   Glamistan
   BachatMela
   GlamGalz
   Techzug
   Vidsage
   Funzug
   WorldHostInc
   Funfani
   FilmyMama
   Uploaded.Tech
   MegaPixelShop
   Netens
   Funotic
   FreeJobsInc
   FilesPark
Participate in the fastest growing Technical Encyclopedia! This website is 100% Free. Please register or login using the login box above if you have already registered. You will need to be logged in to reply, make new topics and to access all the areas. Registration is free! Click Here To Register.
+ Techno World Inc - The Best Technical Encyclopedia Online! » Forum » THE TECHNO CLUB [ TECHNOWORLDINC.COM ] » Computer / Technical Issues » Operating Systems » Linux
 Process In UNIX
Pages: [1]   Go Down
  Print  
Author Topic: Process In UNIX  (Read 1107 times)
Taruna
Elite Member
*****



Karma: 13
Offline Offline

Posts: 845

Hi ALL


View Profile
Process In UNIX
« Posted: January 03, 2007, 01:47:46 PM »


In this article I want to explore the basics of a UNIX process and it s relationship with other processes etc. A process is a program in execution. It is created by the Unix to run a program. Each process in UNIX is allocated a time slice. When a process consumes the time slice in execution, it is preempted by the OS so that it can schedule another process.

When the system starts up first process to be run is scheduler. The actual process name can be different depending upon the flavor of the OS. The scheduler brings init process to execution and init takes care of system start up. In UNIX each process is identified with a ID (integer) which is assigned during process creation. For example the scheduler process which I said in the beginning of this paragraph has process ID 0 and init will have process ID 1. The init reads several script files and execute them before the system is started.. These script files are located in /etc under various directories. /etc/inittab file contains the information which is required to bring the system up. It contains the default run level and location of the directories where the script files for each run level is stored. The UNIX OS may switch different run levels during its lifetime. For example if the run level is 3 we can use UNIX machine as multi-user machine. To say as another example when we shut down the system init process changes its run level so that it will execute the script files which are required for house keeping actions, to gracefully kill the running daemons, processes etc. If u have a system with UNIX kernel u can check urself in depth regarding these details.

In UNIX a new process is created by using fork() system call. The process which executes fork is called parent process and the newly created process is child process. If everything goes well the return value of fork is child process s ID in parent process and 0 in child process. As a process can have several children the above strategy of returning value from fork seems logical. From nowonwards the parent and child process can run concurrently and when the child completes its execution it supplies the exit status to the parent so that parent can know about it. To get the exit status of the child the parent has to execute waitpid() or wait(). When a process is completed its execution all the resources are reclaimed from it and its details are removed from the process table. Here comes a interesting scenario of parent and child process. When a child completed its execution and parent not yet executed the wait system call to get the status of the child, the kernel reclaims all resources of the child but it keeps minimal information in the process table which can be used to return the exit status to the parent. This state of the child is called Zombie state. The process is called Zombie process. As soon as the parent executes wait the status returned to the parent and child process details are removed from the process table.. One more scenario is what happens when the parent exited before child completes its execution. The creators of the UNIX are very generous and they don t wanted to leave the child as orphan. init becomes the parent of this orphan process. There is no special reason for choosing init process for this purpose. The only reason is the init process lives as long the UNIX system is up and running.

Here I will explain some practical scenario of process. We execute a command from the shell. What goes in background is interesting. The shell forks a new process and loads the corresponding executable file and runs it. The shell is parent process here and it executes wait system call. wait doesn t return till the child executes exit. For example the command u want to execute is ls. the shell forks a new process and to load the /bin/ls it uses the exec family of system calls. Immediately the parent executes the wait. The child now runs the command as a separate process and as soon as its execution completed it return the exit status to the parent which is parent.

Logged

Pages: [1]   Go Up
  Print  
 
Jump to:  

Copyright © 2006-2023 TechnoWorldInc.com. All Rights Reserved. Privacy Policy | Disclaimer
Page created in 0.153 seconds with 25 queries.