EmbLogic's Blog

Multitasking and Process Management

Any application that runs on a Linux system is assigned a process ID or PID. This is a numerical representation of the instance of the application on the system. It is used by the system administrator who may have to debug or terminate processes by referencing the PID. Process Management is the series of tasks a System Administrator completes to monitor, manage, and maintain instances of running applications. Multitasking Process Management beings with an understanding concept of Multitasking. Linux is what is referred to as a preemptive multitasking operating system. Preemptive multitasking systems rely on a scheduler. The function of the scheduler is to control the process that is currently using the CPU. so there is parent process and child process. The process which creates another process is called parent process and latter is called child process. And each process has its own PID i.e. process identity number to distinguish the child from the parent. To get these process IDs, we use following functions a) getpid() // to get the current process id b) getppid() // to get the creator/ parent process id There are three methods of creating a process: a) Create a process with the use of loader from file system. b) Create a process from the code segment of the current program using system call c) Duplication of the program To create a process using this method (Duplicate) is done by using “fork()” fork function is a special function use to create a child process from a parent process. Using fork(), child process shares the code segment of its parent but both processes have different physical address. After completion of the child process, child process returns its control to parent and the parent process returns its control to the shell. child PID= parent PID + 1 PPID of child = PID of parent fork() function returns three values a) 0 (zero) : if the process is executed by child b) +ve value : means child is created and +ve value is child’s PID c) -ve value : ERROR…! i.e. child process is not created and we can use these values to know which process is executing.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>