Download as pdf or txt
Download as pdf or txt
You are on page 1of 84

ENG 2139 -

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.

Copyrights © 2020 -2024, Department of Electrical &


04/05/2023 3
Electronic Engineering, University of Zambia
1. INTRODUCTION - 1st GENERATION
OF “OPERATING SYSTEMS” – 1940s
• The earliest computers were mainframes that
lacked any form of operating system.
• Each user had sole use of the machine for a
scheduled period of time.
• The user would arrive at the computer with a
program and data.

Copyrights © 2020 -2024, Department of Electrical &


04/05/2023 4
Electronic Engineering, University of Zambia
1. INTRODUCTION - 1st GENERATION
OF “OPERATING SYSTEMS” – 1940s
• The program and data would often be punched on
paper cards and magnetic or paper tape.
• Then, the program would be loaded into the
machine.
• And the machine would work until the program
was complete or crashed.

Copyrights © 2020 -2024, Department of Electrical &


04/05/2023 5
Electronic Engineering, University of Zambia
1. INTRODUCTION - 1st GENERATION
OF “OPERATING SYSTEMS” – 1940s
• Programs could generally be debugged via a
control panel using toggle switches and panel lights.
• It is said that Alan Turing was a master of this
“debugging” on the early Manchester Mark 1
machine.
• Alan Turing was already deriving the primitive
conception of an operating system from the
principles of the Universal Turing machine.
Copyrights © 2020 -2024, Department of Electrical &
04/05/2023 6
Electronic Engineering, University of Zambia
1. INTRODUCTION - 1st GENERATION
OF “OPERATING SYSTEMS” – 1940s

Figure 2.1: Image of a Tape and Peripheral coordinator on early computers


Copyrights © 2020 -2024, Department of Electrical &
04/05/2023 7
Electronic Engineering, University of Zambia
1. INTRODUCTION - 2nd GENERATION
OF “OPERATING SYSTEMS” – 1950s
• By this time, the routine had improved somewhat
with the introduction of punch cards.

Figure 2.2: Picture of a punch card


Copyrights © 2020 -2024, Department of Electrical &
04/05/2023 8
Electronic Engineering, University of Zambia
1. INTRODUCTION - 2nd GENERATION
OF “OPERATING SYSTEMS” – 1950s
• GM* Research Laboratories implemented the first
operating systems in the early 1950s for their IBM 701.
• The systems generally ran one job at a time.
• These were called single-stream batch processing
systems because programs and data were submitted in
groups or batches.
GM* - General Motors

Copyrights © 2020 -2024, Department of Electrical &


04/05/2023 9
Electronic Engineering, University of Zambia
1. INTRODUCTION - 2nd GENERATION
OF “OPERATING SYSTEMS” – 1950s
• Early computers ran one program at a time.
• Programs were loaded directly from paper tape
with holes punched in it (for example).
• The user would program the computer by
setting a large set of on-off switches.

04/05/2023 Copyrights © 2020 -2024, Department of Electrical & Electroni 10


c Engineering, University of Zambia
1. INTRODUCTION - 2nd GENERATION
OF “OPERATING SYSTEMS” – 1950s

Figure 2.3: Picture of Paper Tape


Copyrights © 2020 -2024, Department of Electrical &
04/05/2023 11
Electronic Engineering, University of Zambia
1. INTRODUCTION - 3rd GENERATION
OF “OPERATING SYSTEMS” – 1960s
• The systems of the 1960's were also batch
processing systems, but they were able to take
better advantage of the computer's resources by
running several jobs at once.
• So operating systems designers developed the
concept of multiprogramming in which several
jobs are in main memory at once.
Copyrights © 2020 -2024, Department of Electrical &
04/05/2023 12
Electronic Engineering, University of Zambia
1. INTRODUCTION - 3rd GENERATION
OF “OPERATING SYSTEMS” – 1960s
• A processor is switched from job to job as
needed to keep several jobs advancing while
keeping the peripheral devices in use.
• For example, on the system with no
multiprogramming, when the current job paused
to wait for other I/O operation to complete.
• The CPU simply sat idle until the I/O finished.
Copyrights © 2020 -2024, Department of Electrical &
04/05/2023 13
Electronic Engineering, University of Zambia
1. INTRODUCTION - 3rd GENERATION
OF “OPERATING SYSTEMS” – 1960s
• The solution for this problem that evolved was to
partition memory into several pieces.
• With a different job in each partition.
• While one job was waiting for I/O to complete,
another job could be using the CPU.

