Process Management
Linux kernel provide set_task_state(task,state) by which you can manipulate the state of given task. By using of set_task_state you can change to state of given task.
Kernel perform some background operation by using of some thread that is called kernel thread.kernel thread are the special thread which doesnt have the process address space .They just run in the kernel space . We can reschedule kernel thread like a normal process .Kernel delegates several task to kernel thread like flush etc.
In Linux there is no special provision for thread . In Linux thread is a process which actual share some resources with other process . Every thread has a unique task_struct.creating thread also created by using the clone sys call except some flags for sharing the data like file system , signal handler,open files also set. Flags are used to specify that which resources are shared between parent and child process or thread.E.g clone(CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND, 0);
In linux a process can be in one of the following state.
1) TASK_RUNNING :- This state specify that process is either running or in ready state and waiting in runqueue .
2) TASK_INTRUPTTIBLE:- This condition states that the task is in sleeping state and waiting for some event to occur. When this condition occurs task comes in TASK_RUNNING state.
3) TASK_UNINTRRUPTIBLE:- This state is similar as previous state but in this state process does not wait for any event to occur.
4)_TASK_TRACED:- The process is getting traced by another process , such as a debugger.
Linux does not differentiate between process and thread. Linux kernel understand a thread as a process and implements process and thread in same way.In Linux thread is a process which actually share some resources with other process .
Threads can share lots of things . Some of the most shared resources are file system information , open files , signal handlers , Address space etc.
In Linux kernel a process is represented by Process descriptor which is a structure of type task_struct . Kernel stores all the process by maintaining a doubly linked list in which each node is type of task_struct. In other words we can say kernel maintained a doubly linked list of process descriptors.
The task_struct is a large data structure around 1.7 Kb on a 32 bit machine. This structure maintain all the information about a process. This structure contains info like signals, files ,stack ,state and much more as we can see below picture.
Read about thread_info structure from linux kernel tutorials.
The task_struct is a large data structure around 1.7 Kb on a 32 bit machine and kernel stack is either 4KB or 8KB . Hence the task of storing structure of 1.7 kb is very much difficult . So kernel introduced concept of thread_info ,which is very much slimmer than task_thread and just points to task_struct structure.
The vfork() system calls has the same effect as fork() except that the page table entries of the parent process are not copied . Instead the child executes as a sole in the parents address space, and the parent is blocked until the child either call exec() or exits.
Normally process runs in user space but when a program calls a syscall or triggers an exception then it enter into the kernel-space at that time kernel is said to be executed on behalf of process and in other word kernel is in process context.
Process which is dead and completed its execution but still it had an entry in process table is called zombie process.
If a parents exist before its children then child process are re-parented to another process in same thread group or , if that fails , then init process.
Process Scheduling
Process of selecting which process to give chance to run is called Process scheduling. It is responsibility of processor to decide which process to run, when and for how long. For multiprogramming system scheduler is base . Scheduler has to decide which process to run and which process has to wait. Scheduler has to allot the time to each process efficiently and make the efficient use of Processor so that user can feel that all the processes is executing at the same time.
Co-operative multitasking:- In this method process does not stop running until it voluntarily stops. The act of process voluntarily stopping itself called yielding.
Preemptive multitasking:- In this kind of multitasking scheduler decides which process to start running and which process to stop. Good thing in this multitasking is that scheduler can take the global decision. All the linux kind OS comes in preemptive scheduling flavor.
The act of process voluntarily stopping itself called yielding.
• Scheduler cannot take globalize?? decision.
• Any process can monopolize the system.
I/O bound processes spend most of the time waiting for some input/output event to occur and take very less time of processor.Processor bound process takes most of the time executing the code . These kind of process runs continuously without waiting for any input/output event and stopped while printed by compiler.
Process priority is a way of specifying the process importance in the system.
Linux implements two types of process priority value.
1) Nice value:-A number from -20 to +19 with a default value of 0. Large nice value corresponds to less priority.
2) Real Time Priority:-A value from 0 to 99. Higher the real time value means higher priority.
Read answer of previous question.
The Vruntime variable stores the virtual runtime of a process ehich is the actual runtime ( the amount of time spent running) normalized by the number of runnable processor. CFS uses Vruntime to account for how long a process has run and thus how longer it ought to run.
• Completely Fair Schedule class
• RT schedule class
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
Syscalls
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
Interrupt Handling
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
Kernel Synchronization
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
Memory Management
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
Virtual File System
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
Process Address Space
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
Device Driver Questions
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/
http://www.tutorialsdaddy.com/courses/linux-kernel-drivers-interview-questions-and-answers/