Title: Memory Management
1Memory Management
- Chapter 4
- Tuesday, February 27, 2007
2Todays Schedule
- Go over Assignment 3 CPU Scheduling Algorithms
- Go over Bankers Algorithm Quick Quiz
- Memory Management - Chapter 4
- Mono-Programming
- Multi-Programming
- Swapping
3Objectives
- You will be able to describe
- The basic functionality of the three memory
allocation schemes fixed partitions, dynamic
partitions, relocatable dynamic partitions - Best-fit memory allocation as well as first-fit
memory allocation schemes - How a memory list keeps track of available memory
4Operating System Software
Model of a non-networked operating system
5Operating System Software
Subsystems managers at the base of a pyramid
6Operating System Software
- Each subsystem manager must perform the following
tasks - Monitor its resources continuously
- Enforce the policies that determine who gets
what, when, and how much - Allocate the resource when its appropriate
- Deallocate the resource when appropriate
7Processor Manager
- Decides how to allocate the central processing
unit (CPU) - Has two levels of responsibility
- To handle jobs as they enter the system
- To manage each process within those jobs
8Memory Manager
- Responsibilities include
- Preserves the space in main memory occupied by
the operating system - Checks the validity of each request for memory
space - Sets up a table to keep track of who is using
which section of memory in a multiuser
environment - Deallocates memory when the time comes to reclaim
the memory
9Mono-Programming
- One user Process at any given time
- DOS (c)
10Memory Fixed Partitions
- N Concurrent Processes
- N Determined at Boot-time
- N Partitions set aside
- Varying sizes Small processes use small blocks
- Equal sizes Large processes can take any block
- Execute any process in memory
11Fixed Partitions
12Fixed Partitions Queueing
- Individual Queues
- Each Partition gets a Queue
- Processes directed to the smallest queue possible
- Large Partition may be idle while small has many
waiting - Single Queue
- One Queue for everyone
- Scheduler finds largest job for opening Partition
- Scheduler must work through Queue and search
- Small jobs given low preference, generally
13Why Multiprogram?
14Modeling Multiprogramming
Degree of multiprogramming
- CPU utilization as a function of number of
processes in memory
15Multiprogramming Performance
- Arrival and work requirements of 4 jobs
- CPU utilization for 1 4 jobs with 80 I/O wait
- Sequence of events as jobs arrive and finish
- note numbers show amount of CPU time jobs get in
each interval
16Relocation and Protection
- Cannot be sure where program will be loaded in
memory - address locations of variables, code routines
cannot be absolute - must keep a program out of other processes
partitions - Use base and limit register values
- address locations added to base value to map to
physical address - address locations larger than limit value is an
error
17Binding of Instructions and Data to Memory
- Compile time If memory location known a priori,
absolute code can be generated must recompile
code if starting location changes - Load time Must generate relocatable code if
memory location is not known at compile time - Execution time Binding delayed until run time
if the process can be moved during its execution
from one memory segment to another. Need
hardware support for address maps (e.g., base and
limit registers)
18Logical vs. Physical Address Space
- Logical address generated by the CPU also
referred to as virtual address - Physical address address seen by the memory
unit - Logical and physical addresses are the same in
compile-time and load-time address-binding
schemes logical (virtual) and physical addresses
differ in execution-time address-binding scheme
19Relocation
- Memory location
- Process memory start is not static
- Memory start is not predictable!
- Resolutions
- Make all jumps relative at compile time
- Change all jumps during loading
- Linker must ID all jumps
20Protection
- Accidental/Intentional clobbering
- Write memory from another job
- Read value from uncontrolled memory
- Resolutions
- Correct relocation
- Protection words (IBM/360)
- Base/Limit registers (CDC 6600, Intel 8088)
21Swapping Not enough room!
- Memory allocation changes as
- processes come into memory
- leave memory
- Shaded regions are unused memory
22Swapping
- Allocate growth space
- Stack for calls
- Heap for dynamic variables
- Swap what is used
- If we havent used the space, dont save it
23Summary
- Memory Management
- Monoprogramming vs Multiprogramming
- Swapping
- Need Freespace Tracking
- Coming up
- How to track freespace and manage memory
- Virtual Memory
- Page Tables
24Thursday, March 1
- Go over graded Assignment 4
- Continue reading through Pg 207,Chapter 4
Memory Management