CS 3733 Operating Systems
Lecture 15 [10/15/97]: Segmentation
Reading: Tanenbaum Section 3.7 and 3.8
Allocation of frames
- Usually a minimal number of frames is allocated
and a maximum is set so that
one process does not use up most of physical memory.
- It is not wise to divide up all of the frames among active processes and
leave very few free frames.
If there are always free frames, then when a
new frame is needed, (e.g. when new process enters the system)
you do not have to save the old one on disk.
- If too few frames are allocated to a process, then a new frame must replace
a page which will be used again soon.
This can cause high page activity called thrashing.
Thrashing can reduce the effective memory access time to the disk access
time.
- You want the level of
multiprogramming to be high to ensure a high CPU utilization.
If it is too high, then processes will not be allocated enough real memory
and thrashing can take place.
- You can determine the level of multiprogramming if you know how many
pages each process is going to need.
During a period of time there is
a collection of pages that a given process will access,
called the working set.
The working set may change with time and may be difficult to track.
- Page size tradeoffs - too large results in internal fragmentation,
too large means large page table. Most current systems seem to be using
pages of size 4K or 8K. Sun has major and minor pages.
Segmentation
- Segmentation is a two-dimensional scheme: segment number and
offset within a segment.
- Programmer is aware of the segment structure.
- Procedures and data can be separately protected.
- Tables that fluctuate in size can be accommodated.
- Sharing is easy.
Most segmentation is implemented by dividing segments up
into pages and having a page table for each segment.
See Figure 3-39 for an example of how Multics does it.
The Intel 386 uses segmentation with paging:
- 16K segments each of 1 billion words.
- LDT = local descriptor table, contains the segments local
to a program.
- GDT = global descriptor table, contains shared and system segments.
- 16 bit selector (Fig. 3-43) is loaded into a segment register.
- A 64-bit descriptor is also loaded (Fig. 4-44).
- Conversion of (selector, offset) to physical address:
- Is offset beyond limit (size can be in bytes or pages).
- Page size is 4K.
- 32-bit base + offset gives linear address.
- If paging is disabled, the linear address is physical address.
- If paging is enabled, linear address is mapped onto a physical
address (Figure 3-46).
- Two-level mapping is used to reduce page table size for small segments.
- Program has a page directory (1024 32-bit entries)
- Has an associative memory to map Dir-Page into physical frame.
- 4 levels of protection (0 most privileged). Can't jump into
the middle of a different level with a call. Must go through a call gate.
Revision Date: 10/15/97