Lecture 15 - Input/Output


Agenda

Announcements

  • None yet.
  • Midterm stuff

    Grading summary, some answers.

    Segmentation

    Another possible memory management scheme, sort of a hybrid of contiguous allocation and paging, is called segmentation.

    Memory is allocated for a process as a collection of segments. These segments correspond to logical units of memory in use by a process:

  • main program
  • procedure, function, method
  • object, local variables
  • global variables
  • common block (Fortran)
  • stack
  • heap space
  • This can be thought of as a finer grained approach to contiguous allocation - smaller contiguous chunks, corresponding to these logical units - are scattered throughout memory.

    With segmentation, a logical address consists of an ordered pair: (segment-number, offset)

    A segment table contains two entries for each segment:

  • base - the starting physical address where the segment resides in memory
  • limit - the length of the segment
  • Two registers locate the segment table in memory:

  • Segment-table base register (STBR) points to the segment table's location in memory
  • Segment-table length register (STLR) indicates number of segments used by a program; segment number s is legal if s < STLR.
  • With segmentation, segments may be relocated by moving the segment and updating the segment table. The segment number, and hence the logical addresses, remain the same.

    Segment sharing is straightforward, as long as each process use the same segment number. This is required because the code in a segment uses addresses in the (segment-number, offset) format.

    Allocation for the segments uses the same techniques as contiguous allocation (first-fit, best-fit), but since the chunks are smaller, there is less likelihood of some of the problems arising, though external fragmentation is there.

    What's the Right Answer?

    Both paging and segmentation are actually used. In fact, many systems combine them. See the text for how they are combined with MULTICS and on the Intel x86 series.

    See the handout that goes with Homework 6 for more on how BSD does all this.

    How might we compare strategies?

  • how much hardware support is needed or available
  • performance - more complexity = slower
  • fragmentation?
  • relocation - do we need dynamic binding?
  • swapping - does it have to go back to the same place? Swap the whole thing?
  • sharing segments/pages
  • protection - need to ensure safe access
  • Input/Output

    One of the primary functions of an OS is I/O management.

  • wide variety of devices to be handled
  • provide convenient interface
  • manage wide variety of device speeds - range from a few bytes per second from a keyboard to several gigabytes per second on a fast network interface
  • organization (files/file system from a disk)
  • error handling
  • deliver I/O to the correct process
  • protection and security
  • We will not spend much time in class going over the background - just highlights. Read Chapter 5 if you're not comfortable with some of the background.

    Two common ways to connect an I/O device:

  • port (serial, parallel)
  • bus (SCSI, USB, PCI)
  • Note the presence of device controllers - hardware that connects directly to the main bus on behalf of actual devices.