83% found this document useful (6 votes)
4K views9 pages

Base and Limit Registers in OS Memory Management

The document discusses various memory management concepts including base and limit registers, address binding stages, logical vs physical addresses, the memory management unit (MMU), memory mapping schemes like paging and segmentation, and types of memory allocation and fragmentation. It provides details on how paging and segmentation work using page tables and segment tables to map logical to physical addresses.

Uploaded by

Gaby Mbugua
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
83% found this document useful (6 votes)
4K views9 pages

Base and Limit Registers in OS Memory Management

The document discusses various memory management concepts including base and limit registers, address binding stages, logical vs physical addresses, the memory management unit (MMU), memory mapping schemes like paging and segmentation, and types of memory allocation and fragmentation. It provides details on how paging and segmentation work using page tables and segment tables to map logical to physical addresses.

Uploaded by

Gaby Mbugua
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
  • Address Binding
  • Base Register and Limit Register
  • Memory Addresses and Memory Management Unit
  • Memory Management and Protection
  • Contiguous Memory Allocation Schemes
  • Fragmentation in Memory
  • Paging
  • Page Table and Segmentation
  • Types of Memory and Virtual Memory

What is the Base register and what is the Limit register?

 Base register: Specifies the smallest legal physical memory address.


 Limit register: Specifies the size of the range.
 A pair of base and limit registers specifies the logical address space.
 The base and limit registers can be loaded only by the operating
system.
 Ex: If the base register holds 300040 and the limit register is 120900,
then the program can legally access all addresses from 300040
through 420939 (inclusive).

What are the different stages in which address binding can


occur?
Address binding can occur at three different stages:

 Compile Time: if you know at compile time where the process will
reside in memory, then absolute code can be generated.
 Load Time: if it is not know at compile time where the process will
reside in memory, then the compiler must generate relocatable code
and the final binding is delayed until the load time.

1
 Execution Time: if the process can be moved during its execution
from one memory segment to another, then binding must be delayed
until run time.

What are the Logical memory address and the Physical


memory address?
 Logical Memory Address: Addresses generated by the CPU.
 Physical Memory Address: Addresses seen by the memory unit.
 Logical and Physical addresses are the same compile-time and load-
time address binding schemes, and differ in the execution-time
address-binding scheme.

What is the Memory Management Unit (MMU)?


 Memory Management Unit (MMU): It is a hardware device that
maps the logical address to physical address.
 The value in the MMU relocation register is added to every logical
address generated by the CPU to be mapped into a physical memory
address.

2
What are the different memory management schemes?
Memory management schemes:

 Contiguous Memory Allocation.


 Non-Contiguous Memory Allocation.

Discuss the Memory mapping and protection issue?


Memory mapping and protection issue:

 The main memory is divided into 2 partitions OS space, and user


space.
 The OS space along with the interrupt vector resides in low memory,
and the user pace resides in high memory.
 We need to protect the OS space from mistakenly accessed.
 We do this by using relocation register together with limit register.
 The relocation register contains the value of the smallest physical
address, and the limit register contains the range of logical address.
 The value of the logical address must be less than the value in the
limit register.

3
 MMU adds the value in the relocation register to the value in the limit
register and send this address to memory.

What are the different contiguous memory allocation schemes?


There are 3 different contiguous memory allocation schemes:

 Fixed-size Partitions: the simplest memory allocation schemes in


which the memory is partitioned into a set of fixed-length partitions
and each partition contains only one process.
 Multiple-partitions method: When a partition is free, a process is
selected from the input queue and loaded into the free partition, and
when the process terminates, the partition becomes free.
 Variable-size partitions: Holes of various sizes are scattered through
memory, and when a process arrives it is allocated memory from a
hole large enough to accommodate it. The OS maintains information
about the allocated partitions and the free partitions.

How to solve the problem of dynamic storage allocation?


To satisfy a request of size n from a list of free holes, we use one of the
following strategies:

 First-Fit: Allocate the process to the first big enough hole.

4
 Best-Fit: Allocate the process to the smallest hole that is big enough
to accommodate the process. The must search the entire list unless
ordered by size and produce the smallest leftover hole.
 Worst-Fit: Allocate the process to the largest hole. The must search
