Process And Process States
Process:
Process is a program which is in execution. A process is the unit of work in a modern time sharing
system.
A system therefore consists of a collection of processes operating system processes executing
system code and user processes executing user code.
A program becomes a process when an executable file is loaded in to memory.
Two common techniques for loading executable files are double clicking an icon
representing the executable file and entering the name of the executable file on
the command line .
A process includes :
>program counter and other registers.
>Stack
>work and data space, along with other resource, files etc.
>PCB(process control block )or process descriptor
PCB
>PCB: PCB,to holds information of state of a process,
Proces Control Block Each process is represented in the operating system by a process control
block ( PCB ) also called a task control block
PCB of all processes are maintained in some doubly linked queue.
Process States:
As a process executes , it changes state.
The state of a process is defined in part by the current activity of that process. A process may be in
one of the following states:
• New. The process is being created.
• Running. Instructions are being executed (Process is holding CPU).
• Waiting. The process is waiting for some event to occur or complete (such as an I/O completion or
reception of a signal).
• Ready. The process is waiting to be assigned to a processor.
• Terminated. The process has finished execution.
Process States Diagram
Process state. The state may be new, ready, running, waiting, and so on.
PCB(process control block) OR PD(process descriptor)
contains information associated with each process
•Program counter:
The counter indicates the address of the next instruction to be executed for this process.
• CPU registers. The registers vary in number and type , depending on the computer architecture. They include accumulators , index registers , stack pointers , and general purpose registers , plus any condition code information . Along with the program counter, this state information must be saved when an interrupt occurs , to allow the process to be continued correctly .
• CPU scheduling information.This information includes a process priority , pointers to scheduling queues, and any other scheduling parameters.
• Memory management information. This information may include such items as the value of the base and limit register and the page tables , or the segment tables, depending on the memory system used by the operating system .
(Process Control Block)PCB
• Accounting information. This information includes the amount of CPU and real time used, time limits , account numbers, job or process numbers , and so on.
• I/O status information. This information includes the list of I/O devices allocated to the process , a list of open files , and so on.
What is Thread?
Thread:
Thread is the smallest unit of processing that can be performed in an Operating System(OS).Thread is the light weight process . Thread exists within a process , a process may contain multiple threads.
Multi-threading:
When multiple threads are running concurrently , this is known as multi-threading.
For Example:
Downloading a video song while playing video song at the same time. Multi-threading is also used in computer generated animation.
Widely used programming languages that allow developers to work on threads in their programs source code are Java , Python and .NET.
Differ between thread and process:
Thread and Process are two closely related terms in multi-threading.
The main difference between these terms is that thread is a part of a process,
A process may contain one or more threads , but a thread cannot contain a process.
Thread is a light weight processes:Threads can generate other threads.
Process exists independent on the other hand threads are subset of process.
Context switching between threads in the same process is faster than context switching between processes.
Threads share their address spaces while process have separate address spaces
Treads are used for the small tasks, where as processes are used for the heavy weight tasks.
9 Comments
Great! thank you for sharing this
ReplyDeletethanks
DeleteMost of this goes right over my head. But you have a great way of simplifying it. Thanks for sharing!
ReplyDeletedear if u know about computer then u can understand it easily because its about operating system
DeleteI truly say that this goes over my head but I must say you have a bright blogging future ahead.
ReplyDeletedear if u know about operating system then u can understan
DeleteI wish I was more techie so I could really understand this :)
ReplyDeletevery well written article good post
ReplyDeleteGreat post thanks for sharing your knowledge
ReplyDelete