SlideShare a Scribd company logo
1
Memory Management
Chapter 7
2
Agenda
• Discuss the principal requirements for memory
management.
• Understand the reason for memory partitioning
and explain the various techniques that are used.
• Understand and explain the concept of paging.
• Understand and explain the concept of
segmentation.
• Assess the relative advantages of paging and
segmentation.
• Summarize key security issues related to memory
management.
• Describe the concepts of loading and linking.
3
Memory Management
• What???
– Uniprogramming System Vs Multiprogramming System
• Subdividing user part of memory to
accommodate multiple processes
dymamically.
• Why???
• Memory needs to be allocated to ensure a
reasonable supply of ready processes to
consume available processor time
4
Memory Management Requirements
• Purpose????
– The requirements that memory management is
intended to satisfy
• Relocation
– Programmer does not know where the program
will be placed in memory when it is executed
– While the program is executing, it may be
swapped to disk and returned to main memory at a
different location (relocated)
– Memory references must be translated in the code
to actual physical memory address
5
6
Memory Management Requirements
• Protection
– Processes should not be able to reference memory
locations in another process without permission
– Impossible to check absolute addresses at compile
time
– Must be checked at run time
– Memory protection requirement must be satisfied by
the processor (hardware) rather than the operating
system (software)
• Operating system cannot anticipate all of the
memory references a program will make
7
• Sharing
– Allow several processes to access the same
portion of memory
– To allow each process access to the same copy
of the program rather than have their own
separate copy
Memory Management Requirements
8
• Logical Organization
– main memory in a computer system is organized as
a linear 1D address space consisting of a sequence
of bytes or words.
– Programs are written in modules
– Modules can be written and compiled independently
– Different degrees of protection given to modules
(read-only, execute-only)
– Share modules among processes
Memory Management Requirements
9
• Physical Organization
– Memory available for a program plus its data may
be insufficient
• Overlaying allows various modules to be assigned the
same region of memory
– Programmer does not know how much space will
be available
– The task of moving information between the
two levels of memory should be a system
responsibility
Memory Management Requirements
Essence of memory management.
– The task of moving information between
the two levels of memory should be a
system responsibility Not Programmer’s
10
Memory Management Requirements
Principle responsibility of memory management
– To bring processes into main memory for
execution by the processor to ensure the
sufficient no. of ready processes.
11
Memory Management Requirements
12
Memory Partitioning: Fixed Partitioning
• Equal-size partitions
– Any process whose size is less than or equal to
the partition size can be loaded into an available
partition
– If all partitions are full, the operating system can
swap a process out of a partition
– A program may not fit in a partition. The
programmer must design the program with
overlays
13
Fixed Partitioning
• Main memory use is inefficient. Any
program, no matter how small, occupies an
entire partition. This is called internal
fragmentation.
• A program may not fit in a partition. It
become programmers headache to write the
program in overlayed form.
14
15
Placement Algorithm with Partitions
• Equal-size partitions
– Because all partitions are of equal size, it does
not matter which partition is used
• Unequal-size partitions
– Can assign each process to the smallest
partition within which it will fit
– Queue for each partition
– Processes are assigned in such a way as to
minimize wasted memory within a partition
16
17
Dynamic Partitioning
• Partitions are of variable length and number
• Process is allocated exactly as much memory
as required
• Eventually get holes in the memory. This is
called external fragmentation
• Must use compaction to shift processes so
they are contiguous and all free memory is in
one block
18
19
Dynamic Partitioning Placement
Algorithm
• Operating system must decide which free
block to allocate to a process
• Best-fit algorithm
– Chooses the block that is closest in size to the
request
– Worst performer overall
– Since smallest block is found for process, the
smallest amount of fragmentation is left
– Memory compaction must be done more often
20
Dynamic Partitioning Placement
Algorithm
• First-fit algorithm
– Scans memory form the beginning and chooses
the first available block that is large enough
– Fastest
– May have many process loaded in the front end
of memory that must be searched over when
trying to find a free block
21
Dynamic Partitioning Placement
Algorithm
• Next-fit
– Scans memory from the location of the last
placement
– More often allocate a block of memory at the
end of memory where the largest block is found
– The largest block of memory is broken up into
smaller blocks
– Compaction is required to obtain a large block
at the end of memory
22
23
Buddy System
• Both fixed and dynamic partitioning schemes have
drawbacks.
– A fixed partitioning scheme limits the number of
active processes
– May use space inefficiently if there is a poor match
between available partition sizes and process sizes.
– A dynamic partitioning scheme is more complex to
maintain
– Also includes the overhead of compaction.
24
Buddy System
• Memory blocks are available of size 2K words, L<= K<= U
• 2L smallest size block that is allocated
• 2U largest size block that is allocated; generally 2U is the
size of the entire memory available for allocation.
• Initially,
• Entire space available is treated as a single block of 2U
• If a request of size s such that 2U-1 < s <= 2U, entire block is
allocated
– Otherwise block is split into two equal buddies
– Process continues until smallest block greater than or
equal to s is generated.
25
26
27
Buddy Systems
• Application of Buddy systems:
– In parallel systems as an efficient means of allocation and
release for parallel programs.
• A modified form of the buddy system is used for
UNIX kernel memory allocation
28
What next????
• Ways of dealing with the shortcomings of
partitioning let it be any
– Fixed
• Equal sized
• Unequal sized
– Dynamic
– Buddy
29
What next????
• A process may occupy different partitions during the
course of its life.
• When a process image is first created, it is loaded
into some partition in main memory.
• The process may be swapped out;
• When it is subsequently swapped back in, it may be
assigned to a different partition than the last time.
30
Relocation
• When program loaded into memory the
actual (absolute) memory locations are
determined.
• A process may occupy different partitions
which means different absolute memory
locations during execution (from swapping)
• Compaction will also cause a program to
occupy a different partition which means
different absolute memory locations.
31
Addresses
• A distinction is made among several types of
addresses.
• Logical
– Reference to a memory location independent of the
current assignment of data to memory
– Translation must be made to the physical address
• Relative
– Address expressed as a location relative to some known
point (Type of logical address)
• Physical
– The absolute address or actual location in main memory
32
Registers Used during Execution
• Base register
– Starting address for the process
• Bounds register
– Ending location of the process
• These values are set when the process is
loaded/updated or when the process is
swapped in.
33
Typically, all of the memory references in the loaded process are
relative to the origin of the program
34
Process of Relocation
• The value of the base register is added
to a relative address to produce an
absolute address.
• The resulting address is compared with
the value in the bounds register.
• If the address is not within bounds, an
interrupt is generated to the operating
system
35
Small exercise
• Consider a fixed partitioning scheme
with equal-size partitions of 2^16 bytes
and a total main memory size of 2^24
bytes. A process table is maintained that
includes a pointer to a partition for each
resident process. How many bits are
required for the pointer?
36
Paging:
• Partition memory into small equal fixed-size chunks
and divide each process into the same size chunks
• The chunks of a process are called pages and chunks
of memory are called frames
• Operating system maintains a page table for each
process
– Contains the frame location for each page in the
process
– Memory address consist of a page number and
offset within the page
37
Assignment of Process Pages to
Free Frames
38
Assignment of Process Pages to
Free Frames
39
Page Tables for Example
40
Segmentation
• All segments of all programs do not have to
be of the same length
• There is a maximum segment length
• Addressing consist of two parts - a segment
number and an offset
• Since segments are not equal, segmentation is
similar to dynamic partitioning
41
42
43
44
Let us do :
A 1-Mbyte block of memory is allocated using
the buddy system. a. Show the results of the
following sequence in a figure
Request 70; Request 35; Request 80; Return A;
Request 60; Return B; Return D; Return C. b.
Show the binary tree representation following
Return B.
45
Let us do : (For chapter 8)
Consider a simple paging system with the
following parameters: 2^32 bytes of physical
memory; page size of 2^10 bytes; 2^16 pages of
logical address space.
a. How many bits are in a logical address?
b. How many bytes in a frame?
c. How many bits in the physical address
specify the frame?
d. How many entries in the page table?
e. How many bits in each page table entry?
46
• Physical: 232
• Page Size: 210
• Number of Pages: 216
• How many bits in a logical
address? That's the page address bits
plus the number of pages bits. The
upper portion of an address is the page
number (16 bits), and the lower portion
is the offset within that address (10
bits), so the whole address size is 26
bits (1026 bytes).
47
• Physical: 232
• Page Size: 210
• Number of Pages: 216How many bytes
are in a frame? A frame is where a
page can be mapped into memory, so a
frame has to be the same size as a
page - 210 bytes.
• How many bits are in the physical
address specifying the frame? Well,
you have 32 bits of physical address,
and a frame is 210 big, so that leaves 22
of the bits (32 - 10) for the frame's base
address.
48
• Physical: 232
• Page Size: 210
• How many entries in the page
table? The page table is the full list of
pages, whether mapped or unmapped -
so there are 216 entries in the page
table, since there are 216 pages.
49
• Physical: 232
• Page Size: 210
• How many bits in each page table
entry? Assume each page table entry
contains a valid/invalid bit. If each
page maps to an entry in the page
table, and that table is a list of the
addresses at which the pages are
mapped in physical memory, then each
address in the table must be the size of
answer 3 (22 bits) plus one bit for the
valid/invalid bit, so 23 bits.
50

