1 / 29

Ch 9. Memory Management

Ch 9. Memory Management. 30-Sep-14. 9.1 배경. 기억장소의 구성. Real. Real. Virtual( Disk ). Single User dedicated System. Real Storage Multiprogramming System. Virtual Storage Multiprogramming. Fixed Partition MP. Variable Partition MP. 페이징. 세그먼 테이션. Combined Paging Segment.

ata
Download Presentation

Ch 9. Memory Management

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Ch 9. MemoryManagement 30-Sep-14

  2. 9.1 배경 • 기억장소의 구성 Real Real Virtual( Disk ) Single User dedicated System Real Storage Multiprogramming System Virtual Storage Multiprogramming Fixed Partition MP Variable Partition MP 페이징 세그먼 테이션 Combined Paging Segment Abso -lute Reloca -table

  3. Register cache main memory electronic disk magnetic disk optical disk magnetic tapes 9.1 Background • 기억장소 계층구조 • 관리 정책 • Fetch policy : When? ( Program or data  Main memory ) • Demand Fetch (요청시 읽음) • Anticipatory Fetch(미리 예측하여 읽음) • Placement policy : Where? • First - fit • Best - fit • Worst -fit • Replacement policy : What?

  4. 원본 프로그램 다른 객체 모듈 Linkage editor 로드 모듈 Load time 컴파일 시간 컴파일러 / 어셈블러 시스템 라이브러리 로더 객체 모듈 동적 시스템 라이브러리 메모리내의 이진메모리 이미지 동적 링킹 실행시간 9.1 Background • 사용자 프로그램의 단계별 처리과정

  5. 9.1 Background • 동적 로딩 • 루틴은 호출될 때까지 로드 되지 않는다. • 모든 루틴은 재배치 가능한 형태로 디스크에 존재한다. • 동적 링킹(dynamic linking) • 동적 로딩과 유사하나, 실행 가능한 이미지로 존재한다.

  6. 9.1 배경 • 중첩(Overlay) User program with storage requirement large then available portion of main storage Operating System Portion of user code and data that must remain in main storage for duration of excute Initialization Phase Processing Phase Output Phase a b c Overlay area 1 2 3 Load Initialization Phase at b and run Then Load Processing Phase at b and run Then Load Output Phase at b and run

  7. 9.1 배경 • Ex) Overlays for a two-pass assembler Symbol table 20K Common routiness 30K Overlay driver 10K 70K Pass 1 Pass 2 80K

  8. 9.2 스와핑(Swapping) • Swapping • 스와핑 시간 (문맥 교환 시간) • 사용자 프로세스 크기 : 1 MB • 디스크 • 초당 5MB 전송률 • 회전지연시간 8ms • 전송시간 : 8 m sec + (1MB / 5MB) = 8 m sec + 200 ms • Swap Time = 208 m sec  Total Swap Time  416 m sec

  9. 9.3 스와핑 디스크를 사용한 두 프로세스의 스와핑 Monitor fence User 1 Swap out  User 2  Swap in user space main memory backing store

  10. 9.3 연속 메모리 할당 • 연속 할당 • Single Contiguous Loading • Partitioned Loading • 불연속 할당 • 페이징과 세그먼테이션 • 스와핑 • 가상 메모리 페이징 세그먼테이션

  11. 9. 3 연속 메모리 할당 • 연속 할당 • Fixed Partition • Variable Partition < Single-partition Allocation > < Dynamic Relocation > relocation register limit register 0 Operating system logical address yes < user + CPU memory no trap; addressing error 512 K 재배치와 상한레지스터를 지원하는 하드웨어 메모리 분할

  12. 9. 3 연속 메모리 할당 스케줄링 예 • 다중 분할 할당 • 고정 분할 • 가변 분할 0 operating system Job queue process memory time 400 K P1 P2 P3 P4 P5 10 5 20 8 15 600 K 1000 K 300 K 700 K 500 K 2160 K 2560 K

  13. 9. 3 연속 메모리 할당 메모리 할당 과정 0 0 0 0 0 Operating system Operating system Operating system Operating system Operating system 400 K 400 K 400 K 400 K 400 K P5 P1 P1 P1 900 K 1000 K 1000 K 1000 K 1000 K 1000 K P4 P4 P4 terminates allocate P2 할당 P2 P1 P5 P4 종료 1700 K 1700 K 1700 K 2000 K 2000 K 2000 K 2000 K 2000 K P3 P3 P3 P3 P3 2300 K 2300 K 2300 K 2300 K 2300 K 2560 K 2560 K 2560 K 2560 K 2560 K (a) (b) (c) (d) (e)

  14. 9. 3 연속 메모리 할당 Compaction 외부 단편화 compaction(garbage collection) 내부 단편화 0 0 operating system operating system 400 K 400 K 가변 분할 할당 P5 P5 900 K 900 K 100K 1000 K P4 Non contiguous : swapping / page , coalescing holes P4 compact 1600 K P3 1700 K 300K 1900 K 2000 K 660K P3 2300 K 260 K 2560 K 2560 K

  15. 9.4 페이징 • 가상주소와 실제 주소 • 외부 단편화 문제의 해결  Noncontiguous logical address physical address Physical Memory p f d d CPU p F : V  R f Page table Paging hardware

  16. 9.4 페이징 4B 페이지를 가진 32B 기억장치의 페이징 예 0 a 1 b 2 c 3 d 0 16 0 a 1 b 2 c 3 d 4 i j k l 20 a b c d 5 6 1 2 0 1 2 3 0 a 1 b 2 c 3 d 8 m n o p 24 e f g h Page table 0 a 1 b 2 c 3 d 12 28 logical memory Physical memory

  17. 9.4 페이징 빈 프레임 (a) 할당전 (b) 할당후 free-frame list 15 free-frame list 14 13 18 20 15 page 1 page 0 13 14 15 16 17 18 19 20 21 13 14 15 16 17 18 19 20 21 page 0 page 1 page 2 page 3 page 2 page 0 page 1 page 2 page 3 page 3 new process new process 14 13 18 20 0 1 2 3 (b) (a) new-process page table

  18. 9.4 페이징 • Virtual address • V = ( b, d ) • block : Division unit of V, M • page : Fixed block size • Paging • segment : No fixed block size • segmentation • 각 프로세스는 자신만의 블록 사상표(Block Mapping Table)를 가지고 있다. b d

  19. 9.4 페이징 • 페이징 주소 변환 by Direct Mapping by Associative Mapping with Combined Associative/Direct < Direct mapping > Base Add. Of PMT b Page number Displacement or “block” b Virtual Add. V=(p,d) P d p + PMT b b+p p P´d Real Address. P´ (PTBR) Page Table Base Register

  20. 9.4 페이징 < TLB를 이용한 페이징 하드웨어 > • Use expensive Associative memory • Associative register = Translation lock-aside buffers(TLB) • Page(entry) # : 8 ~ 2048 Page number Displacement Pd 가상 주소 V=(p,d) Associative map P´ d P P´ 실제 주소. Frame number Displacement (TLB) : Translation Look-aside Buffer

  21. 9.4 페이징 Add. Of page map Table b start Page number Displacement Virtual Add. V=(p,d) P d + Partial Associative map Try this First performed only if no match in associative map b+p Direct map (all page) b P P´ only if match in associative map p P´ only if no match in associative map Frame number Displacement P´ d Real Add. < Combined Associative/Direct page mapping >

  22. Segment map table origin register Base address ‘b’ of segment table Logical address v = s +d b s Segment number s Displacement d + b+s Real address r = s’ + d Segment map table d s S’ S’ + d r + S’ Limit S# Segment Start address of Physical memory < Virtual address translation in a pure segment system > 9.5 세그먼테이션 • logical unit : possible to divide per page in segment • Logical address : segment# , offset

  23. 9.5 세그먼테이션 s limit base Segment table CPU s d Yes < + No 트랩 ; 주소 지정 오류 Physical memory Segmentation hardware

  24. 9.5 세그먼테이션 1400 subroutine stack Segment 0 2400 Segment 3 Segment 0 limit base Symbol table 3200 sqrt 0 1 2 3 4 1000 400 400 1100 1000 1400 6300 4300 3200 4700 Segment 4 Segment 3 main program Segment 1 4300 Segment 2 Segment 2 4700 세그먼트 테이블 Segment 4 논리적 주소공간 5700 6300 Segment 1 6700 <세그먼테이션 예> 물리적 주소

  25. 9.5 세그먼테이션 • Share and Protection of Segment • Share strong point of segmentation • must be protected • when multi user share the same segment, need protection (Fig 8.25) • Segmentation • may cause external fragmentation

  26. 9.5 세그먼테이션 editor 43062 Segment 0 Data 1 editor limit base Segment 1 68348 0 1 25286 4452 43062 68348 Data 1 72773 Segment table process P1 Logical memory process P1 editor 90003 limit base Segment 0 Data 2 Data 2 0 1 25286 8850 43062 90003 98553 Segment 1 Segment table process P2 Logical memory process P2 Physical memory Fig 8.25 Sharing of segment in a segmented memory system

  27. Segment map table origin register Base address , b , of segment table Logical address v = s +d b s Page number b Displacement d Segment number S + b+s Segment map table for this process Associative storage map b s P’ s P S’ Page map table for segments S S’ P S’ P P’ P + S’ Displacement d Frame number P’ 9.6 페이지화된 세그먼테이션 Fig 8.26 Virtual address translation with combined associative / direct mapping in a paged and segment system

  28. 9.7 페이지화된 세그먼테이션 • Paging / Segmentation system • too large segment =>> by unit of page • V = s, p, d • segment fault => control -> O.S -> segment map table page map table • page fault • alternative of shared page

  29. Summary • Comparison • Paged Memory Management • advantage) • may have some internal fragmentation, but increase system efficiency • need not compaction overhead for relocation partition • drawback) • increase computer cost for address mapping • consume large amounts of memory and increase processor time(overhead) because of many tables • Segmented Memory Management • advantage) • eliminate internal fragmentation in page or free table • share segment • (ex) two-pass assembler • drawback) • increase Hardware cost • memory space waste due to table, complexity of O.S

More Related