Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Memory Management(2)

Non-Contiguous Allocation
• In non-contiguous memory allocation, different parts of a process is allocated different places in
Main Memory.
• Paging and Segmentation are the two ways which allow a process’s physical address space to be
non-contiguous. It has advantage of reducing memory wastage but it increases the overheads due to
address translation. It slows the execution of the memory because time is consumed in address
translation.
‫تخصيص غير متجاور‬
.‫ يتم تخصيص أماكن مختلفة ألجزاء مختلفة من العملية في الذاكرة الرئيسية‬، ‫• في تخصيص الذاكرة غير المتجاورة‬
‫ تتميز بميزة تقليل الفاقد في الذاكرة ولكنها‬.‫• الترحيل والتجزئة هما طريقتان تسمحان لمساحة العنوان الفعلية للعملية بأن تكون غير متجاورة‬
.‫ يؤدي إلى إبطاء تنفيذ الذاكرة ألنه يتم استهالك الوقت في ترجمة العنوان‬.‫تزيد من النفقات العامة بسبب ترجمة العنوان‬

Paging
Paging is a memory management scheme that eliminates the need for contiguous allocation of
physical memory. Every process is divided into various parts of equal size called Pages. We also
divide our main memory into different parts of equal size called Frames. It is important to understand
that: Size of page in process = Size of frame in memory

‫الترحيل‬
‫ تنقسم كل عملية إلى أجزاء مختلفة متساوية الحجم تسمى‬.‫عبارة عن مخطط إلدارة الذاكرة يلغي الحاجة إلى التخصيص المتجاور للذاكرة الفعلية‬
.‫ نقسم أيضًا ذاكرتنا الرئيسية إلى أجزاء مختلفة متساوية الحجم تسمى اإلطارات‬.‫الصفحات‬
‫ حجم الصفحة قيد المعالجة = حجم اإلطار في الذاكرة‬:‫من المهم أن نفهم أن‬
Paging needs to maintain a Page Table for each process which contains the base address of the
each block which is acquired by the process in memory space. Paging is done to remove External
Fragmentation. Page table has page table entries where each page table entry stores a frame
number and optional status (like protection) bits. Many of status bits used in the virtual memory
system. The most important thing in PTE is frame Number.

Frame Number – gives the frame number in which the current page is present. The number of bits
required depends on the number of frames. Number of bits for frame = Size of physical
memory/frame size
Present/Absent bit – a bit is also known as valid/invalid bit. It says whether a particular page is
present or absent.

‫يحتاج الترحيل إلى االحتفاظ بجدول صفحات لكل عملية تحتوي على العنوان األساسي لكل كتلة يتم الحصول عليها من خالل العملية في مساحة‬
‫ يحتوي جدول الصفحة على إدخاالت لجدول الصفحات حيث يخزن كل إدخال في جدول‬.‫ يتم إجراء الترحيل إلزالة التجزئة الخارجية‬.‫الذاكرة‬
PTE ‫ أهم شيء في‬.‫ تستخدم العديد من وحدات بت الحالة في نظام الذاكرة الظاهرية‬.‫الصفحات رقم إطار وحالة اختيارية (مثل الحماية) بتات‬
.‫هو رقم اإلطار‬

‫ عدد وحدات‬.‫ يعتمد عدد البتات المطلوبة على عدد اإلطارات‬.‫ يعطي رقم اإلطار الذي توجد به الصفحة الحالية‬- ‫ رقم اإلطار‬Frame Number
‫ حجم اإلطار‬/ ‫البت لإلطار = حجم الذاكرة الفعلية‬
‫ تقول ما إذا كانت صفحة معينة موجودة أو‬.‫ غير صالح‬/ ‫ يُعرف البت أيضًا باسم بت صالح‬- ‫ الغائبة‬/ ‫ البتة الحالية‬Present/Absent bit
.‫غائبة‬
• Address Translation Scheme
• Address generated by CPU is divided into:
• Page number (p) – used as an index into a page table which contains 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.

‫• مخطط ترجمة العنوان‬


:‫• ينقسم العنوان الذي تم إنشاؤه بواسطة وحدة المعالجة المركزية إلى‬
‫ يُستخدم كفهرس في جدول الصفحات الذي يحتوي على العنوان األساسي لكل صفحة في الذاكرة‬: Page number (p) - ‫• رقم الصفحة‬
.‫الفعلية‬
.‫ مع العنوان األساسي لتحديد عنوان الذاكرة الفعلي الذي يتم إرساله إلى وحدة الذاكرة‬: Page offset (d) -‫• إزاحة الصفحة‬
Consider a paging system of a page size of 4 bytes,with a physical address space of 1024 byte. And
with a logical address space of 64 byte.
1. What is the page number and page offset of logical address 0 ?
2. What is the physical address of logical address 0?
3.What is the logical address corresponding to the physical address 27.
4. How many bits are needed to represent the logical address.
5. How many bits are needed to represent the physical address.

‫؟‬0 ‫ما هو رقم الصفحة وإزاحة الصفحة من العنوان المنطقي‬ .1


‫؟‬0 ‫ما هو العنوان الفعلي للعنوان المنطقي‬ .2
‫؟‬.27 ‫ما هو العنوان المنطقي المقابل للعنوان الفعلي‬ .3
‫كم عدد البتات الالزمة لتمثيل العنوان المنطقي‬ .4
.‫كم عدد البتات الالزمة لتمثيل العنوان الفعلي‬ .5
Sol:
1. page_number= logical_address Div page_size
= 0 Div 4 = 0
page_offset = logical_address Mod page_size
= 0 Mod 4 = 0
2. physical_address = (frame_number * page_size ) + page_offset
= (5 * 4 ) + 0 = 20.

3. frame_number = physical_address Div frame_size


=27 Div 4 =6

As we look for this frame number in the page table, we find that it corresponds to page number 1
. frame_offset = physical_address Mod frame_size
= 27 Mod 4 = 3 (page_offset)
Logical_address= (page_number * page_size) + page_offset
= (1 * 4) + 3 = 7
4. Logical address space = 64 byte = 2 6 byte Number of bits in logical address= Log2 2 6 =6 bits
5. Physical address space= 1024 byte= 2 10 Number of bits in physical address= Log2 2 10 = 10 bits

H.W.
For the system above:
1. What is the page number and the page offset for the logical address 11?
2. What is the physical address for he logical address 14?
3. What is the logical address corresponding to physical address 22?
H.W.
:‫للنظام أعاله‬
‫؟‬11 ‫ ما هو رقم الصفحة وإزاحة الصفحة للعنوان المنطقي‬.1
‫؟‬14 ‫ ما هو العنوان الفعلي للعنوان المنطقي‬.2
‫؟‬22 ‫ ما هو العنوان المنطقي المقابل للعنوان الفعلي‬.3

You might also like