CS 3733 Operating Systems
Lecture 9 [9/24/97]: Introduction to Memory Management
Reading: Tanenbaum Sections 3.1-3.2
Finish up signal material:
-
pause
suspends a process until a signal is delivered.
-
sigsuspend
does an atomic unblock and suspend for
a set of signals.
- System calls and signals
- What does it mean to be asynch-signal safe?
- Interruption of long calls.
Fundamentals of memory management on a single user system
- Program is compiled into machine code. Uses a relocatable format
for most addresses and there is a table at the beginning for those
addresses which are not relocatable.
- When the program is loaded into memory all of the appropriate
relocable addresses are adjusted.
- If dynamic loading is used, the entire routine is kept in relocatable
format and loaded in when called. This is done by the program.
- Dynamic linking --- used for system libraries. Also called shared
libraries. The program contains only a stub. The stub loads
the appropriate library when called. This is a feature of
the operating system.
Multiprogramming
- Keep more than one process in memory.
- CPU utilization = 1 - pn where n is the number of
processes and p is fraction of time each process spends
in the I/O wait state.
Fixed partitions for memory management
- Divide up the memory into fixed pieces (not necessarily equal).
- Each partition contains at most one program.
- A base register and a limit register are used to relocate and
protect.
- When job is scheduled it is put into a particular partition.
- If job is a lot shorter than partition, that space is wasted
for duration of job (internal fragmentation).
- If a partition is too small for any of the current jobs, that
partition sits idle (external fragmentation).
- If job is larger than any partitions, you're out of luck.
Variable partitions
- Partition sizes are determined dynamically to match the
current job sizes.
- The operating system keeps a table of current parititions.
- When a job finishes, it leaves a hole. Eventually there are holes
everywhere which must be consolidated (external fragmentation).
This is called compaction.
- Hardware is same as for fixed partitions (base register and
a limit register).
Swapping
- Move a process out of memory to
disk and then bring it back into memory
to continue its execution.
- There is too much overhead to have the CPU scheduler
constantly swap out processes. (How long would it
take to swap out a 500 K process to a disk with a
transfer rate of 3 Mbytes/sec?)
Problems:
- The CPU scheduler must work on a shorter time scale than this.
- Even if done in the background (by a separate I/O controller) this would
produce too much disk activity.
- Some processes, like X Windows applications are over a megabyte in size.
- We cannot swap out a process which is not using the CPU because it
is doing I/O.
- Swapping can be used by the long term scheduler to swap out processes that
are waiting for an event that will not occur for a long time.
Revision Date: 9/27/97