Saturday, October 24, 2009

What defines a Process in Linux?

The kernel stores the processes in a circular doubly linked list called the task list. Each element in the task list is a process descriptor of the type struct task_struct, which is defined in include/linux/sched.h. The process descriptor contains all the information about a specific process. A task_struct exactly defines a Linux process

The important information of processes contained in task_struct is:

  • Volatile long state - contains whether this task is runnable, and if not whether it is interruptible (may receive signals) or not.
  • Long counter - represents the dynamic portion of the task's goodness. Whenever it is reset, it is set to priority. At certain points in the task's execution (most commonly when the 10 msec timer goes off while the task is running) the counter is decremented. If the counter ever reaches 0 while the task is executing, need_resched is set.
  • Long priority - represents the static portion of the task's goodness.
  • Long need_resched - is examined before returning to the current task after a system call and each time the 10 msec timer interrupts. If need_resched is set, schedule () is called.
  • Unsigned long policy - states whether the current task is being scheduled under soft realtime first in first out (SCHED_FIFO), soft real time round robin (SCHED_RR ), or the normal Linux priority scheduling policy (SCHED_OTHER).
  • Unsigned rt_priority - is used to determine a soft real time task's goodness.
  • Struct mm_struct *mm - points to the memory management information for the task. Some tasks share a single mm_struct.


Apart from these, task_struct also contains a pointer to the task_struct of its parent and child processes, process credentials, resource limits, file system info, list of open files information and VM state of the process.

No comments:

Post a Comment