More Related Content

PDF
07-MemoryManagement.ppt
hello509579
 
PDF
Memory Management
DEDE IRYAWAN
 
PPTX
Memory management1
rizwanaabassi
 
PPT
Memory Management in Operating Systems for all
VSKAMCSPSGCT
 
PPTX
Memory Management techniques -ch8_1.pptx
KongaMadhukar
 
DOCX
PAGIN AND SEGMENTATION.docx
ImranBhatti58
 
PPT
08 operating system support
Sher Shah Merkhel
 
PPTX
chapter 2 memory and process management
Aisyah Rafiuddin
 
07-MemoryManagement.ppt
hello509579
 
Memory Management
DEDE IRYAWAN
 
Memory management1
rizwanaabassi
 
Memory Management in Operating Systems for all
VSKAMCSPSGCT
 
Memory Management techniques -ch8_1.pptx
KongaMadhukar
 
PAGIN AND SEGMENTATION.docx
ImranBhatti58
 
08 operating system support
Sher Shah Merkhel
 
chapter 2 memory and process management
Aisyah Rafiuddin
 

Similar to Chapter07_ds.ppt (20)

PPTX
Memory Management in Operating Systems ppt.pptx
bhaimodel20
 
PPTX
Os unit 3
SandhyaTatekalva
 
