0% found this document useful (0 votes)
20 views32 pages

Topic 2 Part 1

The document discusses memory management techniques, describing the memory hierarchy from fastest to slowest storage, memory management strategies like placement and replacement, and memory allocation methods including segmentation which divides programs into variable segments and paging which partitions memory into equal size pages, with each process having a page table maintained by the operating system.

Uploaded by

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

Topic 2 Part 1

The document discusses memory management techniques, describing the memory hierarchy from fastest to slowest storage, memory management strategies like placement and replacement, and memory allocation methods including segmentation which divides programs into variable segments and paging which partitions memory into equal size pages, with each process having a page table maintained by the operating system.

Uploaded by

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

Topic 2

Memory and
Process
Management

Part 1
Learning Outcome

 Define the function of memory manager


 Describe characteristics of the different levels in the
hierarchy of memory organization
 Describe memory management strategies
 Identify between resident and transient routines
 Describe memory swapping technique
 Describe fixed partition memory management
 Describe how virtual memory works in relation to
Segmentation and Paging
 Explain the major system resource types within a
computer system
MEMORY MANAGEMENT
 A memory management is a utility that helps manage the
system memory more efficiently.
 Without memory management, processes will not have
enough memory space to run.

Functions of Memory Manager

Determine part of Preserve the


the memory that Allocate memory memory in used
can be used and for the needed by any process so
which part cannot process that it is not
be used interrupted
MEMORY HIERARCHY

 Memory hierarchy is an organization of different


types of system memories in the order of their
increasing access speeds.

 This is needed because making large and fast


memories is extremely costly and would not make it
economical.
The memory hierarchy in most computers is:
Details
Processor registers Registers – the fastest access speed. Found in
CPU.
Level 1 (L1) cache
Cache - High speed memory, small to
Level 2 (L2) cache moderate capacity . Found in CPU.

Level 3 (L3) cache Main memory – Moderate speed, primary


storage, can be multiple gigabytes.
Main memory (RAM)
Disk storage – Slow speed, but can be
multiple terabytes.
Disk storage
Tertiary storage – Simple, very large, slow
Tertiary storage speed removable storage. I.e. magnetic tape.
Memory Management Strategies
1. Fetch Strategy:
 Determine when to load and how much to load at a time.

2. Placement Strategy:
 Determine where information is to be placed.
 Types: Best-Fit, First-Fit, Worst-Fit.

3 . Replacement Strategy:
 Determine which memory area is to be removed under
conflict conditions.
Placement Strategies

Best-fit
•Allocate the smallest empty space that is big enough
•Makes the best use of memory space but slower in
making allocation

First-fit
•Allocate the first empty space that is big enough
•Faster in making allocation but leads to memory
waste

•Allocate the largest empty space


Worst-fit •Opposite to best-fit
•Not the best choice for an actual system

Detailed explanation: http://thumbsup2life.blogspot.com/2011/02/best-fit-first-fit-and-worst-fit-memory.html


Activity: Arrange the processes
 A memory space is segmented as per following:
Segment 0 = 100kb, Segment 1 = 80kb, Segment 2 = 160kb, Segment 3 =
350kb, Segment 4 = 500kb.

#0 (100kb) #1 (80kb) #2 (160kb) #3 (350kb) #4 (500kb)

 Given: Process A= 50kb, Process B= 100kb, Process C= 150kb,


Process D= 300kb.
 Assume the processes arrive in the order A, B, C, D
 Draw the allocation diagram for the processes A, B, C, D in the stated
memory space segmentation.
Answer: First-fit
 Process A= 50kb, Process B= 100kb, Process C= 150kb, Process D=
300kb.
 Assume the processes arrive in the order A, B, C, D.

#0 (100kb) #1 (80kb) #2 (160kb) #3 (350kb) #4 (500kb)

 First-fit = Allocate the first empty space that is big enough


Answer: First-fit
 Process A= 50kb, Process B= 100kb, Process C= 150kb, Process D=
300kb.
 Assume the processes arrive in the order A, B, C, D.
A B C D
#0 (100kb) #1 (80kb) #2 (160kb) #3 (350kb) #4 (500kb)

 First-fit = Allocate the first empty space that is big enough


Answer: Best-fit
 Process A= 50kb, Process B= 100kb, Process C= 150kb, Process D=
300kb.
 Assume the processes arrive in the order A, B, C, D.

#0 (100kb) #1 (80kb) #2 (160kb) #3 (350kb) #4 (500kb)

 Best-fit = Allocate the smallest empty space that is big enough.


Answer: Best-fit
 Process A= 50kb, Process B= 100kb, Process C= 150kb, Process D=
300kb.
 Assume the processes arrive in the order A, B, C, D.
