[OS] 가상 메모리할당 - Segmentation System

Manx·2022년 6월 8일
0

운영체제

목록 보기
10/12

Segmentation System

Paging System 처럼 프로그램을 고정된 크기로 분할하는 것이 아닌 논리적 block으로 분할
-> Block의 크기가 서로 다를 수 있다.

특징

  • 메모리를 미리 분할하지 않는다.
  • Variable partition (VPM) 과 유사하다.
  • Segemnt sharing / protection (권한 관리)가 용이하다.
  • Address mapping 및 메모리 관리의 overhead가 크다.
  • No internal framentation, External fragmentation 발생 가능

비연속적으로 할당한다.

Address mapping

Virtual address : v = (s, d)

  • s : segment number
  • d : displacement in a segment

Segment Map Table (SMT)
각 Block마다 크기가 다르기 때문에 segment length가 있다.

Address mapping 과정

  1. 프로세스의 SMT가 저장되어 있는 주소 b에 접근
  2. SMT에서 segment s의 entry 탐색 ( s의 entry 위치 = b + s * entrySize )
  3. residence bit 검사
    변위(d)가 segment 길이보다 큰 경우 ( d > l ), segment overflow exception,
    허가되지 않은 연산일 경우 (protection bit field 검사), segment protection exception
  4. 실제 주소 r 계산 ( r = a + d )
  5. r로 메모리에 접근

Segment sharing/protection

논리적으로 분할되어 있어, 공유 및 보호가 용이하다.
-> Page Block 단위가 아니기 때문에 이동이 편리하기 때문

Paging VS Segmentation

Paigin System

  • Simple
  • Low Overhead (크기 계산 X)
  • No logical concept for partitioning
  • Complex page sharing mechanism

Segmentation System

  • High management overhead (function마다 크기를 계산해야 한다)
  • Logical concept for partitioning
  • Simple and easy sharing mechanism

실제로 사용하는 가상메모리 할당 기법은 Hybrid paging/segmentation system이다.

Hybrid paging/segmentation system

  1. 논리 단위의 segment로 분할
  2. 각 segment를 고정된 크기의 page들로 분할

Page 단위로 메모리에 적재한다.

Address mapping

Virtual address : v = ( s, p, d )

  • s : segment number
  • p : page number
  • d : offset in a page

SMT와 PMT를 모두 사용한다.

하나의 segment에 PMT가 여러개 존재한다
Why ? segment 크기로 여러개의 Page를 만들었기 때문에

과정

앞서 모두 설명한 것이기 때문에 설명은 생략하겠다.

요약

  • Segment + Page
  • Page sharing / protection이 쉬움
  • 메모리 할당 / 관리 overhead가 작음
  • No external fragmentation
  • 전체 테이블 수가 증가해 메모리 소모가 크다, Address mapping 과정이 복잡하다.
  • Direct mapping의 경우, 메모리 접근이 3배라 성능이 저하될 수 있다.

Reference

운영체제:그림으로 배우는 구조와 원리 - 한빛 아카데미

profile
백엔드 개발자

0개의 댓글