PPTX
M20CA1030_391_2_Part2.pptx
HarikishnaKNHk
 
PPTX
OS UNIT4.pptx
DHANABALSUBRAMANIAN
 
PPTX
B.Tech. Computer Science Engineering OS Notes Unit 3
likatif784
 
PPTX
Lecture 5 memory management in operating systems.pptx
HarrisChikunya
 
PPT
08 operating system support
Anwal Mirza
 
PPTX
Lecture-7 Main Memroy.pptx
Amanuelmergia
 
PPT
operationg systemsdocumentmemorymanagement
SNIGDHAAPPANABHOTLA
 
PPT
OS-unit-3 part -1mxmxmxmmxmxmmxmxmxmxmxmmxmxmmx.ppt
SNIGDHAAPPANABHOTLA
 
PPT
08 operating system support
Bitta_man
 
PPT
08 operating system support
dilip kumar
 
PPTX
Memory management concepts in operating system
GopikaS12
 
PPT
7. Memory management in operating system.ppt
imrank39199
 
PDF
Memory Management slides of operating system
shamsulhuda34
 
PPT
Memory Management-Muhammad Ahmad.ppt
AliyanAbbas1
 
PPTX
Memory management
PATELARCH
 
PDF
Memory Management Strategies - II.pdf
Harika Pudugosula
 
