16 April 2011

linux : process management

1) Explain each system calls used for process management in linux.
Answer :
System calls used for Process management:

Fork () :- Used to create a new process

Exec() :- Execute a new program

Wait():- wait until the process finishes execution

Exit():- Exit from the process

Getpid():- get the unique process id of the process

Getppid():- get the parent process unique id

Nice():- to bias the existing property of process

2) Which commands are used to set a processor-intensive job to use less CPU time?
Answer :
nice command is used for changing priority of the jobs.
Syntax: nice [OPTION] [COMMAND [ARG]...]
Range of priority goes from -20 (highest priority) to 19 (lowest).Priority is given to a job so that the most important job is executed first by the kernel and then the other least important jobs. This takes less CPU times as the jobs are scheduled and are given priorities so the CPU executes fast. The priority is given by numbers like -20 describe the highest priority and 19 describe the least priority.
3) Explain Linux Process management

Answer : process control and the ability for inter process communication is handled by the Linux kernel. Within the Linux kernel, a process is represented by a rather large structure called task_struct. This structure contains all of the necessary data to represent the process, along with a plethora of other data for accounting and to maintain relationships with other processes (parents and children) . All processes in Linux are collected in two different ways. The first is a hash table, which is hashed by the PID value; the second is a circular doubly linked list. The circular list is ideal for iterating through the task list. As the list is circular, there's no head or tail; but as the init_task always exists.









4) Explain Some Tools for working with processes:

Answer:

a) accton - Turns process accounting on and off. Uses the file /var/log/pacct. To turn it on type "accton /var/log/pacct". Use the command with no arguments to turn it off.

b) kill - Kill a process by number

c) lastcomm (1) - Display information about previous commands in reverse order. Works only if process accounting is on.

d) skill - Report process status.

d) snice - Report process status.





Reference:

http://www.comptechdoc.org/os/linux/howlinuxworks/linux_hlprocess.html

http://www.ibm.com/developerworks/linux/library/l-linux-process-management/index.html

5)  Various Command to Manage Process.Answer: All software runs within an operating system known as a process(binaries in the running state). All process that are running with in the Linux  operating system have a process ID(PID) related to it. We can manage the process with the PID value.you can only kill process which are created by yourself. A Administrator can almost kill 95-98% process. But some process can not be killed, such as VDU Process. Each process have a priority value associated with it. these value ranges from -20 to 19.. The lower the number the more priority that task gets.

Commands For managing process1.ps -> To see currently running processEg. $ ps2.kill -> To stop any process by PID i.e. to kill processEg. kill PID

3. killall -> To stop processes by nameEg. killall httpd4. ps -aux -> To display the owner of the processes along with the processes5.kill 0 -> To stop all process except your shell

Eg. $ kill 06. pstree -> To display a tree of processesEg. $ pstree7. top -> To see currently running processes and other information like memory and CPU usage with real time updates

Eg. $ top 8. pidof -> get the process id value of a running a processEg. pidof gedit9. renice - Can be used to change the process priority of a currently running processReference

http://www.nixtutor.com/linux/changing-priority-on-linux-processes http://www.comptechdoc.org/os/linux/usersguide/linux_ugprocesses.html

http://linux.about.com/cs/linux101/g/process__process.html

Click here for more questions...

No comments:

Post a Comment