Copyrights © 2020 -2024, Department of Electrical &


04/05/2023 14
Electronic Engineering, University of Zambia
1. INTRODUCTION - 3rd GENERATION
OF “OPERATING SYSTEMS” – 1960s
• Another major feature in third-generation
operating system was the technique called spooling.
• Spooling meant simultaneous peripheral operations
on line.
• In spooling, a high-speed device like a disk
interposed between a running program and a low-
speed device involved with the program in
input/output.
Copyrights © 2020 -2024, Department of Electrical &
04/05/2023 15
Electronic Engineering, University of Zambia
1. INTRODUCTION - 3rd GENERATION
OF “OPERATING SYSTEMS” – 1960s
• Instead of writing directly to a printer, for example,
outputs are written to the disk.
• Programs can run to completion faster, and other
programs can be initiated sooner when the printer
becomes available, the outputs may be printed.
• Note that spooling technique is much like thread
being spun to a spool so that it may be later
unwound as needed.
Copyrights © 2020 -2024, Department of Electrical &
04/05/2023 16
Electronic Engineering, University of Zambia
1. INTRODUCTION - 3rd GENERATION
OF “OPERATING SYSTEMS” – 1960s
• Another feature present in this generation was
time-sharing technique.
• A variant of multiprogramming technique, in
which each user has an on-line (i.e., directly
connected) terminal.
• Because the user is present and interacting with the
computer, the computer system must be fast.

Copyrights © 2020 -2024, Department of Electrical &


04/05/2023 17
Electronic Engineering, University of Zambia
1. INTRODUCTION - 3rd GENERATION
OF “OPERATING SYSTEMS” – 1960s
• This means that the computer responds quickly to
user requests.
• Otherwise user productivity could suffer.
• Timesharing systems were developed to multi-
program large number of simultaneous interactive
users.

Copyrights © 2020 -2024, Department of Electrical &


04/05/2023 18
Electronic Engineering, University of Zambia
2. OPERATING SYSTEMS – 1980s
• With the development of LSI (Large Scale
Integration) circuits, chips, operating system
entered in the personal computer and the
workstation age.
• Microprocessor technology evolved to the point
that it became possible to build desktop computers
as powerful as the mainframes of the 1970s.

Copyrights © 2020 -2024, Department of Electrical &


04/05/2023 19
Electronic Engineering, University of Zambia
2. OPERATING SYSTEMS – 1980s
• Two operating systems have dominated the
personal computer scene: MS-DOS
 written by Microsoft, Inc. for the IBM PC;
 and other machines using the Intel 8088 CPU and its
successors.
• UNIX, which is dominant on the large personal
computers using the Motorola 6899 CPU family.

Copyrights © 2020 -2024, Department of Electrical &


04/05/2023 20
Electronic Engineering, University of Zambia
3. DESCRIPTION OF OPERATING
SYSTEMS
• The Role of Operating Systems
 Bridge the “Semantic Gap” between Hardware and
Application
 Three Views of Operating Systems

Copyrights © 2020 -2024, Department of Electrical &


04/05/2023 21
Electronic Engineering, University of Zambia
3. DESCRIPTION OF OPERATING
SYSTEMS
• Organization of Operating Systems
 Structural Organization
 The Hardware Interface
 The Programming Interface
 The User Interface
 Runtime Organization

Copyrights © 2020 -2024, Department of Electrical &


04/05/2023 22
Electronic Engineering, University of Zambia
3. DESCRIPTION OF OPERATING
SYSTEMS
Single CPU System

Figure 2.4: Single CPU Model

Copyrights © 2020 -2024, Department of Electrical &