the entire list unless ordered by size and produce the largest leftover
hole.

What are types of fragmentation?


Fragmentation can be one of the following:

 External Fragmentation: Total memory space exists to satisfy a


request but is not contiguous. Resulted from best-fit and first-fit.
 Internal Fragmentation: Allocated memory may be slightly larger
than the required memory resulted in a size difference that is memory
internal to a partition but is not used.
 The general approach to avoiding external fragmentation is to break
the physical memory into fixed-sized blocks and allocate memory in
units based on block size.

How to reduce the external fragmentation?


To reduce the external fragmentation by:

 Compaction: Shuffle memory contents to place all free memory


together in one large block. It is possible only if relocation is dynamic,
and is done at execution time.
 Another possible solution: paging and segmentation.

What are the types of Non-contiguous Memory allocation?


Non-Contiguous Memory Allocation:

 Paging.
 Segments.
 Segments with paging.

5
What is paging?
 Paging: It is a memory management scheme that permits the physical
address space of a process to be non-contiguous.
 Divides the physical memory into fixed-length blocks called frames
and each frame size is of power 2 from 512 bytes to 16 Mbytes
 Divides the logical memory into blocks of same size called pages.
 Each address generated by the CPU is divided into two parts:
- Page # (p): It is used as an index to a page table which contains
the base address of each page in physical memory.
- Page Offset (d): Combined with base address to define the
physical memory address that is sent to the memory unit.

Logical address generated by the CPU

Paging Hardware

6
Mapping logical address into physical address

What is a page table? And how is it implemented?


 Page Table: a portion of main memory that maps the page number of
a process into its physical frame in memory.
 It is implemented as follows:
- Page Table Base Register (PTBR) points to the page table.
- Page Table Length Register (PTLR) indicates the size of page
table.
 In this scheme every data/instruction access requires two memory
accesses. One for the page table and one for the data/instruction.

What is segmentation?
 Segmentation: Memory-management scheme that supports user view
of memory.
 A program is a collection of segments.
 A segment is logical unit such as (main program, procedure, method,
object, local variables, global variables, common block …).
 Logical address consists of a two tuple <segment-number, offset>.

7
Logical view of segmentation
What is the segment table? And how is it implemented?
 Segment Table: maps two-dimensional physical addresses; each table
entry has:
- Base: contains the starting physical address where the segments
reside in memory.
- Limit: specifies the length of the segment.
 It is implemented as:
- Segment Table Base Register (STBR): points to the segment
table’s location in memory.
- Segment Table Length Register (STLR): indicates the number of
segments used by a program.

8
Segmentation Hardware
What are the types of memory?
Memory types:

 Real Memory: Main Memory.


 Virtual Memory: Memory on disk.

What is a virtual memory?


 Virtual Memory: Involves separation of user logical memory from
physical memory.
 Simulating more random access memory (RAM) than actually exists,
allowing the computer to run larger programs and multiple programs
concurrently.
 A common function in most every OS and hardware platform, virtual
memory uses the hard disk to temporarily hold what was in real
memory.
 It can be implemented as:
- Demand paging.
- Demand segmentation.

1 
What is the Base register and what is the Limit register? 
 Base register: Specifies the smallest legal physical memory
2 
 Execution Time: if the process can be moved during its execution 
from one memory segment to another, then binding mus
3 
 
 
 
 
 
 
 
 
 
 
What are the different memory management schemes? 
Memory management schemes: 
 Contiguous Memory A
4 
 MMU adds the value in the relocation register to the value in the limit 
register and send this address to memory.
5 
 Best-Fit: Allocate the process to the smallest hole that is big enough 
to accommodate the process. The must search th
6 
What is paging? 
 Paging: It is a memory management scheme that permits the physical 
address space of a process to be
7 
 
 
 
 
 
 
 
 
 
Mapping logical address into physical address 
What is a page table? And how is it implemented? 
 Pag
8 
 
 
 
 
 
 
 
 
Logical view of segmentation 
What is the segment table? And how is it implemented? 
 Segment Table: ma
9 
 
 
 
 
 
 
 
 
 
Segmentation Hardware 
What are the types of memory? 
Memory types: 
 Real Memory: Main Memory. 
 Vi

You might also like