PDF
Ch8 main memory
Welly Dian Astika
 
PPT
Unit 4_ Memory Management Memory ManagementMemory ManagementMemory Management...
harsh1212000552
 
Memory Management in Operating Systems ppt.pptx
bhaimodel20
 
Os unit 3
SandhyaTatekalva
 
M20CA1030_391_2_Part2.pptx
HarikishnaKNHk
 
OS UNIT4.pptx
DHANABALSUBRAMANIAN
 
B.Tech. Computer Science Engineering OS Notes Unit 3
likatif784
 
Lecture 5 memory management in operating systems.pptx
HarrisChikunya
 
08 operating system support
Anwal Mirza
 
Lecture-7 Main Memroy.pptx
Amanuelmergia
 
operationg systemsdocumentmemorymanagement
SNIGDHAAPPANABHOTLA
 
OS-unit-3 part -1mxmxmxmmxmxmmxmxmxmxmxmmxmxmmx.ppt
SNIGDHAAPPANABHOTLA
 
08 operating system support
Bitta_man
 
08 operating system support
dilip kumar
 
Memory management concepts in operating system
GopikaS12
 
7. Memory management in operating system.ppt
imrank39199
 
Memory Management slides of operating system
shamsulhuda34
 
Memory Management-Muhammad Ahmad.ppt
AliyanAbbas1
 
Memory management
PATELARCH
 
Memory Management Strategies - II.pdf
Harika Pudugosula
 
Ch8 main memory
Welly Dian Astika
 
Unit 4_ Memory Management Memory ManagementMemory ManagementMemory Management...
harsh1212000552
 
Ad

Recently uploaded (20)

PDF
How Howard Wilner of Sudbury, MA Helps Leaders Align Personal Values with Pro...
jimcarns
 
PPTX
AIMS OBJECTIVES ajjsjsjsjejejejejejejejejj
IsaacAntwi15
 
PPTX
Selection and Retentionhsiwisjjeuwjfdwws
FahadBinImtiaz
 
PPTX
Database management system is manager data
thakormitul730
 
PPTX
1.02 Ramesh Pinjani - Important Track Design Parameters.pptx
abheeplay
 
PPTX
PROPOSAL RESEARCH METHODOLOGY-1lssskkskes
IsaacAntwi15
 
PDF
PC450LC-8R KOMATSU HYDRAULIC EXCAVATOR PARTS MANUAL SN 75001-UP
Heavy Equipment Manual
 
PDF
Evis Kola on How to Maximize Your Layover Turning Airport Time into Mini Adve...
Evis Kola
 
PDF
PC160LC-7K-KA KOMATSU CRAWLER EXCAVATOR PARTS MANUAL SN K40001-UP
Heavy Equipment Manual
 
PPTX
Soffit_Panel_India_Presentation.pptx____
interviewquestion6
 
PDF
PC160LC-7K-KA KOMATSU CRAWLER EXCAVATOR PARTS MANUAL K40001-UP
Heavy Equipment Manual
 
PDF
Transform Your Lexus for the Trails with Expert Off-Road Customization Services
MW4 Outfitters
 
PDF
NCHRP Report 672 Roundabouts: An Informational Guide
Forklift Trucks in Minnesota
 
PDF
Reliable Solutions for Maserati Battery, Wiring, and Electronics Problems You...
Kruse Lucas Imports
 
PPTX
Presentation1.pptxiiiiiiiiiiiiiiiiiiiiiiii
gillprabhjot1212
 
PPT
Operational Risk and its importance an d
icuphamid
 
PPTX
INTRODUCTION TO HUMAN RESOURCE MANAGEMEN
FahadBinImtiaz
 