04/05/2023 23
Electronic Engineering, University of Zambia
3. DESCRIPTION OF OPERATING
SYSTEMS
• Classic von Neumann stored-program computer
– memory is linear sequence of directly addressable
cells
• (1) Fetch Processing
Central Instruction Unit (CPU) cycles:
(2) Increment Program Counter
(3) Decode Instruction
(4) Fetch Operands
(5) Execute Instruction
Copyrights © 2020 -2024, Department of Electrical &
04/05/2023 24
Electronic Engineering, University of Zambia
4. ROLE OF OPERATING SYSTEMS
• Semantic Gap
 Hardware capabilities are very low level
 arithmetic and logical operators
 comparison of two bit-strings
 branching, reading, and writing bytes

Copyrights © 2020 -2024, Department of Electrical &


04/05/2023 25
Electronic Engineering, University of Zambia
4. ROLE OF OPERATING SYSTEMS
• Semantic Gap
 User needs to think in terms of problem to be solved
 high-level data structures and corresponding operations
 simple, uniform interfaces to subsystems
 treat programs and data files as single entities

Copyrights © 2020 -2024, Department of Electrical &


04/05/2023 26
Electronic Engineering, University of Zambia
4. ROLE OF OPERATING SYSTEMS
• Bridging the Semantic Gap
 Use software to bridge this semantic gap
 language processors – assemblers, compilers, interpreters
 editors and text processors, linkers and loaders
 application programs, utility and service programs

Copyrights © 2020 -2024, Department of Electrical &


04/05/2023 27
Electronic Engineering, University of Zambia
4. ROLE OF OPERATING SYSTEMS
• Bridge Hardware / Application Gap
 Machine instruction vs. high level operation
 Linear memory vs. Data structures
 Limited CPU & memory vs. More needed
 Secondary memory devices vs. Files
 I/O devices vs. High level I/O commands

Copyrights © 2020 -2024, Department of Electrical &


04/05/2023 28
Electronic Engineering, University of Zambia
4. ROLE OF OPERATING SYSTEMS
• Bridge Hardware / Application Gap
 Multiprocessor Systems

Figure 2.5: Shared Memory & Shared I/O Devices


Copyrights © 2020 -2024, Department of Electrical &
04/05/2023 29
Electronic Engineering, University of Zambia
4. ROLE OF OPERATING SYSTEMS
• Bridge Hardware / Application Gap
 Multiprocessor Systems

Figure 2.6: Dedicated Memory


Copyrights © 2020 -2024, Department of Electrical &
04/05/2023 30
Electronic Engineering, University of Zambia
4. ROLE OF OPERATING SYSTEMS
• Bridge Hardware / Application Gap
 Multicomputer Systems

Figure 2.7: Multicomputer System


Copyrights © 2020 -2024, Department of Electrical &
04/05/2023 31
Electronic Engineering, University of Zambia
4. ROLE OF OPERATING SYSTEMS
• PC Hardware Organisation

Figure 2.8: Block Diagram of PC Hardware


Copyrights © 2020 -2024, Department of Electrical &
04/05/2023 32
Electronic Engineering, University of Zambia
5. THREE VIEWS OF THE OPERTING
SYSTEM (OS)
• OS IS AN EXTENDED MACHINE
 Principle of abstraction hides complexity
 OS provides high level operations using lower level
operations
 OS presents a consistent machine interface
 To a larger extend, the OS becomes the extension of
the hardware machine.

Copyrights © 2020 -2024, Department of Electrical &


04/05/2023 33
Electronic Engineering, University of Zambia
5. THREE VIEWS OF THE OPERTING
SYSTEM
• OS is a "Virtual Machine"
 Principle of virtualization supports sharing.
 OS provides virtual CPU, memory, devices.
 OS presents a consistent computing platform.
 OS becomes what the user interacts with.
 OS becomes the abstraction of the Hardware “black-
box” to the user.

Copyrights © 2020 -2024, Department of Electrical &


04/05/2023 34
Electronic Engineering, University of Zambia
5. THREE VIEWS OF THE OPERTING
SYSTEM
• OS is a Resource Manager
 Efficiency: balance overall performance with
individual needs (response time, deadlines).
 It manages the Processor.
 It manages the Memory.
 It Manages all other computing resources in a
way that is seamless to the user.

Copyrights © 2020 -2024, Department of Electrical &


04/05/2023 35
Electronic Engineering, University of Zambia
5. ORGANISATION OF THE OPERTING
SYSTEM
• Structural Organisation
Applications
(system & user)

Libraries calls
System Libraries

