Transcript
Page 1: Operating Systems { week  12a}

Operating Systems{week 12a}

Rensselaer Polytechnic InstituteCSCI-4210 – Operating SystemsDavid Goldschmidt, Ph.D.

Page 2: Operating Systems { week  12a}

Hierarchical storage architecture

very small

very large

very fast

very slow

volatile

non-volatile

Page 3: Operating Systems { week  12a}

Von Neumann architecture Based on the von Neumann

architecture, data and program instructionsexist in physical memory Repeatedly perform

fetch-decode-executecycles

The execute partoften results in datafetch and store operations

physical memory

Page 4: Operating Systems { week  12a}

Main memory (i)

Locations in memoryare identified bymemory addresses When compiled, programs

consist of relocatable code Other compiled modules

also consist ofrelocatable code

symbolic addresses

in source code

relative addresses

in object code

Page 5: Operating Systems { week  12a}

Main memory (ii)

At load time, anyadditional librariesalso consist ofrelocatable code

physical addresses

generated by loader

Page 6: Operating Systems { week  12a}

Main memory (iii)

At run time, memoryaddresses of all objectfiles are mapped to asingle memory spacein physical memory

Page 7: Operating Systems { week  12a}

Dynamic loading and linking Using dynamic loading, external libraries

are not loaded when a process starts Libraries are stored on disk in relocatable form Libraries loaded into memory only when needed

Using dynamic linking, external libraries can be preloaded into shared memory When a process calls a library function, the

corresponding physical address is determined

Page 8: Operating Systems { week  12a}

Contiguous memory allocation (i) Main memory

is partitionedand allocatedto residentoperating systemand user processes

fixed partitioning scheme

Page 9: Operating Systems { week  12a}

Contiguous memory allocation (ii) A pair of base and limit

registers define thelogical address space Also known as

relocation registers

Page 10: Operating Systems { week  12a}

Contiguous memory allocation (iii) The CPU generates logical memory addresses

A Memory-Management Unit (MMU)maps logical memory addressesto the physical address space

User programs never seephysical memory addresses

Page 11: Operating Systems { week  12a}

Contiguous memory allocation (iv) Hardware protects against memory

access outside of a process’s valid memory space

Page 12: Operating Systems { week  12a}

Dynamic partitioning Variable-length or dynamic partitions:

When a new process enters the system, the process is allocated to a single contiguous block

The operating system maintains a list of allocated partitions and free partitions

OSProcess

5

Process 8

Process 2

OSProcess

5

Process 2

OSProcess

5

Process 2

Process 9

OSProcess

5Process 9

Process 2

Process 1

Page 13: Operating Systems { week  12a}

Placement algorithms

How can we place new process Pi in memory? First-fit algorithm: allocate the first free block

that’s large enough to accommodate Pi Best-fit algorithm: allocate the

smallest free block that’s largeenough to accommodate Pi

Next-fit algorithm: allocate thenext free block, searching from last allocated block

Worst-fit algorithm: allocate the largest free blockthat’s large enough to accommodate Pi

Page 14: Operating Systems { week  12a}

Fragmentation (i)

Memory is wasted due to fragmentation,which can cause performance issues Internal fragmentation is wasted

memorywithin a partition or process memory

External fragmentation can reducethe number of runnable processes▪ Total memory space exists to satisfy

a memory request, but memory isnot contiguous

OSProcess

5Process

8

Process 2

Process 3Process

6

Process 12

Process 7Process 9

Page 15: Operating Systems { week  12a}

Process 3Process

6

Process 12

Process 7

Fragmentation (ii)

Reduce external fragmentation bycompaction or defragmentation Rearrange memory contents to organize

all free memory blocks together intoone large contiguous block

Compaction is possible only ifrelocation is dynamic and isdone at execution time

Compaction is expensive

OSProcess

5Process

8

Process 2

Process 9

Process 3Process

6

Process 12

Process 7

Process 3Process

6Process

12

Process 7

Process 9


Top Related