Memory Management

stizzahaddockΛογισμικό & κατασκευή λογ/κού

14 Δεκ 2013 (πριν από 3 χρόνια και 5 μήνες)

73 εμφανίσεις

Memory Management


1. Single contiguous allocation


2. Partitioned organization:


Static, Dynamic


3. (Pure) Paging


Memory Management


1. Single Contiguous Allocation


Early, uni
-
programmed machines


Memory divided into 3 areas:


Memory management developed over time


(Historical Overview)

OS (32K)

User Job (64K)

Wasted (160K)

Memory (256K)




Single Contiguous Allocation



Hardware : Bounds register, supervisor
mode


Software : User job


available memory?


If so, allocate and run to completion


If not, error


Advantage : simplicity


Disadvantages : poor M, P utilitization


job must fit into M



Memory Management


2. Partitioned Organization


Early multiprogramming environment


Memory divided into partitions. Each holds
1 job.


E.g.




Partitioned Organization


Software :


1. Keep track of status of partitions


Size, Free or Allocated


2. Which job gets M [Job Scheduler]


3. Alloc :

Free partition of sufficient size assigned


4. Dealloc :

Freed when job terminates


Hardware :


2 bounds registers to bracket partition


Locks and keys [IBM]


Each partition has own protection key


When processor assigned, “key” in PSW =

Key of partition




Partitioned Organization


Two types of partitions :


Static Partitions


Memory divided into partitions according
to OS or Operator specification


Each job specifies max memory req’d;
memory management assigns partition
of sufficient size


Appropriate if : size, frequency of jobs
known


OW : wasteful of M


Estimated 75% wasted




Partitioned Organization


Two types :


Dynamic Partitions


Created during job processing to
match partition to job size


Need tables for allocating,
deallocating partitions : Size,
Location, Status.


E.g.




Partitioned Organization


Dynamic Partitions


Jobs terminate, new partitions created from
freed areas, subject to :


1. Free area


Job size


2. If >, fragmentation


3. On deallocation, merge adjacent free areas


Implementation :


Table size varies




Append info to each partition and chain


Lists of free, alloc partitions



3. (Simple or Pure) Paging


Each job’s address space


Equal pieces


frames


Memory


pieces of same size


Frames (blocks)


User :


Sees logically continuous address space


But pages loaded into frames which are not contiguous


HW maps any page into any frame


Mapping : PMT (Separate registers, 1/Page)


Page size is critical (1
-
4K, in powers of 2)


Solves fragmentation problem without moving
partitions

Memory Management

(Pure
paging)




Paging


Hardware :


1 register/page needed for memory
mapping


High speed registers or memory locations
(cache)


Dynamic Address Translation (DAT)


Divides EA into :









0 …. 7 8 …. 19 20 …. 31

Page number

Byte offset




Paging


Consider IBM example :


Page Size = 2
12
or 4096 bytes


Effective address (EA) = 24 bits


DAT : Divides EA into page index, byte
displacement


PMT : Maps page number to frame number




Physical address of page


Add byte offset



Address of operand


Software : Need 3 tables


1 PMT/job, with 1 entry per page


A memory block (frame) table (MBT), with status
info for each frame (if used, by whom)


A job table (JT), with 1 entry/job (Size, status,
pointer to PMT)




Paging



Advantages :


Facilitates multiprogramming by
eliminating fragmentation (more jobs in
memory, no compacting)


Facilitates sharing of info (memory)
among jobs by incorporating pages in
more than 1 job’s address space




Paging


Disadvantages :


Page address mapping
-

HW costly, time
-
consuming


Tables : Memory required for PMTs, time to update


Internal fragmentation (page breakage)


Half page/job wasted on average


Tradeoff :


Small pages (min page wastage) vs


Large pages (reducing # entries in PMT)


Know average job size


Some memory may not be used (if #frames <
address space)


Memory still contains infrequently used info


Job size must be


Memory size