Kernel calls
Operating System
(Kernel)
Machine instructions

Hardware

Figure 2.9: OS Structural organisation


Copyrights © 2020 -2024, Department of Electrical &
04/05/2023 36
Electronic Engineering, University of Zambia
5. ORGANISATION OF THE OPERTING
SYSTEM
• Interface Organisation 1
 Hardware Interface
 Applications and OS compiled into machine instructions
 Interrupts and traps allow the OS to seize control of the
computer process
 Process management (time-sharing)
 Device management (I/O completion)

Copyrights © 2020 -2024, Department of Electrical &


04/05/2023 37
Electronic Engineering, University of Zambia
5. ORGANISATION OF THE OPERTING
SYSTEM
• Interface Organisation 2
 Hardware Interface (contnd)
 Mode of CPU execution
 Privileged/non-privileged
 SVC (Supervisor call) causes traps
 Control transferred to OS in privileged mode
 OS exits privileged mode when returning to user

Copyrights © 2020 -2024, Department of Electrical &


04/05/2023 38
Electronic Engineering, University of Zambia
5. ORGANISATION OF THE
OPERATING SYSTEM
• Interface Organisation 3
Applications
• Programming (system & user)
Interface
Libraries calls
System Libraries
• Invoking system
Kernel calls
services: Operating System
• Library call – (Kernel)
non-privileged Machine instructions
• Kernel call –
privileged Hardware

Figure 2.10: OS Interface organisation


Copyrights © 2020 -2024, Department of Electrical &
04/05/2023 39
Electronic Engineering, University of Zambia
5. ORGANISATION OF THE
OPERATING SYSTEM
• Interface Organisation 4

Figure 2.11: Architecture of Linux


Copyrights © 2020 -2024, Department of Electrical &
04/05/2023 40
Electronic Engineering, University of Zambia
5. ORGANISATION OF THE
OPERATING SYSTEM
• Interface Organisation 5

Figure 2.12: Kernel in the Operating System


Copyrights © 2020 -2024, Department of Electrical &
04/05/2023 41
Electronic Engineering, University of Zambia
5. ORGANISATION OF THE
OPERATING SYSTEM
• Interface Organisation 5

Figure 2.13: Kernel and Other Components of the


Operating System
Copyrights © 2020 -2024, Department of Electrical &
04/05/2023 42
Electronic Engineering, University of Zambia
5. ORGANISATION OF THE
OPERATING SYSTEM
• Interface Organisation 5

Figure 2.14: Kernel and Other Components of the


Operating System
Copyrights © 2020 -2024, Department of Electrical &
04/05/2023 43
Electronic Engineering, University of Zambia
5. OS – KERNEL
• Kernel is the core component of the Operating
System.
• Kernel is sometimes referred to as a nervous
system of the Operating system.
• It is the central and critical core of the Operating
System.
• Kernel controls everything in the Operating
System.
Copyrights © 2020 -2024, Department of Electrical &
04/05/2023 44
Electronic Engineering, University of Zambia
5. OS – KERNEL
• Kernel controls Processor (Process) Management,
I/O Management, Memory Management, and all
other modules in the Operating system
• Kernel is a bridge between user applications and
the data processing in the Central Processing Unit.
• It acts as an interface between user applications
and the hardware.

Copyrights © 2020 -2024, Department of Electrical &


04/05/2023 45
Electronic Engineering, University of Zambia
5. OS – KERNEL FEATURES
The features of the kernel are:
 Inter-process communication
 Context switching
 Low-level scheduling of processes
 Process synchronization

Copyrights © 2020 -2024, Department of Electrical &


04/05/2023 46
Electronic Engineering, University of Zambia
5. OS – TYPES OF KERNELS

Figure 2.15: Types of Kernel of the Operating System


Copyrights © 2020 -2024, Department of Electrical &
04/05/2023 47
Electronic Engineering, University of Zambia
5. OS – PROCESSOR MANAGEMENT
THE PROCESS CONCEPT
Process is program in execution
Process need resources like:
 CPU times
 Memory
 Files
 I/O devices

Copyrights © 2020 -2024, Department of Electrical &


