Professional Documents
Culture Documents
ENG 2139 - CH02 - Fundamentals of Operating Systems - v1.0
ENG 2139 - CH02 - Fundamentals of Operating Systems - v1.0
INTRODUCTION TO
INFORMATION
TECHNOLOGY
For 2ND Year Students doing
BEng. + BSc. Mining
ENG 2139
PART I
CH02 – FUNDAMENTALS
OF OPERATING SYSTEMS
1. INTRODUCTION - 1st GENERATION
OF “OPERATING SYSTEMS” – 1940s
• The earliest electronic digital computers had no
operating systems.
• Programs were often entered one bit at a time on
rows of mechanical switches (plug boards).
• Programming languages were unknown (not even
any assembly languages existed at the time).
• Operating systems were unheard of.
Libraries calls
System Libraries
Kernel calls
Operating System
(Kernel)
Machine instructions
Hardware
0
Figure 2.16: Process in memory
Copyrights © 2020 -2024, Department of Electrical &
04/05/2023 53
Electronic Engineering, University of Zambia
5. OS – PROCESSOR MANAGEMENT
THE PROCESS STATES
0xFFFF 0xFFFF
Operating system Device drivers
User program (ROM) (ROM)
(RAM)
User program
User program (RAM)
Operating system (RAM)
(RAM) Operating system
0 (RAM) 0
Copyrights © 2020 -2024, Department of Electrical &
04/05/2023 58
Electronic Engineering, University of Zambia
6. OS – MEMORY MANAGEMENT
Fixed partitions: multiple programs
• Fixed memory partitions
• Divide memory into fixed spaces
• Assign a process to a space when it’s free
• Mechanisms
• Separate input queues for each partition
• Single input queue: better ability to optimize CPU usage
900K 900K
Partition 4 Partition 4
700K 700K
Partition 3 Partition 3
600K 600K
Partition 2 Partition 2
500K 500K
Partition 1 Partition 1
100K 100K
OS OS
0
Copyrights © 2020 -2024, Department of Electrical & 0
04/05/2023 59
Electronic Engineering, University of Zambia
6. OS – MEMORY MANAGEMENT
How many programs to run at once?
• Several memory partitions (fixed or variable size)
• Lots of processes wanting to use the CPU
• Trade off
More processes utilize the CPU better
Fewer processes use less memory (cheaper!)
• How many processes do we need to keep the CPU fully
utilized?
This will help determine how much memory we need
Is this still relevant with memory costing less than $1/GB?
A X B A B
A X A
X B B
X
Copyrights © 2020 -2024, Department of Electrical &
04/05/2023 69
Electronic Engineering, University of Zambia
6. OS – MEMORY MANAGEMENT
Limitations of Swapping
• Problems with swapping
Process must fit into physical memory (impossible to
run larger processes)
Memory becomes fragmented
External fragmentation: lots of small free areas
Compaction needed to reassemble larger free areas
Processes are either in memory or on disk: half and
half don’t do any good
• Overlays solved the first problem
Bring in pieces of the process over time (typically data)
Still doesn’t solve the problem of fragmentation or
partially resident processes
Copyrights © 2020 -2024, Department of Electrical &
04/05/2023 70
Electronic Engineering, University of Zambia
6. OS – MEMORY MANAGEMENT
Virtual Memory
• Basic idea: allow the OS to hand out more memory than exists
on the system
• Keep recently used stuff in physical memory
• Move less recently used stuff to disk
• Keep all of this hidden from processes
Processes still see an address space from 0 – max address
Movement of information to and from disk handled by the OS
without process help
• Virtual memory (VM) especially helpful in multiprogramming
system
CPU schedules process B while process A waits for its memory to be
retrieved from disk
Copyrights © 2020 -2024, Department of Electrical &
04/05/2023 71
Electronic Engineering, University of Zambia
6. OS – MEMORY MANAGEMENT
Virtual and Physical Addresses
• Program uses virtual
CPU chip addresses
CPU MMU Addresses local to the
process
Hardware translates virtual
Virtual addresses
address to physical address
from CPU to MMU
• Translation done by the
Memory Memory Management Unit
Usually on the same chip as
the CPU
Physical addresses Only physical addresses
on bus, in memory
leave the CPU/MMU chip
Disk
• Physical memory indexed
controller
by physical addresses
Copyrights © 2020 -2024, Department of Electrical &
04/05/2023 72
Electronic Engineering, University of Zambia
6. OS – MEMORY MANAGEMENT
Limitations of Swapping
• Problems with swapping
Process must fit into physical memory (impossible to
run larger processes)
Memory becomes fragmented
External fragmentation: lots of small free areas
Compaction needed to reassemble larger free areas
Processes are either in memory or on disk: half and
half doesn’t do any good
• Overlays solved the first problem
Bring in pieces of the process over time (typically data)
Still doesn’t solve the problem of fragmentation or
partially resident processes
Copyrights © 2020 -2024, Department of Electrical &
04/05/2023 73
Electronic Engineering, University of Zambia
6. OS – MEMORY MANAGEMENT
Paging and Page Tables
• Virtual addresses mapped to
physical addresses
60–64K -
56–60K -
Unit of mapping is called a page 52–56K -
All addresses in the same virtual 48–52K 6
page are in the same physical 44–48K 5
page 40–44K 1
Page table entry (PTE) contains
36–40K -
translation for a single page
32–36K -
28–32K 3 28–32K
• Table translates virtual page 24–28K 24–28K
number to physical page number
20–24K - 20–24K
16–20K 0 16–20K
Not all virtual memory has a 12–16K - 12–16K
physical page 8–12K - 8–12K
Not every physical page need be 4–8K 4
used 0–4K 7 0–4K