ch7. memory paging, segmentation #์šด์˜์ฒด์ œOS #ํŽ˜์ด์ง•๊ธฐ๋ฒ•

2022. 12. 14. 23:14ใ†_Study/OperationSystem

728x90

Paging ๐Ÿ‡¸.•*¨*•¸.•*¨*•¸.•*¨*•¸.•*¨*•

ํ•ด๋‹น ์ž๋ฃŒ๋Š” ๊ฐ•์˜ ํ•™์Šต์ž๋ฃŒ์ž…๋‹ˆ๋‹ค.


static partion / dynamic partition : ์ž‘์€ ์‚ฌ์ด์ฆˆ์—๋„ ๋‹จํŽธํ™”๊ฐ€ ์ƒ๊ธด๋‹ค.

ํ”„๋กœ์„ธ์Šค๋ฅผ ๋งค์šฐ ์ž‘์€ ๊ณ ์ •๋œ ์‚ฌ์ด์ฆˆ๋กœ ๋‚˜๋ˆˆ ๊ฒƒ์„ page ๋ผ๊ณ  ํ•˜๊ณ 

๋ฉ”๋ชจ๋ฆฌ๋ฅผ ๋งค์šฐ ์ž‘์€ ๊ณ ์ •๋œ ์‚ฌ์ด์ฆˆ์˜ ๋ฉ”๋ชจ๋ฆฌ์กฐ๊ฐ์œผ๋กœ ๋‚˜๋ˆ„์—ˆ๋Š”๋ฐ ์ด๋ฅผ page frame์ด๋ผ๊ณ  ํ•œ๋‹ค. page๋ฅผ ๋„ฃ์„ ์ˆ˜ ์žˆ๋Š” ํ‹€์ด๋ผ๊ณ  ์ƒ๊ฐํ•˜๋ฉด ๋œ๋‹ค.

 

Memory is partitioned into equal fixed-size chunks

- Frames or page Frames

- that are relativley small

 

Process is also divided into small fixed-size chunks (pages) of the same size

frame(page frame) : memory ์ชฝ์— ๋‚˜๋ˆ”

page : process ์ชฝ์—์„œ ๊ฐ™์€ ์‚ฌ์ด์ฆˆ๋กœ ๋‚˜๋ˆˆ ์กฐ๊ฐ

์ด๋ ‡๊ฒŒ page๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ์™ธ๋ถ€ ๋‹จํŽธํ™”๊ฐ€ ํ•ด๊ฒฐ ๋œ๋‹ค: (ํ• ๋‹นํ•˜๊ณ  ๋ฐ”๊นฅ์ชฝ์— ๋‚จ์€ ๋ฉ”๋ชจ๋ฆฌ), ๊ทธ๋ ‡์ง€๋งŒ ์›๋ž˜ page์กฐ๊ฐ ๋ณด๋‹ค ์ž‘์œผ๋ฉด internal fragmentation ์€ ์ƒ๊ธด๋‹ค. ์• ์ดˆ์— ํฌ๊ธฐ๊ฐ€ ๋งค์šฐ ์ž‘๊ธฐ ๋•Œ๋ฌธ์— ๋‚ด๋ถ€ ๋‹จํŽธํ™”๋กœ ์ƒ๊ธฐ๋”๋ผ๋„ ์ž‘๊ฒŒ ์ƒ๊ธด๋‹ค.

 

 

ํ”„๋กœ์„ธ์Šค๋ฅผ ์ชผ๊ฐœ์–ด ์—ฌ๋Ÿฌ ๊ฐœ์˜ frame์— ์ €์žฅ์ด ๊ฐ€๋Šฅํ•˜๋‹ค ์ด๋ฅผ paging ๊ธฐ๋ฒ•์ด๋ผ๊ณ  ํ•˜๋ฉฐ partition์€ ๊ตณ์ด ์—ฐ์†๋  ํ•„์š”๊ฐ€ ์—†๊ณ  ์—ฌ๊ธฐ์ €๊ธฐ ๋„ฃ์–ด๋„ ๋œ๋‹ค.

 

OS maintain page table for each process : ํŽ˜์ด์ง€ ํ…Œ์ด๋ธ”์„ ๋งŒ๋“ค์–ด ๊ด€๋ฆฌํ•œ๋‹ค.

which contains the frame location forf each page in the process

logical address๋Š” ํŽ˜์ด์ง€ ๋„˜๋ฒ„๋กœ ๊ตฌ์„ฑ๋˜์–ด ์žˆ๋‹ค.

ํŽ˜์ด์ง€ ์•ˆ์—์„œ๋„ ๊ทธ์•ˆ์˜ ์ฐธ์กฐํ•  ์ฃผ์†Œ๋ฅผ offset ๋ฒˆํ˜ธ๋กœ ๊ฐ€์ง€๊ณ  ์žˆ๊ณ  ์ด๋ฅผ ์ด์šฉํ•˜์—ฌ Page table์„ ์‹ค์ œ ์ฃผ์†Œ๋ฅผ ์ฐธ์กฐํ•˜๋Š”๋ฐ ์‚ฌ์šฉํ•œ๋‹ค. (์ด๋ฏธ size๋ฅผ ์•Œ๊ณ  ์žˆ๋‹ค)

logical address = page number + offset

paging์€ page table์˜ number index์—์„œ framelocation์„ ์ฐพ์•„์•ผํ•œ๋‹ค.

relative address ๊ฐ™์€๊ฒฝ์šฐ ์˜ˆ์‹œ๊ฐ€ 1502 ์ธ๋ฐ ์ด๋ฅผ ์ด์ง„์ˆ˜๋กœ ๋‚˜ํƒ€๋‚ด๋ฉด 000001 0111011110 ์ด๋‹ค. 