PPTX
Have 10 Thousand Dollars Lying Around? You Can Buy Any One Of These Project Cars
jennifermiller8137
 
PPTX
"Data Structures Essentials for Efficient Organization and Retrieval"
dhruvpatel5224
 
PDF
From Campus to City: The Kiwibot Growth Timeline (2017–2025)
ricky228571
 
How Howard Wilner of Sudbury, MA Helps Leaders Align Personal Values with Pro...
jimcarns
 
AIMS OBJECTIVES ajjsjsjsjejejejejejejejejj
IsaacAntwi15
 
Selection and Retentionhsiwisjjeuwjfdwws
FahadBinImtiaz
 
Database management system is manager data
thakormitul730
 
1.02 Ramesh Pinjani - Important Track Design Parameters.pptx
abheeplay
 
PROPOSAL RESEARCH METHODOLOGY-1lssskkskes
IsaacAntwi15
 
PC450LC-8R KOMATSU HYDRAULIC EXCAVATOR PARTS MANUAL SN 75001-UP
Heavy Equipment Manual
 
Evis Kola on How to Maximize Your Layover Turning Airport Time into Mini Adve...
Evis Kola
 
PC160LC-7K-KA KOMATSU CRAWLER EXCAVATOR PARTS MANUAL SN K40001-UP
Heavy Equipment Manual
 
Soffit_Panel_India_Presentation.pptx____
interviewquestion6
 
PC160LC-7K-KA KOMATSU CRAWLER EXCAVATOR PARTS MANUAL K40001-UP
Heavy Equipment Manual
 
Transform Your Lexus for the Trails with Expert Off-Road Customization Services
MW4 Outfitters
 
NCHRP Report 672 Roundabouts: An Informational Guide
Forklift Trucks in Minnesota
 
Reliable Solutions for Maserati Battery, Wiring, and Electronics Problems You...
Kruse Lucas Imports
 
Presentation1.pptxiiiiiiiiiiiiiiiiiiiiiiii
gillprabhjot1212
 
Operational Risk and its importance an d
icuphamid
 
INTRODUCTION TO HUMAN RESOURCE MANAGEMEN
FahadBinImtiaz
 
Have 10 Thousand Dollars Lying Around? You Can Buy Any One Of These Project Cars
jennifermiller8137
 
"Data Structures Essentials for Efficient Organization and Retrieval"
dhruvpatel5224
 
From Campus to City: The Kiwibot Growth Timeline (2017–2025)
ricky228571
 
Ad

