0Pricing
Assembly Language & x86 Low-Level Systems Programming · درس

الت分页 ووحدة إدارة الذاكرة (MMU)

افهم كيفية تحويل وحدة إدارة الذاكرة MMU في x86 للعناوين الافتراضية إلى عناوين فعلية باستخدام جداول الصفحات وأدلة الصفحات.

الت分页 ووحدة إدارة الذاكرة (MMU) درس مجاني في Assembly Language & x86 Low-Level Systems Programming على CoddyKit. هذا هو الدرس 1 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Assembly Language & x86 Low-Level Systems Programming، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Assembly Language & x86 Low-Level Systems Programming 4 دروس في المجموع.

بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.

What is Paging?

Welcome! Today we'll explore Paging, a crucial memory management technique in x86 systems. It's how your computer handles memory safely and efficiently.

Paging allows programs to think they have a huge, continuous block of memory, even if the physical RAM is fragmented or smaller than what the program needs.

Virtual vs. Physical Address

When a program runs, it uses virtual addresses. These are logical addresses that the program 'sees' and uses to refer to data and instructions.

However, the CPU and actual RAM hardware use physical addresses. Paging is the system that translates virtual addresses into physical addresses.

The MMU's Role

The translation from virtual to physical addresses is handled by a special hardware component inside the CPU called the Memory Management Unit (MMU).

The MMU acts like a super-fast translator, ensuring that every memory access from a program goes to the correct physical location in RAM, or signals an error if it's an invalid access.

Pages and Page Frames

For paging to work, memory is divided into fixed-size blocks:

  • Pages: These are the blocks of virtual memory that a program sees.
  • Page Frames: These are the blocks of physical memory (RAM).

On x86 systems, a common page size is 4 Kilobytes (4KB). The MMU translates virtual pages to physical page frames.

Introducing Page Tables

How does the MMU know which virtual page maps to which physical page frame? It uses data structures called page tables.

A page table is essentially an array where each entry maps a virtual page number to its corresponding physical page frame address. Each running process has its own set of page tables.

Multi-Level Paging: Page Directories

For very large virtual address spaces (like 32-bit or 64-bit systems), a single page table would be enormous. To manage this, x86 uses a multi-level paging hierarchy.

The first level is the Page Directory. It doesn't point directly to page frames, but to other Page Tables. These secondary tables then point to the actual physical page frames.

The Address Translation Process

Let's simplify the 32-bit address translation process:

  1. The CPU generates a virtual address.
  2. The MMU uses the upper bits of this address to find an entry in the Page Directory.
  3. That entry points to a specific Page Table.
  4. The MMU uses middle bits of the virtual address to find an entry in that Page Table.
  5. This entry contains the physical address of the Page Frame.
  6. The lower bits of the original virtual address (the offset) are added to the page frame address to get the final physical address.

CR3: The Paging Root

How does the MMU know where the Page Directory is for the current process?

The CPU has a special control register called CR3. This register holds the physical address of the current Page Directory Base Register (PDBR). It tells the MMU exactly where to start looking for the page directory.

PTE Flags and Permissions

Each entry in a Page Table (a PTE - Page Table Entry) contains more than just the physical address. It also has various flags:

  • Present: Is the page currently in physical memory?
  • Read/Write: Can the page be written to?
  • User/Supervisor: Can user-mode programs access this page?
  • Accessed: Has the page been accessed recently?
  • Dirty: Has the page been written to since it was loaded?

These flags are vital for memory protection and virtualization.

Benefits of Paging

Paging is fundamental to modern operating systems due to its many benefits:

  • Memory Protection: Isolates processes, preventing them from corrupting each other's memory.
  • Virtual Memory: Allows programs to use more memory than physically available by swapping pages to disk.
  • Memory Sharing: Multiple processes can share the same physical pages (e.g., for shared libraries or inter-process communication).
  • Relocation: Programs can be loaded anywhere in physical memory; the MMU handles the mapping.

Paging Knowledge Check

Which of the following best describes the primary function of the Memory Management Unit (MMU) in an x86 system?

Paging & MMU Recap

Great job! You've learned about the critical role of Paging and the MMU.

  • Programs use virtual addresses, while hardware uses physical addresses.
  • The MMU translates these addresses using Page Directories and Page Tables.
  • Memory is divided into pages (virtual) and page frames (physical).
  • The CR3 register points to the current Page Directory.
  • PTE flags control permissions and page status.

This system provides essential memory protection, virtual memory, and flexible memory management for all modern operating systems.

الأسئلة الشائعة

هل درس «الت分页 ووحدة إدارة الذاكرة (MMU)» مجاني؟

نعم — نص درس «الت分页 ووحدة إدارة الذاكرة (MMU)» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Assembly Language & x86 Low-Level Systems Programming، انتقل إلى CoddyKit PRO. تتضمن دورة Assembly Language & x86 Low-Level Systems Programming 4 دروس في المجموع.

ماذا ستتعلم في «الت分页 ووحدة إدارة الذاكرة (MMU)»؟

افهم كيفية تحويل وحدة إدارة الذاكرة MMU في x86 للعناوين الافتراضية إلى عناوين فعلية باستخدام جداول الصفحات وأدلة الصفحات. تتمرن على Assembly Language & x86 Low-Level Systems Programming مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.

هل أحتاج إلى خبرة سابقة لأبدأ Assembly Language & x86 Low-Level Systems Programming؟

لا تُشترط خبرة سابقة. Assembly Language & x86 Low-Level Systems Programming على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 1 من أصل 4.

كم من الوقت يستغرق درس «الت分页 ووحدة إدارة الذاكرة (MMU)»؟

معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.

هل يمكنني كتابة وتشغيل أكواد في درس Assembly Language & x86 Low-Level Systems Programming هذا؟

نعم. كل درس في Assembly Language & x86 Low-Level Systems Programming يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.

جميع الدروس في هذه الدورة

  1. الت分页 ووحدة إدارة الذاكرة (MMU)
  2. حلقات الحماية والامتيازات
  3. أساسيات برامج مراقبة الأجهزة والافتراضية
  4. التقسيم وجدول الواصفات العام (GDT)
← العودة إلى Assembly Language & x86 Low-Level Systems Programming