0% found this document useful (0 votes)
9 views

Operating System Lecture 4

The document discusses operating system processes including process scheduling concepts, process creation and termination using system calls like fork, exec, wait and exit. It covers long term, short term and medium term schedulers and their responsibilities in managing processes in the ready queue.

Uploaded by

janishab1704
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Operating System Lecture 4

The document discusses operating system processes including process scheduling concepts, process creation and termination using system calls like fork, exec, wait and exit. It covers long term, short term and medium term schedulers and their responsibilities in managing processes in the ready queue.

Uploaded by

janishab1704
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 18

Operating Systems

Lecture 5
Agenda for Today
 Review of previous lecture
 Process scheduling concepts
 Process creation and termination
 fork, exec, wait, exit

May 15, 2024


Review of Lecture 4
 Process conceptstates
 types (CPU- and I/O-bound)
 PCB
 OS queues
 CPU scheduling

May 15, 2024


Schedulers
 Long term scheduler
 Short term scheduler
 Medium term scheduler

May 15, 2024


Queues in a Computer
System

May 15, 2024


Long Term Scheduler
 Long-term scheduler (or job scheduler) – selects
processes from the job pool to be brought into the
ready queue.
 Long-term scheduler is invoked very infrequently
(seconds, minutes)  (may be slow).
 The long-term scheduler controls the degree of
multiprogramming.
 More processes, smaller percentage of time each
process is executed

May 15, 2024


Short Term Scheduler
 Short-term scheduler (or CPU scheduler) – selects
which process should be executed next and
allocates it the CPU through the dispatcher.
 Short-term scheduler is invoked very frequently
(milliseconds)  (must be fast).
 Invoked when following events occur
 CPU slice of the current process finishes
 Current process needs to wait for an event
 Clock interrupt
 I/O interrupt
 System call

May 15, 2024


Medium Term
Scheduler
 Also known as swapper
 Selects an in-memory process and swaps it out
to the disk temporarily
 Swapped out process , Swap Space
 Swapping decision is based on several factors
 Arrival of a higher priority process but no memory
available
 Poor mix of jobs
May 15, 2024
 Memory request of a process cannot be met
Addition of Medium
Term Scheduling

May 15, 2024


• Context means current information about that particular
process
• When CPU switches to another process, the system must
save the state (context) of the ‘current’ (old) process and
load the saved state for the new process.
• When the process resume it execution it needs to know
where did it stop executing at that particular moment
Process Creation
Process Management in
UNIX/Linux
Important process-related UNIX/Linux
system calls
 Fork (creates new process)

 wait
 Exec(replaces memory address of a process with new program)

 exit

May 15, 2024


FORK()
• Is a sytem call which is used to create child
• Child and parent have different ID
• If parent is busy than child will do the work Both execute parallely
When kernel busy

Number of fork
Both execute parllely
Child

Fork return two value 0 and 1


Total child
Processes Tree on a
UNIX System

May 15, 2024


Process Termination
 Process executes the last statement and
requests the operating system to terminate
it (exit).
 Output data from child to parent (via wait).
 Process resources are deallocated by the
operating system, to be recycled later.

May 15, 2024


Process Termination …
 Parent may terminate execution of
children processes (abort).
 Child has exceeded allocated resources
(main memory, execution time, etc.).
 Parent needs to create another child but has
reached its maximum children limit
 Task performed by the child is no longer
required.
 Parent exits.
 Operating system does not allow child to continue
if its parent terminates.
 Cascaded termination
May 15, 2024

You might also like