04/05/2023 48
Electronic Engineering, University of Zambia
5. OS – PROCESSOR MANAGEMENT
THE PROCESS CONCEPT
Resources are allocated to processes either:
 When it created
 While it executed

Process can be:


 Operating System process => execute system code
 User process => execute user code

Copyrights © 2020 -2024, Department of Electrical &


04/05/2023 49
Electronic Engineering, University of Zambia
5. OS – PROCESSOR MANAGEMENT
THE PROCESS CONCEPT
The OS’s Process Management involves:
 Creation and deletion of process
 Scheduling of process
 Provision of mechanism for synchronization
communication
 Dead lock handling for the process

Copyrights © 2020 -2024, Department of Electrical &


04/05/2023 50
Electronic Engineering, University of Zambia
5. OS – PROCESSOR MANAGEMENT
DEFINITION OF THE PROCESS
The Process is more than a program because:
 It includes the current activity - represented by the value or
content of the Program Counter.
 A content of processor register
A process also has process:
 Stack (contains temporary data like subroutine variables), return
address and temporary variables.
 Data section containing global variables.

Copyrights © 2020 -2024, Department of Electrical &


04/05/2023 51
Electronic Engineering, University of Zambia
5. OS – PROCESSOR MANAGEMENT
DEFINITION OF THE PROCESS
The Two process may be associated with the same
program – are considered two separate execution
sequences
 Eg.: a user may invoke many copies of the editor program
 Each is a separate process, but their text section are
equivalent, but data section will vary.

Copyrights © 2020 -2024, Department of Electrical &


04/05/2023 52
Electronic Engineering, University of Zambia
5. OS – PROCESSOR MANAGEMENT
THE PROCESS IN MEMORY
max

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

Figure 2.17: The Process States


Copyrights © 2020 -2024, Department of Electrical &
04/05/2023 54
Electronic Engineering, University of Zambia
6. OS – MEMORY MANAGEMENT
• Basic memory management
• Swapping
• Virtual memory
• Paging

Copyrights © 2020 -2024, Department of Electrical &


04/05/2023 55
Electronic Engineering, University of Zambia
6. OS – MEMORY MANAGEMENT
• The ideal world has memory that is
• Very large
• Very fast
• Non-volatile (doesn’t go away when power is turned off)
• The real world has memory that is:
• Very large
• Very fast
• Affordable!
ÞPick any two…
• Memory management goal: make the real world
look as much like the ideal world as possible

Copyrights © 2020 -2024, Department of Electrical &


04/05/2023 56
Electronic Engineering, University of Zambia
6. OS – MEMORY MANAGEMENT
Memory hierarchy
• What is the memory hierarchy?
• Different levels of memory
• Some are small & fast
• Others are large & slow
• What levels are usually included?
• Cache: small amount of fast, expensive memory
• L1 (level 1) cache: usually on the CPU chip
• L2 & L3 cache: off-chip, made of SRAM
• Main memory: medium-speed, medium price memory (DRAM)
• Disk: many gigabytes of slow, cheap, non-volatile storage
• Memory manager handles the memory hierarchy
Copyrights © 2020 -2024, Department of Electrical &
04/05/2023 57
Electronic Engineering, University of Zambia
6. OS – MEMORY MANAGEMENT
Basic Memory Management
• Components include
• Operating system (perhaps with device drivers)
• Single process
• Goal: lay these out in memory
• Memory protection may not be an issue (only one program)
• Flexibility may still be useful (allow OS changes, etc.)
• No swapping or paging

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?

Copyrights © 2020 -2024, Department of Electrical &


04/05/2023 60
Electronic Engineering, University of Zambia
6. OS – MEMORY MANAGEMENT
Modeling multiprogramming
• More I/O wait means less processor utilization
 At 20% I/O wait, 3–4 processes fully utilize CPU
 At 80% I/O wait, even 10 processes aren’t enough

• This means that the OS should have more


processes if they’re I/O bound
• More processes => memory management &
protection more important!

Copyrights © 2020 -2024, Department of Electrical &


04/05/2023 61
Electronic Engineering, University of Zambia
6. OS – MEMORY MANAGEMENT
Multiprogrammed system performance
• Arrival and work requirements of 4 jobs
• CPU utilization for 1–4 jobs with 80% I/O wait
• Sequence of events as jobs arrive and finish
• Numbers show amount of CPU time jobs get in each interval
• More processes => better utilization, less time per process

