0% found this document useful (0 votes)
16 views25 pages

4 - Processes

Uploaded by

abdullahzahidhp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views25 pages

4 - Processes

Uploaded by

abdullahzahidhp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

1

CSC351-Operating System
Lecture-4
2
Text Book

 Operating system concepts by Abraham


Silberschatz, Galvin, Gagne, 9th edition

Lahore Garrison University


3

►System Calls
►System programs
Preamble ►OS Layered Approach
(Past lesson ►OS Services
brief)

Lahore Garrison University


4
Chapter 3: Processes

 Process Concept
 Process Scheduling
 Operations on Processes
 Interprocess Communication
 Examples of IPC Systems
 Communication in Client-Server Systems

Lahore Garrison University


5
Learning Outcomes

 To introduce the notion of a process -- a program in


execution, which forms the basis of all computation
 To describe the inter process communication among
various process
 To describe cooperating processes

Lahore Garrison University


6
Process Concept

 An operating system executes a variety of programs:


 Batch system – jobs
 Time-shared systems – user programs or tasks
 Textbook uses the terms job and process almost
interchangeably
 Process – a program in execution; process execution must
progress in sequential fashion

Lahore Garrison University


Process Concept

Process execution must progress in sequential


fashion
 Multiple parts
 The program code, also called text section
 Current activity including program counter, processor registers
 Stack containing temporary data
 Function parameters, return addresses, local variables

 Data section containing global variables


 Heap containing memory dynamically allocated during run time
 CPU state
 PCB
8
Process Concept (Cont.)

 Program is passive entity stored on disk (executable file),


process is active
 Program becomes process when executable file loaded into
memory
 Execution of program started via GUI mouse clicks,
command line entry of its name, etc
 One program can be several processes
 Consider multiple users executing the same program

Lahore Garrison University


9
Process in Memory

Lahore Garrison University


1
0
CPU and I/O bounded
processes

 Processes can be:


 I/O-bound process – spends more time doing I/O than
computations, many short CPU bursts.ms word

I/O Burst CPU Burst I/O Burst CPU Burst

 CPU-bound process – spends more time doing computations,


very long CPU bursts.(adding..copying..updating)

CPU Burst I/O CPU Burst I/O

Lahore Garrison University


1
1
Diagram of Process State

Lahore Garrison University


1
2
Process State

 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

Lahore Garrison University


1
3
Process Control Block (PCB)

Information associated with each process


(also called Process control block)
 Process state – running, waiting, etc
 Program counter – location of instruction to next execute
 CPU registers – contents of all process-centric registers
 CPU scheduling information- priorities, scheduling queue
pointers(when its turn come)
 Memory-management information –(base + limit registers,
page, Segmentation)
 Accounting information – CPU used, clock time elapsed
since start, time limits
 I/O status information – I/O devices allocated to process, list
of open files
 Process ID(PID)
 Parent PID, etc.

Lahore Garrison University


1
4
Process Scheduling

 Maximize CPU use, quickly switch processes onto CPU for


time sharing
 Process scheduler selects among available processes for
next execution on CPU
 Maintains scheduling queues of processes
 Job queue – set of all processes in the system
 Ready queue – set of all processes residing in main memory,
ready and waiting to execute
 Device queues – set of processes waiting for an I/O device
 Processes migrate among the various queues

Lahore Garrison University


1
5
Ready Queue And Various I/O
Device Queues

Lahore Garrison University


1
6
Representation of Process
Scheduling in computer system

Queueing diagram represents queues, resources, flows

Lahore Garrison University


1
7
Schedulers

 Long-term scheduler (or job scheduler) – selects which processes


should be brought into the ready queue
 It selects the process from job pool and put into main memory
 Long-term scheduler is invoked infrequently (seconds, minutes) 
(may be slow)
 The long-term scheduler controls the degree of multiprogramming
 Long-term scheduler strives for good process mix

 Short-term scheduler (or CPU scheduler)/(ready to CPU)


 selects which process should be executed next and allocates CPU

 Sometimes the only scheduler in a system


 Short-term scheduler is invoked frequently (milliseconds)  (must
be fast)
Lahore Garrison University
1
8
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
1
9
Schedulers(Cont...)

Lahore Garrison University


2
0
Schedulers (Conti…)

 Medium term scheduler (Also known as swapper)

► Selects a process in memory and swaps it out to the disk temporarily

► Swapping decision is based on several factors

► Arrival of a higher priority process but no memory available

► Poor mix of jobs

► Memory request of a process cannot be met

► Remove process from memory, store on disk, bring back in from disk to
continue execution: swapping

Lahore Garrison University


2
1
Addition of Scheduling

Lahore Garrison University


22
Multitasking in Mobile Systems

 Some mobile systems (e.g., early version of iOS) allow only one
process to run, others suspended
 Due to screen real estate, user interface limits iOS provides for a
 Single foreground process- controlled via user interface
 Multiple background processes– in memory, running, but not on the
display, and with limits
 Limits include single, short task, receiving notification of events,
specific long-running tasks like audio playback
 Android runs foreground and background, with fewer limits
 Background process uses a service to perform tasks
 Service can keep running even if background process is suspended
 Service has no user interface, small memory use
Lahore Garrison University
2
3
Context Switch

 When CPU switches to another process, the system must


save the state of the old process and load the saved state
for the new process via a context switch
 Context of a process represented in the PCB
 Context-switch time is overhead; the system does no
useful work while switching
 The more complex the OS, the longer the context switch
 Time dependent on hardware support
 Some hardware provides multiple sets of registers per CPU ➔
multiple contexts loaded at once

Lahore Garrison University


2
4
CPU Switch From Process to Process

Lahore Garrison University


2
5
Reference

 To cover this topics , different reference material has


been used for consultation.
 Operating systems concept by Abraham siberchatz
edition 9
 Tutorialspoint.com
 Google.com
 https://www.tutorialspoint.com/operating_system/os_p
rocess_scheduling.htm

Lahore Garrison University

You might also like