Content-Length: 3094161 | pFad | https://www.scribd.com/presentation/708416949/Process-Concept-2
4Process Concept 2
Process Concept 2
Process Concept 2
• CPU scheduling : scheduling criteria, preemptive & non-preemptive scheduling, scheduling algorithms
(FCFS, SJF, RR, priority), algorithm evaluation, multi-processor scheduling.
• Process Synchronization : background, critical section problem, critical region, synchronization hardware,
classical problems of synchronization, semaphores.
• Deadlocks : system model, deadlock characterization, methods for handling deadlocks, deadlock
prevention, deadlock avoidance, deadlock detection, recovery from deadlock.
Process concept
Memory
• Process is a dynamic entity
– Program in execution Disk
User
• Program code program
– Contains the text section
• Program becomes a process when
– executable file is loaded in the memory
– Allocation of various resources
• Processor, register, memory, file, devices
• One program code may create several processes
– One user opened several MS Word
– Equivalent code/text section
– Other resources may vary
Process State
Single
processor
Multitasking/Time sharing
As a process executes, it changes state
– new: The process is being created
– running: Instructions are being executed
– waiting: The process is waiting for some event to
occur
– ready: The process is waiting to be assigned to a
processor
– terminated: The process has finished execution
How to represent a process?
• Process is a dynamic entity
– Program in execution
• Program code
– Contains the text section
• Program counter (PC)
• Values of different registers
– Stack pointer (SP) (maintains process stack)
• Return address, Function parameters
C Z O S I K
– Program status word (PSW)
– General purpose registers
• Main Memory allocation
– Data section
• Variables
– Heap
• Dynamic allocation of memory during process execution
Process Control Block (PCB)
• Process is represented in the operating system
by a Process Control Block
Information associated with each process
• Process state
• Program counter
• CPU registers
– Accumulator, Index reg., stack pointer, general
Purpose reg., Program Status Word (PSW)
• CPU scheduling information
– Priority info, pointer to scheduling queue
• Memory-management information
– Memory information of a process
– Base register, Limit register, page table, segment table
• Accounting information
– CPU usage time, Process ID, Time slice
• I/O status information
– List of open files=> file descriptors
– Allocated devices
Process Representation in Linux
Represented by the C structure task_struct
pid t pid; /* process identifier */
long state; /* state of the process */
unsigned int time slice /* scheduling information */
struct task struct *parent; /* this process’s parent */
struct list head children; /* this process’s children */
struct files struct *files; /* list of open files */
struct mm_struct *mm; /* address space of this pro */
Doubly
linked list
CPU Switch From Process to Process
Context switch
Context Switch
Job queue
Ready queue
Device queue
Ready Queue And Various
I/O Device Queues
Device queue
Many processes
are waiting for
disk
Process Scheduling
• We have various queues
• Single processor system
– Only one CPU=> only one running process
• Selection of one process from a group of
processes
– Process scheduling
Process Scheduling
• Scheduler
– Selects a process from a set of processes
• Two kinds of schedulers
1. Long term schedulers, job scheduler
– A large number of processes are submitted (more than
memory capacity)
– Stored in disk
– Long term scheduler selects process from job pool and loads
in memory
2. Short term scheduler, CPU scheduler
– Selects one process among the processes in the memory
(ready queue)
– Allocates to CPU
Long Term Scheduler
CPU scheduler
Representation of Process Scheduling
CPU scheduler selects
a process Dispatched (task of
Dispatcher)
Parent at
wait()
Dispatcher
• Dispatcher module gives control of the CPU to
the process selected by the short-term scheduler;
this involves:
– switching context
– switching to user mode
– jumping to the proper location in the user program to
restart that program
Create
initial Child Shell
PCB
Exce()
Update PCB
Context switch
Swapper
ISR for context switch
Current <- PCB of current process
Context_switch()
{
switch to kernel mode
Disable interrupt;
Save_PCB(current);
Insert(ready_queue, current);
next=CPU_Scheduler(ready_queue);
remove(ready_queue, next);
Enable Interrupt;
Dispatcher(next);
}
Dispatcher(next)
{
Load_PCB(next); [update PC]
switch to user mode;
Fetched URL: https://www.scribd.com/presentation/708416949/Process-Concept-2
Alternative Proxies: