Once needs to understand Program Compilation and the concept of Dynamic Loading to understand

Hierarchy

  • Registers

  • Cache

    • Sits between main memory and CPU registers
  • Main Memory

  • Secondary Memory

Memory Manager

Part of OS that manages the memory hierarchy†

  • Relocation

    • Assigning new memory block to the process when it is comes back into the Ready State after being suspended
  • Protection

    • A process is only allowed to access it’s memory space

      • This is ensured by using the Base and Limit Register. If the requesting memory block address of the program is >​ the Base Register and <​ the Limit Register, only then is the block allowed to access that memory block
  • Sharing

  • Physical Memory Organisation

We use Base Register and Limit Register to keep track of the memory partitions

We use Hardware Based Solutions to avoid Critical Section Problems

Base Register

Keeps track of the starting address of the partition / block in the memory

Limit Register

Keeps track of the size / limit of the partition / block in the memory

Fixed Sized Partitioning

Cons

Internal Fragmentation

The Fixed Sizes when allocated lesser sized processes, have some space left which might be too small to be used by any other upcoming process

Solutions

Non-Continuous Memory Allocation

Variable Sized Partitioning

Cons

External Fragmentation

The size of the partitions might break down too small for larger upcoming programs to fit in

Solutions

Compaction

We can move our being used memory blocks to the other part of the memory, this can give us free sized blocks combined on the other part of the memory

Coalescing Holes

We can combine multiple neighbouring holes to create space for the larger program to fit

Paging

​Each process is divided into the same count of blocks / frames as the memory is divided into

image

Address Allocation Scheme

We have a Page Number of and a Page Offset which tells us where the designated byte (block of the process we require) is stored

Page Number:

Page Number tells us the designed divided page assigned to the the byte we seek

Page Offset:

Page Offset tells us the starting address of the page in the Page Table

Page Table

This table stores the addresses of the pages (from where they start)

Paging Model of Logical and Physical Memory
Adress TypeMemory SegmentOrigin
Logical AddressPageProcess
Physical AddressFrameMain Memory
Virtual AddressBlockSecondary Memory

Frame and Block sizes will be same for the Paging Model

Numerical Example:

Page Size = Displacements = Offsets = 8 Bytes

No of Pages = 4

Process Size = Page Size x No of Pages = 8 x 4 = 32

Byte RepresentationPage #D0D1D2D3D4D5D6D7
00001234567
01189101112131415
1021617181920212223
1132425262728293031

D Represents Displacement

Logical Address

Page Number (Bits)Displacement Number (Bits)

Max Pages in a Process’s Address Space:

or

Page Table Size:

where PTES is the page table entry size, the size in bits which store the frame number out of total frames in the Main Memory

PTES can be calculated by dividing the bits of Frame Number by 8 (Converting it into Bytes)

Physical Address

Frame Number (Bits)Displacement Number (Bits)

The displacement number is same as in the case of Logical Address

Frame Size = 8 Bytes

No of Frames = 8

Size of Main Memory = 8 x 8 = 64 Bytes

Frame #D0D1D2D3D4D5D6D7
001234567
189101112131415
21617181920212223
32425262728293031

Roles of Bitmaps

Memory is divided into allocation units and each unit is expressed with a bit

If a bit is 1​ it represents that the space is occupied while a 0​ tell that this is a hole

  • Size of allocation unit is important

    • Smaller Bitmap Unit

      • Larger bitmap required
    • Larger Bitmap Unit

      • Smaller bitmap required

Allocation units can be in:

  • Words
  • Several Kilobytes

Roles of Linked Lists

Each Node represents a process and a hole. In this way we can find holes within our Linked List

A Node not only stores the the state of the block (process or a hole), it also tells us the:

  • Size of the Block
  • Starting Address
  • Ending Address

Resources

Paging in Operating System | Geeks for Geek