Job Arrival CPU


time needed
1 2 3 4
1 10:00 4 CPU idle 0.80 0.64 0.51 0.41
2 10:10 3 CPU busy 0.20 0.36 0.49 0.59
3 10:15 2 CPU/process 0.20 0.18 0.16 0.15
4 10:20 2

Copyrights © 2020 -2024, Department of Electrical &


04/05/2023 62
Electronic Engineering, University of Zambia
6. OS – MEMORY MANAGEMENT
Memory and multiprogramming
• Memory needs two things for multiprogramming
Relocation
Protection
• The OS cannot be certain where a program will
be loaded in memory
Variables and procedures can’t use absolute
locations in memory
Several ways to guarantee this

Copyrights © 2020 -2024, Department of Electrical &


04/05/2023 63
Electronic Engineering, University of Zambia
6. OS – MEMORY MANAGEMENT
Memory and multiprogramming
• The OS must keep processes’ memory
separate
Protect a process from other processes reading or
modifying its own memory
Protect a process from modifying its own memory
in undesirable ways (such as writing to program
code)

Copyrights © 2020 -2024, Department of Electrical &


04/05/2023 64
Electronic Engineering, University of Zambia
6. OS – MEMORY MANAGEMENT
Base and Limit Registers
• Special CPU registers: base & 0xFFFF
limit 0x2000
• Access to the registers limited to Limit
system mode Process
• Registers contain
partition
• Base: start of the process’s
memory partition Base
• Limit: length of the process’s 0x9000
memory partition
• Address generation
• Physical address: location in
actual memory OS
• Logical address: location from
the process’s point of view
• Physical address = base + logical Logical address: 0x1204
address Physical address:
• Logical address larger than limit 0x1204+0x9000 = 0xa204
=> error
Copyrights © 2020 -2024, Department of Electrical &
04/05/2023 65
Electronic Engineering, University of Zambia
6. OS – MEMORY MANAGEMENT
Swapping
C C C C C
B B B B
A
A A A
D D D
OS
• Memory allocation changes as
• Processes come into memory
• Processes leave memory
• Swapped to disk
• Complete execution
• Gray regions are unused memory
Copyrights © 2020 -2024, Department of Electrical &
04/05/2023 66
Electronic Engineering, University of Zambia
6. OS – MEMORY MANAGEMENT
Swapping – Leaving Room to Grow
• Need to allow for programs
to grow Stack
• Allocate more memory for Room for
data Process B to grow
• Larger stack B
Data
• Handled by allocating
Code
more space than is
necessary at the start Stack
• Inefficient: wastes memory Room for
that’s not currently in use Process A to grow
• What if the process requests A
Data
too much memory?
Code

Copyrights © 2020 -2024, Department of Electrical &


04/05/2023 67
Electronic Engineering, University of Zambia
6. OS – MEMORY MANAGEMENT
Allocating Memory
• Search through region list to find a large enough space
• Suppose there are several choices: which one to use?
First fit: the first suitable hole on the list
Next fit: the first suitable after the previously allocated hole
Best fit: the smallest hole that is larger than the desired region
(wastes least space?)
Worst fit: the largest available hole (leaves largest fragment)
• Option: maintain separate queues for different-size
holes
Copyrights © 2020 -2024, Department of Electrical &
04/05/2023 68
Electronic Engineering, University of Zambia
6. OS – MEMORY MANAGEMENT
Freeing Memory
• Allocation structures must be updated when memory
is freed
• Easy with bitmaps: just set the appropriate bits in the
bitmap
• Linked lists: modify adjacent elements as needed
Merge adjacent free regions into a single region
May involve merging two regions with the just-freed area

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

• Example: Virtual Physical


 64 KB virtual memory address memory
 32 KB physical memory space
Copyrights © 2020 -2024, Department of Electrical &
04/05/2023 74
Electronic Engineering, University of Zambia
7. COMMON OPERTING SYSTEMs
Windows
• Windows is a graphical operating system developed by
Microsoft.
• It allows users to view and store files, run the software, play
games, watch videos, and provides a way to connect to the
internet.
• It was released for both home computing and professional
works.
• Windows uses Hybrid Kernel.
• Its main File System is NTFS