์ด๋Š” 1(1024) + 0111011110(478) ์ด๋‹ค.

์ฆ‰, 1KB ์˜ ๊ฐ™์€ ์‚ฌ์ด์ฆˆ๋กœ ํŽ˜์ด์ง€๋ฅผ ๋‚˜๋ˆ„๋ฉด ํ•œ ๋‹จ์œ„๊ฐ€ 2์˜ 10์Šน์ด๋ผ offset์ด 10๊ฐœ(10๋น„ํŠธ) ์ธ ๊ฑฐ ๊ฐ™๋‹ค.

๋‹ค์Œ page number์ด 000010 ์ด ๋˜๋ฉด offset์˜ 2์˜ 10์Šน์ด ์ง€๋‚˜์•ผํ•œ๋‹ค. ๋”ฐ๋ผ์„œ Page๋ฌถ์Œ์ด 1KB์ธ ๊ฒƒ์„ ๋งŒ์กฑํ•œ๋‹ค.

๋”ฐ๋ผ์„œ page number ์˜ bit๋ฅผ ์กฐ์ ˆํ•˜๋ฉด page ์˜ ๋‹จ์œ„๋ฅผ ์กฐ์ ˆํ•  ์ˆ˜ ์žˆ์„๊ฑฐ ๊ฐ™๋‹ค.

 

 

segmentation๐Ÿ‡¸.•*¨*•¸.•*¨*•¸.•*¨*•¸.•*¨*•


A program can be subdivided into segements : ํ”„๋กœ๊ทธ๋žจ์„ ์—ฌ๋Ÿฌ segments๋กœ ๋‚˜๋ˆŒ ์ˆ˜ ์žˆ๋‹ค.

- Not required that all segments of all programs be of the same length : ๊ฐ™์€ ํฌ๊ธฐ๋กœ ๊ตณ์ด ๋‚˜๋ˆ„์ง€ ์•Š์•„๋„ ๋œ๋‹ค.

- there is a maximum length : ์ตœ๋Œ€ ๊ธธ์ด๊ฐ€ ์ •ํ•ด์ ธ ์žˆ๋‹ค.

 

Logical address consists of two parts:

- segment number + offset

 

similar to dynamic partitioning (unequal size)

- but, a program may occupy more than one patition;

- these partitions need not be contiguous

 

No internal fragmentation : ๋‚ด๋ถ€ ๋‹จํŽธํ™”๊ฐ€ ํ•ด๊ฒฐ๋œ๋‹ค.

Relatively smaller external fragmentation : ์™ธ๋ถ€ ๋‹จํŽธํ™”๊ฐ€ ๋ฐœ์ƒํ•œ๋‹ค.

Segmentation is visible to ther programmer or compiler

Provded as a convenience to organize logically programs

 

No simple relationship between logical addresses and physical addresses

OS maintains a segment table for each process and a list of free blocks of main memory

 

Each segment table entry contains:

- the starting physical addresses of that segment

- the length of that segment

to assure that invalid addresses are not used.

ํ•„์š”ํ•œ segment ํฌ๊ธฐ๋งŒํผ ํ• ๋‹น๋ฐ›์•„ ์‚ฌ์šฉํ•œ๋‹ค.

 

page๋Š” ์‚ฌ์ด์ฆˆ๋ฅผ ์•Œ๊ณ  ์žˆ๋Š”๋ฐ ์—ฌ๊ธฐ๋Š” ๋๊ณผ ๋์˜ ์ฃผ์†Œ๋กœ ์‚ฌ์ด์ฆˆ๋ฅผ ๊ณ„์‚ฐํ•œ๋‹ค.

limit : ์‹œ์ž‘ ์œ„์น˜

base : ๋๋‚˜๋Š” ์œ„์น˜

 

 

๋‹จ์ : physical address์™€ ์ „ํ˜€ ๊ด€๊ณ„๊ฐ€ ์—†๋Š” logical address, ๋น„์–ด์žˆ๋Š” block list ๊ฐ€ ํ•„์š”๋กœ ํ•˜๋‹ค.

 

 

 

์ •๋ฆฌ

  Paging  Segment
์ •์˜ ํ”„๋กœ์„ธ์Šค๋ฅผ ์ชผ๊ฐœ์–ด ์—ฌ๋Ÿฌ ๊ฐœ์˜ frame์— ์ €์žฅ์ด ๊ฐ€๋Šฅํ•˜๋‹ค ํ”„๋กœ๊ทธ๋žจ์„ ์—ฌ๋Ÿฌ ๊ฐœ์˜ segment ๋กœ ๋‚˜๋ˆ„์–ด ์ €์žฅ์ด ๊ฐ€๋Šฅํ•˜๋‹ค.
์‚ฌ์šฉ page : ํ”„๋กœ์„ธ์Šค์—์„œ ๋‚˜๋ˆˆ ๊ฐ™์€ ์‚ฌ์ด์ฆˆ์˜์ž‘์€ ์กฐ๊ฐ segment : ์—ฌ๋Ÿฌ ํฌ๊ธฐ๋กœ ๋‚˜๋ˆ„์–ด์ง„ ํ”„๋กœ๊ทธ๋žจ
๋ฐœ์ƒํ•˜๋Š” ๋‹จํŽธํ™” ๋‚ด๋ถ€ ๋‹จํŽธํ™” ์™ธ๋ถ€ ๋‹จํŽธํ™”
์ฃผ์†Œ ์ฐธ์กฐ page table + offset segment table + offset
visible ์—ฌ๋ถ€ ์‹œ์Šคํ…œ ์ƒ์˜ ์ฒ˜๋ฆฌ ๊ฐœ๋ฐœ์ž๊ฐ€ ํ™•์ธ ๊ฐ€๋Šฅ