OS - Chapter 2
OS - Chapter 2
CHAPTER-2
Processes, Thread & Process Scheduling
Syllabus
Process
• The Text section is madeup of the compiled program code , read in from
non-volatile storage when the program is launched.
• The Data section is made up the global and static variables, allocated and
initialized prior to executing the main.
• The Heap Section is used for the dynamic memory allocation, and is
managed via calls to new, delete, malloc, free, etc.
• The Stack is used for local variables. Space on the stack is reserved for
local variables when they are declared.
Process Vs. Program
Process State
• As a process executes, it changes state.
Start
This is the initial state when a process is first started/created.
Ready
The process is waiting to be assigned to a processor. Ready
processes are waiting to have the processor allocated to them by
the operating system so that they can run.
Process may come into this state after Start state or while running
it by but interrupted by the scheduler to assign CPU to some other
process.
Contd…
Running
Once the process has been assigned to a processor by the OS
scheduler, the process state is set to running and the processor
executes its instructions.
Waiting
Process moves into the waiting state if it needs to wait for a
resource, such as waiting for user input, or waiting for a file to
become available.
For example the process may be waiting for keyboard input, disk
access request, inter-process messages, a timer to go off, or a child
process to finish.
Contd..
Terminated or Exit
Once the process finishes its execution, or it is terminated by the
operating system, it is moved to the terminated state where it waits
to be removed from main memory.
Process State Transitions
Process State[ 1 ]
Process Transitions
1 Process State : The current state of the process i.e., whether it is ready,
running, waiting, or whatever.
2 Process privileges : This is required to allow/disallow access to system
resources.
3 Process ID : Unique identification for each of the process in the operating
system.
4 Pointer : A pointer to parent process.
Table : 2.1 Process States Attributes
Contd…
• As each thread has its own independent resource for process execution,
multiple processes can be executed parallel by increasing number of threads.
• Each thread belongs to exactly one process and no thread can exist outside a
process.
Threads
• Efficient communication.
Disadvantages
• Multithreaded application cannot take advantage
of multiprocessing
Kernel Level Thread
• Multithreading Models
1. Many to One Model
2. One to One Model
3. Many to Many Model
Many to one Model
• In the many to one model, many user-level threads are
all mapped onto a single kernel thread.
• Thread management is handled by the thread library in
user space, which is efficient in.nature