Chapter07_ds.ppt

  • 2. 2 Agenda • Discuss the principal requirements for memory management. • Understand the reason for memory partitioning and explain the various techniques that are used. • Understand and explain the concept of paging. • Understand and explain the concept of segmentation. • Assess the relative advantages of paging and segmentation. • Summarize key security issues related to memory management. • Describe the concepts of loading and linking.
  • 3. 3 Memory Management • What??? – Uniprogramming System Vs Multiprogramming System • Subdividing user part of memory to accommodate multiple processes dymamically. • Why??? • Memory needs to be allocated to ensure a reasonable supply of ready processes to consume available processor time
  • 4. 4 Memory Management Requirements • Purpose???? – The requirements that memory management is intended to satisfy • Relocation – Programmer does not know where the program will be placed in memory when it is executed – While the program is executing, it may be swapped to disk and returned to main memory at a different location (relocated) – Memory references must be translated in the code to actual physical memory address
  • 5. 5
  • 6. 6 Memory Management Requirements • Protection – Processes should not be able to reference memory locations in another process without permission – Impossible to check absolute addresses at compile time – Must be checked at run time – Memory protection requirement must be satisfied by the processor (hardware) rather than the operating system (software) • Operating system cannot anticipate all of the memory references a program will make
  • 7. 7 • Sharing – Allow several processes to access the same portion of memory – To allow each process access to the same copy of the program rather than have their own separate copy Memory Management Requirements
  • 8. 8 • Logical Organization – main memory in a computer system is organized as a linear 1D address space consisting of a sequence of bytes or words. – Programs are written in modules – Modules can be written and compiled independently – Different degrees of protection given to modules (read-only, execute-only) – Share modules among processes Memory Management Requirements
  • 9. 9 • Physical Organization – Memory available for a program plus its data may be insufficient • Overlaying allows various modules to be assigned the same region of memory – Programmer does not know how much space will be available – The task of moving information between the two levels of memory should be a system responsibility Memory Management Requirements
  • 10. Essence of memory management. – The task of moving information between the two levels of memory should be a system responsibility Not Programmer’s 10 Memory Management Requirements
  • 11. Principle responsibility of memory management – To bring processes into main memory for execution by the processor to ensure the sufficient no. of ready processes. 11 Memory Management Requirements
  • 12. 12 Memory Partitioning: Fixed Partitioning • Equal-size partitions – Any process whose size is less than or equal to the partition size can be loaded into an available partition – If all partitions are full, the operating system can swap a process out of a partition – A program may not fit in a partition. The programmer must design the program with overlays
  • 13. 13 Fixed Partitioning • Main memory use is inefficient. Any program, no matter how small, occupies an entire partition. This is called internal fragmentation. • A program may not fit in a partition. It become programmers headache to write the program in overlayed form.
  • 14. 14
  • 15. 15 Placement Algorithm with Partitions • Equal-size partitions – Because all partitions are of equal size, it does not matter which partition is used • Unequal-size partitions – Can assign each process to the smallest partition within which it will fit – Queue for each partition – Processes are assigned in such a way as to minimize wasted memory within a partition
  • 16. 16
  • 17. 17 Dynamic Partitioning • Partitions are of variable length and number • Process is allocated exactly as much memory as required • Eventually get holes in the memory. This is called external fragmentation • Must use compaction to shift processes so they are contiguous and all free memory is in one block
  • 18. 18
  • 19. 19 Dynamic Partitioning Placement Algorithm • Operating system must decide which free block to allocate to a process • Best-fit algorithm – Chooses the block that is closest in size to the request – Worst performer overall – Since smallest block is found for process, the smallest amount of fragmentation is left – Memory compaction must be done more often
  • 20. 20 Dynamic Partitioning Placement Algorithm • First-fit algorithm – Scans memory form the beginning and chooses the first available block that is large enough – Fastest – May have many process loaded in the front end of memory that must be searched over when trying to find a free block
  • 21. 21 Dynamic Partitioning Placement Algorithm • Next-fit – Scans memory from the location of the last placement – More often allocate a block of memory at the end of memory where the largest block is found – The largest block of memory is broken up into smaller blocks – Compaction is required to obtain a large block at the end of memory
  • 22. 22
  • 23. 23 Buddy System • Both fixed and dynamic partitioning schemes have drawbacks. – A fixed partitioning scheme limits the number of active processes – May use space inefficiently if there is a poor match between available partition sizes and process sizes. – A dynamic partitioning scheme is more complex to maintain – Also includes the overhead of compaction.
  • 24. 24 Buddy System • Memory blocks are available of size 2K words, L<= K<= U • 2L smallest size block that is allocated • 2U largest size block that is allocated; generally 2U is the size of the entire memory available for allocation. • Initially, • Entire space available is treated as a single block of 2U • If a request of size s such that 2U-1 < s <= 2U, entire block is allocated – Otherwise block is split into two equal buddies – Process continues until smallest block greater than or equal to s is generated.
  • 25. 25
  • 26. 26
  • 27. 27 Buddy Systems • Application of Buddy systems: – In parallel systems as an efficient means of allocation and release for parallel programs. • A modified form of the buddy system is used for UNIX kernel memory allocation
  • 28. 28 What next???? • Ways of dealing with the shortcomings of partitioning let it be any – Fixed • Equal sized • Unequal sized – Dynamic – Buddy
  • 29. 29 What next???? • A process may occupy different partitions during the course of its life. • When a process image is first created, it is loaded into some partition in main memory. • The process may be swapped out; • When it is subsequently swapped back in, it may be assigned to a different partition than the last time.
  • 30. 30 Relocation • When program loaded into memory the actual (absolute) memory locations are determined. • A process may occupy different partitions which means different absolute memory locations during execution (from swapping) • Compaction will also cause a program to occupy a different partition which means different absolute memory locations.
  • 31. 31 Addresses • A distinction is made among several types of addresses. • Logical – Reference to a memory location independent of the current assignment of data to memory – Translation must be made to the physical address • Relative – Address expressed as a location relative to some known point (Type of logical address) • Physical – The absolute address or actual location in main memory
  • 32. 32 Registers Used during Execution • Base register – Starting address for the process • Bounds register – Ending location of the process • These values are set when the process is loaded/updated or when the process is swapped in.
  • 33. 33 Typically, all of the memory references in the loaded process are relative to the origin of the program
  • 34. 34 Process of Relocation • The value of the base register is added to a relative address to produce an absolute address. • The resulting address is compared with the value in the bounds register. • If the address is not within bounds, an interrupt is generated to the operating system
  • 35. 35 Small exercise • Consider a fixed partitioning scheme with equal-size partitions of 2^16 bytes and a total main memory size of 2^24 bytes. A process table is maintained that includes a pointer to a partition for each resident process. How many bits are required for the pointer?
  • 36. 36 Paging: • Partition memory into small equal fixed-size chunks and divide each process into the same size chunks • The chunks of a process are called pages and chunks of memory are called frames • Operating system maintains a page table for each process – Contains the frame location for each page in the process – Memory address consist of a page number and offset within the page
  • 37. 37 Assignment of Process Pages to Free Frames
  • 38. 38 Assignment of Process Pages to Free Frames
  • 40. 40 Segmentation • All segments of all programs do not have to be of the same length • There is a maximum segment length • Addressing consist of two parts - a segment number and an offset • Since segments are not equal, segmentation is similar to dynamic partitioning
  • 41. 41
  • 42. 42
  • 43. 43
  • 44. 44
  • 45. Let us do : A 1-Mbyte block of memory is allocated using the buddy system. a. Show the results of the following sequence in a figure Request 70; Request 35; Request 80; Return A; Request 60; Return B; Return D; Return C. b. Show the binary tree representation following Return B. 45
  • 46. Let us do : (For chapter 8) Consider a simple paging system with the following parameters: 2^32 bytes of physical memory; page size of 2^10 bytes; 2^16 pages of logical address space. a. How many bits are in a logical address? b. How many bytes in a frame? c. How many bits in the physical address specify the frame? d. How many entries in the page table? e. How many bits in each page table entry? 46
  • 47. • Physical: 232 • Page Size: 210 • Number of Pages: 216 • How many bits in a logical address? That's the page address bits plus the number of pages bits. The upper portion of an address is the page number (16 bits), and the lower portion is the offset within that address (10 bits), so the whole address size is 26 bits (1026 bytes). 47
  • 48. • Physical: 232 • Page Size: 210 • Number of Pages: 216How many bytes are in a frame? A frame is where a page can be mapped into memory, so a frame has to be the same size as a page - 210 bytes. • How many bits are in the physical address specifying the frame? Well, you have 32 bits of physical address, and a frame is 210 big, so that leaves 22 of the bits (32 - 10) for the frame's base address. 48
  • 49. • Physical: 232 • Page Size: 210 • How many entries in the page table? The page table is the full list of pages, whether mapped or unmapped - so there are 216 entries in the page table, since there are 216 pages. 49
  • 50. • Physical: 232 • Page Size: 210 • How many bits in each page table entry? Assume each page table entry contains a valid/invalid bit. If each page maps to an entry in the page table, and that table is a list of the addresses at which the pages are mapped in physical memory, then each address in the table must be the size of answer 3 (22 bits) plus one bit for the valid/invalid bit, so 23 bits. 50