B A C D
#0 (100kb) #1 (80kb) #2 (160kb) #3 (350kb) #4 (500kb)

 Best-fit = Allocate the smallest empty space that is big enough.


Answer: Worst-fit
 Process A= 50kb, Process B= 100kb, Process C= 150kb, Process D=
300kb.
 Assume the processes arrive in the order A, B, C, D.

#0 (100kb) #1 (80kb) #2 (160kb) #3 (350kb) #4 (500kb)

 Worst-fit = Allocate the largest empty space that is found.


Answer: Worst-fit
 Process A= 50kb, Process B= 100kb, Process C= 150kb, Process D=
300kb.
 Assume the processes arrive in the order A, B, C, D.
C B A
#0 (100kb) #1 (80kb) #2 (160kb) #3 (350kb) #4 (500kb)

 Process D has to wait.

 Worst-fit = Allocate the largest empty space that is found.


Resident and Transient Routines
 The operating system is a collection of software routines.
Routines are tasks done repeatedly.

Resident routines Transient routines


Routines that directly support Stored on disk and read into
application programs as they run. memory only when needed
Remain in the memory.

Example: routine that control Example: routine that formats disks


physical I/O
Cont..
 During system boot up, system
control information comes first

 This is followed by various resident


operating system routines.

 The remaining memory area is


where application programs and
transient operating system routines
are loaded.

Resident & transient routines


structure
Memory Swapping Technique
 A process must be in the memory to be executed.

 When there is not enough memory space, a process can be swapped.

 Swapping is a mechanism in which a process is swapped temporarily out


of the memory to a backing store (usually a hard disk) to give way to
other process. The first process is brought back into the memory to
continue execution after the second process finishes.

 Swapping policy is used for priority-based scheduling algorithms. If a


higher-priority process arrives and wants service, the memory manager
can swap out the lower-priority process and then load and execute the
higher-priority process. When the higher-priority process finishes, the
lower-priority process can be swapped back in and continued.
Swapping of two processes using a disk as a backing store
Fixed-partition Memory Management
 Itis the simplest approach to managing memory for multiple
programs.

On many systems,
multiple programs are
loaded into memory and
executed by turns.

At any time slice, only one


process may run.
Cont…
Fixed-partition memory
management divides the Operating system
memory space into fixed
length (not chageable)
partitions. Process A (partition 1)

Each one holds one


process. Memory space
Process B (partition 2)
is wasted if any process
does not fully utilize its
partition.
Process C (partition 3)
Advantages: Simplicity.

Disadvantages: Wastes Memory utilization


space. Wasted space
Segmentation
 Withsegmentation, programs are
divided into variable size segments.

 Programs are segmented


automatically by compiler or
assembler.

 Segmentation uses a segment table.


Example of Segmentation
 Each entry in the
segment table has a
segment base and a
segment limit.
 The segment base
contains the
starting physical
address where the
segment resides in
memory.
 The segment limit Segment
number

specifies the length


of the segment.
Exercise
0

10
Seg. 2
13

Seg. LIMI BAS 20


T E Seg. 3
30
0 10 100 Seg. 4
60
1 25 70
70
2 3 10 Seg. 1
95
3 10 20
100
4 30 30 Seg. 0
110
5 5 110 Seg. 5
115

Given the above


segment table, draw Answer.
the segment
diagram.
Paging
 Paging partitions memory into small equal-size chunks
(perhaps 2K to 4K).

 Operating system maintains a page table for each process.


Segmentation vs. Paging

 Divide program into  Divide memory into equal-


variable-sized segments size chunks

 Uses segment table


 Uses page table
 No internal fragmentation
 No external fragmentation
 Some external
fragmentation  Small amount of internal
fragmentation
DID YOU KNOW?

Internal vs. External Fragmentation


 Internal fragmentation occurs when there is extra space empty
inside of a block of memory that has been allocated for a process.

 External fragmentation happens when the memory has sections of


unused memory blocks that are often too small for significant use.
System Resources
 A resource, or system resource, is any component which has
limited availability within a computer system.

 I.e : 4GB memory cannot perform an operation which


requires 5GB. Same goes to the speed of the cpu, it is limited
to its speed.

 Examples of system resources are:

CPU time Memory


Cont…
 CPU Time: The CPU time is measured in clock
ticks or seconds. CPU is limited to its speed i.e. 3
GHz.
Cont…

 Memory: Limitation of its capacity i.e. 4GB

 Hard disk space: Limitation of its capacity i.e


500GB

 Network throughput: refers to the amount of data


that can flow through a network media at one time.
A common network cable has a maximum 1Gbps
data throughput
Cont…

 Electrical power: the wattage supplied i.e. 2


Kilowatt

 External devices: printer, scanner, external storage,


etc.

 I/O operations: A computer has a maximum limit on


how much I/O operations it can handle in any given
amount of time
Q&A

You might also like