Presentation is loading. Please wait.

Presentation is loading. Please wait.

Memory management. Instruction execution cycle Fetch instruction from main memory Decode instruction Fetch operands (if needed0 Execute instruction Store.

Similar presentations


Presentation on theme: "Memory management. Instruction execution cycle Fetch instruction from main memory Decode instruction Fetch operands (if needed0 Execute instruction Store."— Presentation transcript:

1 Memory management

2 Instruction execution cycle Fetch instruction from main memory Decode instruction Fetch operands (if needed0 Execute instruction Store result in memory if needed At least one memory access per instruction!

3 Process of compiling, linking and loading Compiling: Take program high level language and convert into object programs Linker: Take several object programs, resolve external references and perform relocation; result: load module Loader: loads load module in memory

4 Kinds of addresses Source program Object module Running program Symbolic addresses Relocatable addresses Absolute address

5 I. Simple memory allocation Only 1 user. Partition into two parts--OS part and user part Have bounds register (has smallest permitted address for user program) OS can access entire memory; user can access only user part (except through some trap instructions)

6 II. Static partitioned allocation Memory is divided into a fixed number of user partitions (plus an OS partition). Number and size of individual partitions do not change. Managing storage Allocation/De-allocation

7 Managing storage Maintain a table Location, size and status (in use or free) Deallocation: Set status to free –Executed when a process terminates and its memory is to be freed

8 Allocation Search for the partition that is free and is big enough for the program that needs it. Two searching schemes –First-fit: Search table equentially for the first free partition of sufficient size –Best-search: Search for the smallest free partition of sufficient size

9 Dynamic partitioned allocation Number of size of partitions will vary with time. Initially, one big free partition. Issues: –Managing memory –Deallocate –Allocate

10 Managing memory Maintain a linked list of free space. Update the list when doing deallocation or allocation

11 Deallocation Insert the partition into the free list. Merge with adjacent free partition(s) if possible.

12 Allocation First fit allocation –Search list and find the first free partition that is sufficiently large for the requested process Best fit allocation algorithm –Find the smallest free partition that is sifficient Worst fit –Find the largest free partition (not good in practice)

13 External fragmentation Free memory is partitioned into large number of small spaces; cannot allocate to a process that needs it. In terms of the extent of external fragmentation, there is no clear choice between first fit and best fit; There are instances when one is better than the other

14 Compaction Move free memory together to make one large free partition Moving programs is expensive (moving time is proportional to program size) Determining the optimal way to move programs: NP-hard problem

15 Segmentation Break the program into modules (based on how the program is written; use compiler help). Allocate each module separately. Fragmentation problem is smaller since we do not have large program sizes

16 Dynamic address translation in segmentation Each address is of the form (s,o) where s is the segment number and o is the offset. At run time, find the beginning absolute address of segment s, check that offset o is less than or equal to segment size and –absolute address = starting address+o

17 Dynamic address translation Use the segment table –if there are n segments (modules) for a program, the table has n rows –Each row has two components: size and starting address of that segment in main memory


Download ppt "Memory management. Instruction execution cycle Fetch instruction from main memory Decode instruction Fetch operands (if needed0 Execute instruction Store."

Similar presentations


Ads by Google