Operating Systems

Paging

Ahmad Yoosofan

University of Kashan

شکل سادهٔ صفحه‌بندی

  1. Number of bits of Addrress related to Maximum supported memory by this computer(cpu and motherboard)
  2. Number of bits of Addrress = log2(Maximum supported memory)
  3. If max supported memory = 32 words then number of bits needed for addrress ?
  4. 32 = 2 ^ 5, \(n = log_2(m)\) , m is number of bytes or words
  5. 5 = log2(32)
  6. if p = 2, d = 3 then the size of each frame or page is ?
  7. 2 ^ 3 = 8
  8. Maximum number of Frames?
  9. 2 ^ 2 = 4

بخش‌بندی ثبات آدرس در حافظهٔ صفحه‌بندی شده

Maximux memory supported by cpu

Consider a computer with maximum 16 words

  1. Draw Memory Bytes
  2. d = 2
  3. Draw Memory Frames
  4. some First Frames for os
  5. Put a process into Memory (not continuous or in order)
  6. Fill page table
  7. Convert a Logical Addfress to Physical Address
  8. Put another process into Memory

0000

0001

0010

0011

0100

0101

0110

0111

1000

1001

1010

1011

1100

1101

1110

1111

0

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

.

00

01

10

11

0

1

2

3

00

00

01

10

11

4

5

6

7

01

00

01

10

11

8

9

10

11

10

00

01

10

11

12

13

14

15

11

یک کامپیوتر با حافظهٔ ۳۲ بایت و اندازه‌های قاب ۸ بایتی و یک فرآیند

d = 3, p = 2

p0 11 bytes

---

یک کامپیوتر با حافظهٔ ۱۲۸ بایتی و صفحه‌های ۸ بایتی

---

یک حافظهٔ ۳۲ بایتی با صفحه‌های ۴ بایتی

تغییرات فضاهای آزاد پیش و پس از تخصیص حافظه به یک فرآیند

تغییرات حافظه برای چند فرآیند

تبدیل آدرس منطقی به آدرس فیزیکی در حافظهٔ صفحه‌بندی شده

Address Translation

Process and Page Table

PTBR

TLB

Flowchart of TLB miss

Paging Memory Access

اشتراک گذاری در حافظهٔ صفحه‌بندی شده

سلسه مراتب حافظه

Memory Access

Effective Access Time

$$\begin{align}EAT = table + memory\end{align}$$
$$\begin{align}table = h_t * t_t + ( 1 - h_t ) * ( t_t + t_m )\end{align}$$
$$\begin{align}memory = h_c * t_c + ( 1 - h_c ) * ( t_c + t_m )\end{align}$$
$$\begin{align}EAT = h_t * t_t + ( 1 - h_t ) * ( t_t + t_m ) + h_c * t_c + ( 1 - h_c ) * ( t_c + t_m )\end{align}$$

زمان دسترسی مؤثر را برای پردازنده‌ای با حافظهٔ صفحه‌بندی شده حساب کنید اگر زمان دسترسی به حافظهٔ نهان جدول صفحه برابر ۱ نانو ثانیه باشد و زمان دسترسی به حافظهٔ نهان ۵ نانوثانیه باشد و زمان دسترسی به حافظه برابر ۱۰۰ نانوثانیه باشد و ضریب اصابت حافظهٔ نهان جدول صفحه برابر با ۹۵ درصد و ضریب اصابت به حافظهٔ نهان ۹۰ درصد باشد.

$$\begin{align}EAT = table + memory\end{align}$$
$$\begin{align}table = h_t * t_t + ( 1 - h_t ) * ( t_t + t_m )\end{align}$$
$$\begin{align}table = 0.95 * 1 + 0.05 * (1 + 100) = 0.95 + 5.05 = 6\end{align}$$
$$\begin{align}memory = h_c * t_c + ( 1 - h_c ) * ( t_m + t_c )\end{align}$$
$$\begin{align}memory = 0.90 * 5 + 0.1 * (5 + 100) = 4.5 + 10.5 = 15\end{align}$$
$$\begin{align}EAT = 6 + 15 = 21ns\end{align}$$

زمان دسترسی مؤثر = زمان دسترسی به جدول صفحه + زمان دسترسی به حافظه

با فرض برابر بودن نسبت‌های اصابت و زمان‌های یکسان برای دسترسی به حافظهٔ نهان و حافظهٔ TLB خواهیم داشت

$$\begin{align}EAT = 2 * (h * t_c + ( 1 - h ) * ( t_c + t_m ))\end{align}$$
$$\begin{align}EAT = 2 * ( h_c * t_c + (1-h_c) * (t_m + t_c) )\end{align}$$
$$\begin{align}EAT = 2 * ( h_c * t_c + t_m + t_c - h_c * t_m - h_c * t_c )\end{align}$$
$$\begin{align}EAT = 2 * ( t_c + (1 - h_c) * t_m )\end{align}$$

حفاظت از حافظهٔ صفحه‌بندی شده

References(I)

References(II)

References(III)

References(IV)

1