How memory manages data

2025. 7. 27. 21:36·Computer Science/Operating System

 

One of the key roles of an operating system is memory management.

It must maximize the use of limited memory resources inside the computer.


Virtual Memory

Virtual memory is a memory management technique that

abstracts the actual physical memory resources available on a computer

and makes it appear as a very large memory to the users.

 

 

  • The virtual addresses given are called virtual addresses (logical addresses),
  • while the addresses physically present in memory are called physical addresses.
  • Virtual addresses are translated to physical addresses by the Memory Management Unit (MMU),
  • which allows users to develop programs without needing to be aware of the physical addresses.
  • Virtual memory is managed through a page table that maps virtual addresses to physical addresses and contains the address information of processes.

 

 

More about Virtual Memory – Reasons for Use, Pros and Cons

더보기

Virtual memory is a technology in computer systems that expands the capacity of the actual physical memory (RAM). This allows the computer to keep and process data larger than the physical memory. Virtual memory works by using a portion of the disk space as if it were additional memory.

 

Why Use Virtual Memory?

  1. Efficient Memory Usage - Although the actual physical memory (RAM) size is limited, virtual memory provides a larger memory space by using disk space, allowing programs to operate as if they have more memory.
  2. Process Isolation - Each process uses its own virtual memory space, preventing one process from accessing or corrupting another process’s memory.
  3. Support for Multitasking - When multiple programs run simultaneously, virtual memory allows each program to behave as if it has sufficient memory, effectively supporting multitasking.
  4. Running Large Programs - Even when physical memory is insufficient, virtual memory enables running larger programs or handling large-scale data tasks.

Advantages

  1. Solves Memory Shortage - Programs can continue to run without interruption by using part of the disk as memory when physical memory is low.
  2. Improves Multitasking - Prevents memory conflicts among programs running simultaneously and allocates resources efficiently.
  3. Enhances Safety and Security - Since each process has its own virtual memory space, interference between processes is prevented, increasing system stability.
  4. Improves System Performance - Less frequently used memory areas can be paged out to disk, freeing up more memory for active data.

Disadvantages

  1. Speed Degradation - Because virtual memory uses the disk, it is slower than RAM. Frequent disk access can cause performance drops (swapping).
  2. Disk Space Usage - Using disk as memory consumes significant disk space.
  3. Increased Complexity - Managing virtual memory requires additional system resources such as page replacement algorithms and page tables, making system management more complex.

Summary

Virtual memory is a technique that extends physical memory, enhancing system efficiency and enabling large program execution. However, it has downsides like speed degradation and excessive disk space usage.

 

Swapping

When accessing data or code that exists in virtual memory but is not currently in physical memory (RAM), a *page fault occurs.

At this point, the OS moves unused areas of memory to the hard disk and loads the required part of the disk into memory as if it were RAM — this process is called swapping.


*Page Fault

A page fault occurs when a process tries to access data that exists in its virtual address space but is not currently loaded in the computer’s RAM.


Page Fault and the Resulting Swapping

  1. The CPU checks physical memory and, if the page is missing, triggers a trap (software interrupt) to notify the OS.
  2. The OS pauses the CPU.
  3. The OS checks the page table to see if the page exists in virtual memory.
    •   If it does not exist, the process is terminated.
    •   If it exists but no free frame is available in physical memory, swapping is triggered.
  4. The page is loaded into a free frame in physical memory, and the page table is updated.
  5. The CPU resumes its operation.

Page: The smallest unit of virtual memory.

Frame: The smallest unit of physical memory.


Thrashing

Thrashing refers to a state where the page fault rate is very high, severely degrading the system’s performance.


Memory Allocation

When allocating memory to a program, the OS determines the starting memory location and allocation size.

This can be done using two methods: contiguous allocation and non-contiguous allocation.

  • Contiguous Allocation - Allocates memory in one continuous block.
  • Non-contiguous Allocation - This is the method used by modern operating systems, with various techniques for efficient non-contiguous allocation. Allocates memory in scattered blocks rather than continuously.

 

 

'Computer Science > Operating System' 카테고리의 다른 글

PCB & Context Switching  (0) 2025.08.03
Process  (0) 2025.07.30
Memory  (0) 2025.07.25
Components of a computer  (0) 2025.07.22
Structure of the Operating System  (0) 2025.07.19
'Computer Science/Operating System' 카테고리의 다른 글
  • PCB & Context Switching
  • Process
  • Memory
  • Components of a computer
JTB
JTB
웹/앱 개발 정보를 공유하고 있습니다.
  • JTB
    JTechBlog
    JTB
  • 전체
    오늘
    어제
    • All About Programming;) N
      • Computer Science
        • Terminology and Concepts
        • Network
        • Operating System
        • Database
        • Data Structure
      • Frontend
        • Javascript Essentials
        • Perfomance Optimization
        • JS Patterns
        • Next.js
        • Flutter
      • Backend
        • Node.js
      • DevOps
        • Docker & Kubernetes
      • Coding Test N
        • LeetCode N
        • Programmers
      • Tech Books & Lectures
        • Javascript_Modern JS Deep d..
        • Network_IT 엔지니어를 위한 네트워크 입문
      • Projects
        • PolyLingo_2025
        • Build Your Body_2024
        • JStargram_2021
        • Covid19 Tracker_2021
        • JPortfolio_2021
      • BootCamp_Codestates
        • TIL
        • TILookCloser
        • Pre Tech Blog
        • IM Tech Blog
        • Daily Issues and DeBugging
        • First Project
        • Final Project
        • Sprint Review
        • Good to Know
        • Socrative Review
        • HTML & CSS
  • 블로그 메뉴

    • 홈
    • 태그
    • 방명록
  • 링크

    • 글쓰기
    • 관리
  • 공지사항

  • 인기 글

  • 태그

    need a database
    자바스크립트
    testing
    자바스크립트 딥다이브
    leetcode
    structure of os
    VoiceJournal
    DOM
    Data Structure
    이벤트
    Binary Tree BFS
    모던 자바스크립트 Deep Dive
    커리어
    딥다이브
    Network
    프론트엔드 성능 최적화 가이드
    Time complexity and Space complexity
    js pattern
    JavaScript
    스코프
    indie hacker
    Threads and Multithreading
    Shared resources
    database
    polylingo
    mobile app
    CPU scheduling algorithm
    How memory manage data
    Operating System
    TCP/IP
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.5
JTB
How memory manages data
상단으로

티스토리툴바