Tuesday, February 9, 2010

My OS Assignment No.1


In a multi tasking computer system, processes may occupy a variety of states. These distinct states may not actually be recognized as such by the operating system kernel however they are a useful abstraction for the understanding of processes.
Following fig describes the life cycle of the process state in typical computer.

Created

(Also called New) When a process is first created, it occupies the "created" or "new" state. In this state, the process awaits admission to the "ready" state


Ready or Running

(Also called waiting or runnable) A "ready" or "waiting" process has been loaded into main memory and is awaiting execution on a CPU (to be context switched onto the CPU by the dispatcher, or short-term scheduler). There may be many "ready" processes at any one point of the systems execution - for example, in a one processor system, only one process can be executing at any one time, and all other "concurrently executing" processes will be waiting for execution.

Blocked

A process that is waiting for some event (such as I/O operation completion or a signal).

Terminated

A process may be terminated, either from the "running" state by completing its execution or by explicitly being killed. In either of these cases, the process moves to the "terminated" state.

Process control block

A Process Control Block (PCB, also called Task Controling Block or Task Struct) is a data structure in the OS kernel containing the information needed to manage a particular process. The PCB is "the manifestation of a process in an operating system"

Process control blocks are found in all modern operating
systems. The structure of pcbs will be different on each operating system
though.

The process table. The pcbs may be put into a number of lists at the same time.
The process table describes the system by which the operating system finds a pcb
by its process id.

Linux PCBs:

/* memory management info */
struct mm_struct *mm;
/* open file information */
struct files_struct *files;
/* tss for this task */
struct thread_struct tss;
int pid;
volatile long state; /* -1 unrunnable, 0
runnable, >0 stopped */
long priority;
unsigned short uid,euid,suid,fsuid;
#ifdef __SMP__
int processor;
#endif
struct task_struct *p_opptr, *p_pptr,
*p_cptr, *p_ysptr, *p_osptr;
/* limits */
struct rlimit rlim[RLIM_NLIMITS];
long utime, stime, cutime, cstime,
start_time;

Windows NT PCBs:
Information is scattered in a variety of objects.
Executive Process Block (EPROCESS)
includes
• KPROCESS and PEB
• pid and ppid (the ppid is not visible to Win32)
• file name of program
• window station (terminal?)
• exit status
• create and exit times
• links to next process
• memory quotas
• memory management info
• Ports for exceptions and debugging
• Security information

NT PCB :
Kernel Process Block (KPROCESS) includes
info the kernel needs to schedule threads
• Kernel and user times.
• Pointers to threads.
• Priority information.
• Process state
• Processor affinity

Process Table:

A data structure within the kernel that stores information about all the current processes.


No comments:

Post a Comment