Copyrights © 2020 -2024, Department of Electrical &


04/05/2023 75
Electronic Engineering, University of Zambia
7. COMMON OPERTING SYSTEMs
Unix
• Unix is a portable, multitasking, multiuser, time-sharing
operating system (OS) originally developed in 1969 by a
group of employees at AT&T.
• Unix was first programmed in assembly language but was
reprogrammed in C in 1973.
• Unix is a modular OS made up of a number of essential
components, including the kernel, shell, file system and a
core set of utilities or programs.
• At the heart of the Unix OS is the kernel, a master control
program that provides services to start and end programs.
Copyrights © 2020 -2024, Department of Electrical &
04/05/2023 76
Electronic Engineering, University of Zambia
7. COMMON OPERTING SYSTEMs
Linux
• Linux, was created in the early 1990s by Finnish
software engineer Linus Torvalds.
• Linux grew throughout the 1990s because of the
efforts of hobbyist developers.
• Linux is a Unix-like, open source and community-
developed operating system (OS) for computers.
• Linux is an efficient and reliable system that rarely
crashes.

Copyrights © 2020 -2024, Department of Electrical &


04/05/2023 77
Electronic Engineering, University of Zambia
7. COMMON OPERTING SYSTEMs
Linux
• Combined with Apache, an open-source Web server,
Linux accounts for most of the servers used on the
Internet.
• Linux can run on servers, mainframes, mobile devices
and embedded devices.
• It is supported on almost every major computer
platform, including x86, ARM and SPARC, making it
one of the most widely supported operating systems.

Copyrights © 2020 -2024, Department of Electrical &


04/05/2023 78
Electronic Engineering, University of Zambia
7. COMMON OPERTING SYSTEMs
Linux
• It has a very varied file system.
• Linux Kernel is monolithic.
• Linux has many releases, commonly known as
distributions (distros).

Copyrights © 2020 -2024, Department of Electrical &


04/05/2023 79
Electronic Engineering, University of Zambia
7. COMMON OPERTING SYSTEMs
Mac OS
• MacOS is the computer operating system (OS) for Apple
desktops and laptops.
• It is a proprietary graphical OS that powers every Mac.
• Within the market of desktop and laptop computers, it is
the second most widely used desktop OS.

Copyrights © 2020 -2024, Department of Electrical &


04/05/2023 80
Electronic Engineering, University of Zambia
7. COMMON OPERTING SYSTEMs
Mac OS
• In macOS, the system is limited to running no more than
1064 processes (or 2088 starting with Catalina)
systemwide.
• And individual users are limited to 709 (or 1392 in
Catalina).
• Apple File System (APFS), the default file system for
Mac computers.

Copyrights © 2020 -2024, Department of Electrical &


04/05/2023 81
Electronic Engineering, University of Zambia
7. COMMON OPERTING SYSTEMs
Android
• Android is an open source and Linux-based Operating
System.
• It is used for mobile devices such as smartphones and
tablet computers.
• Android was developed by the Open Handset Alliance,
led by Google, and other companies.
• Android offers a unified approach to application
development for mobile devices.

Copyrights © 2020 -2024, Department of Electrical &


04/05/2023 82
Electronic Engineering, University of Zambia
7. COMMON OPERTING SYSTEMs
Android
• Developers need only develop for Android, and their
applications should be able to run on different devices
powered by Android.
• The first beta version of the Android Software
Development Kit (SDK) was released by Google in 2007
where as the first commercial version, Android 1.0, was
released in September 2008.

Copyrights © 2020 -2024, Department of Electrical &


04/05/2023 83
Electronic Engineering, University of Zambia
7. COMMON OPERTING SYSTEMs
iOS
• Apple iOS stands for iPhone operating system and is
designed for use with Apple's multitouch devices.
• The mobile OS supports input through direct
manipulation and responds to various user gestures,
such as pinching, tapping and swiping.
• The iOS developer kit provides tools that allow for iOS
app development.
• iOS is a proprietary Operating System for Apple mobile
devices such as iPhones and iPads.
Copyrights © 2020 -2024, Department of Electrical &
04/05/2023 84
Electronic Engineering, University of Zambia

You might also like