TheLinuxKernel:Process,Interrupts
Communication,Synchronization
ProcessDescriptors
n The kernel maintains info about each process in a
process descriptor, of type task_struct.
n See include/linux/sched.h
n Each process descriptor contains info such as run
-state of process, address space, list of open files,
process priority etc…
structtask_struct{
volatilelongstate;/*-1unrunnable,0runnable,>0stopped*/
unsignedlongflags;/*perprocessflags*/
mm_segment_taddr_limit;/*threadaddressspace:
0-0xBFFFFFFFforuser- thead
0-0xFFFFFFFFforkernel-thread*/
structexec_domain*exec_domain;
longneed_resched;
longcounter;
longpriority;
/*SMPandrunqueuestate*/
structtask_struct*next_task,*prev_task;
structtask_struct*next_run,*prev_run;
...
/*taskstate*/
/*limits*/
/*filesysteminfo*/
/*ipcstuff*/
/*tssforthistask*/
/*filesysteminformation*/
/*openfileinformation*/
/*memorymanagementinfo*/
/*signalhandlers*/
...
};
Contentsofprocess
descriptor
ProcessState
n Consists of an array of mutually exclusive flags*
n *at least true for 2.2.x kernels.
n *implies exactly one state flag is set at any time.
n state values:
n TASK_RUNNING (executing on CPU or runnable).
n TASK_INTERRUPTIBLE (waiting on a condition: interrupts,
signals and releasing resources may “wake” process).
n TASK_UNINTERRUPTIBLE (Sleeping process cannot be
woken by a signal).
n TASK_STOPPED (stopped process e.g., by a debugger).
n TASK_ZOMBIE (terminated before waiting for parent).
ProcessIdentification
n Each process, or independently scheduled execution context,
has its own process descriptor.
n Process descriptor addresses are used to identify processes.
n Process ids (or PIDs) are 32-bit numbers, also used to
identify processes.
n For compatibility with traditional UNIX systems, LINUX uses
PIDs in range 0..32767.
n Kernel maintains a task array of size NR_TASKS, with pointers
to process descriptors. (Removed in 2.4.x to increase limit on
number of processes in system).