GC

OS 2

COB231 - Operating Systems, Networks and the Internet 1

  • Lecture 3, 4: Memory Management

  • Institution: Loughborough University #InspiringWinners since 1909

Quick Review of Last Week

  • Operating Systems (OS) within computer system structure

  • Sharing and protection of system resources

  • Objectives of Operating Systems

  • Established concepts:

    • Multiprogramming and multitasking

    • Multi-state processor technology

    • Interrupts

    • System calls

Lecture Outline

  • Memory Management Techniques: • Base-limit addressing • Segmentation • Paging

Memory Sharing

  • General-purpose computers utilize rewritable main memory, known as RAM.

  • Limited main memory requires sharing by users and applications.

  • Protection: One application must not alter another application's data without authorization.

  • Focus: Various strategies for effective memory management will be discussed today.

Memory Management Introduction

  • Main memory is typically the only storage device directly addressed by the CPU.

  • Most data and instructions reside on slower hard disks.

  • The OS transfers data from hard disk to main memory to facilitate processing.

  • Multiple processes can reside in main memory simultaneously.

Program Management in Memory

  • Programs exist on disks as binary executable files and must load into RAM for execution.

  • Loaded programs aren’t always at memory location zero due to dynamic relocation management.

Virtual and Real Addressing

  • Programs reside in a specific memory segment (shown as sharing in RAM).

  • Each program’s memory section consists of instructions and data.

  • Concept of virtual addresses (logical addresses) is utilized for program execution.

  • Real addresses (physical addresses) are mapped using dynamic addressing schemes.

Base-Limit Addressing

  • Each program has a defined separate space with restricted accessible addresses.

  • Two values define memory access:

    • Base value: smallest legal real address for a program

    • Limit value: size of memory assigned to that program

  • Example explained visually, showing base and limit values for various programs.

Memory Management Unit (MMU)

  • The MMU executes real-time mapping of virtual to physical addresses.

  • It checks memory accesses for validity regarding a program's memory bounds.

Memory Allocation Strategies

  • Strategies employed in memory management:

    • First Fit

    • Best Fit

    • Worst Fit

  • Primary goal: Efficiently align newer programs with available free memory sections.

Compaction Strategy

  • Compaction or shuffling combats fragmented memory blocks, promoting effective storage utilization.

  • Identifiable fragmentation occurs when programs create numerous small gaps in memory.

Swapping Mechanism

  • Swapping out is utilized to temporarily remove programs from RAM to create space in memory.

  • Existence of a backing store (such as hard disks) helps facilitate swapping.

Segmentation Overview

  • A program may be logically split into various segments representing collections of data.

  • Characteristics include:

    • Logical units (registers, main functions)

    • Virtual and physical memory interactions managed through segment tables.

Paging Overview

  • Paging splits the program into fixed-size pages that map physical frames in memory.

  • Paging contrasts segmentation; pages are not logically defined.

  • No external fragmentation occurs, and every page fits perfectly within any frame.

Final Summary on Memory Management

  • Key elements discussed include: • Base-limit addressing • Memory allocation strategies • Compaction, Swapping • Segmentation and Paging mechanics

Homework

  • Prepare using:

    • Lecture notes

    • Relevant textbook sections

    • Tutorial questions for feedback session.