Follow the Australian Telecommunications scene NEWSLETTER- FREE TRIAL
The Linux distillery
Bringing the world of Linux to you, David cuts through the tech and shows you how it works and how to use it, in terms that apply to any distro. RSS
Technology news and Jobs arrow The Linux distillery arrow Processed Linux: from exec to exit
Processed Linux: from exec to exit E-mail
by David M Williams   
Monday, 03 March 2008
Linux is a multitasking operating system, running many tasks – or processes – seemingly at once. Every process leaves a footprint on your system. Here are some tools to examine these, and we also work out just what that creepy /proc directory is all about.
Welcome back. Over the last weeks we looked at how the Linux scheduler prioritised the processes to run, and learned about jiffies and zombies. Now it’s time to cover the life cycle of a Linux process and just what happens when you run a program.

Linux enforces strong family values through parent/child relationships. Every single process except for one has a parent process. The one exception is init which is the granddaddy of everything else. This is process number 1, the big kahuna which fires when Linux first boots. Every other process has been spawned from it, either directly or through its offspring.

Like some types of worms and fish, Linux processes have only one parent. And, like guinea pigs and rabbits, a Linux process can have almost any number of children.

Users of a Linux system create processes when they execute command-line instructions or when they double-click on icons and menu options within the GUI environment. Behind the scenes, the applications invoked come to life because they are spawned by a parent process – whether it be a BASH shell, for instance, or the KDE or Gnome desktop.

And, if a program creates another task then it is making a child process of its own. This happens all the time. It’s what Apache does when a web page request comes in, for example. Apache spawns a new process to take care of the incoming connection so the main body of the program is freed up instantly and can listen for new incoming requests. If it didn’t spawn off a child process, the web server may become unusable by others because its time is taken up serving the first request instead of responding to newcomers.

Behind the scenes, these processes are made through one of but three system calls within the Linux kernel. Two of these have a shared UNIX heritage, fork and vfork, whereas the third one is specific to Linux and is called clone.

fork is the historically preferred way to create new processes. The fork system call splits the process in two, leaving a parent and a child process. The parent is the original process, retaining the process ID it had since it began, and receiving the process ID of the child as a return value from fork. The child process, however, is a duplicate running in a new process space with a new process ID. It receives a value of 0 as the return value from fork. It’s this return value which lets program code determine if it is the parent or child process once the split has taken place and respond in whatever manner is appropriate for that specific application.

Please read on for more cytokinesis!

CONTINUED







 
< Next story in category   Previous story in the category >
iTWire user statistics Visitors last 30 days
694,279
Subscribers 15,210
#1 independent technology news advertise here
  •   *  
  • Search
  • AdvSeach
  • Login
  • Events
  • FreeStuff

- Advertisement -

Featured Whitepapers

Follow iTWire on Twitter

About iTWire

iTWire is all about technology news, information, jobs and community for the IT and telecommunications industry professional. Subscribe to our free ICT daily newsletter