================ Start Lecture #17 ================

Ridiculously non-cost-effective extra credit for lab 2:
  1. Add worst fit and circular best fit. Hence there will be four curves on each graph.
  2. Add the number of allocated blocks, and the size of the largest allocated block to the standard statistics. Hence there will be 12 graphs.
  3. Add buddy system. Now allocations should be restricted to powers of two. Do not compare with the other four algorithms graphically, i.e. just produce the numerical output.
  4. If done completely correctly 10 points extra credit will be given.
  5. Don't even try this extra credit. I only added it on the request of a (presumably masochistic) student.

Notes on copyfile

4.1.7: Memory mapped files (not on 202 exams)

Conceptually simple and elegant. Associate a segment with each file and then normal memory operations take the place of I/O.

Thus copyfile does not have fgetc/fputc (or read/write). Instead it is just like memcopy

while ( (dest++)* = (src++)* );

The implementation is via demand paging (on top of segmentation) but the backing store for the pages is the file. This all sounds great but ...

  1. How do you tell the length of a newly created file? You know which pages were written but not what words in those pages. So a file with one byte or 10, looks like a page.
  2. What if same file is accessed by both I/O and memory mapping.
  3. What if the file is bigger than the size of virtual memory (will not be a problem in 5 years on modern systems).

4.2: Directories

Unit of organization.

4.2.1: Hierarchical directory systems

Possibilities

These are not as wildly different as they sound.

4.2.2: Path Names

Homework: 1, 8.

4.2.3: Directory operations

  1. Create: Normally comes with . and ..

  2. Delete: First empty the directory (except for . and ..)

  3. Opendir: Same as with files (creates a ``handle'')

  4. Closedir: Same as files

  5. Readdir: In the old days (of unix) could read directories as files so there was no special readdir (or opendir/closedir). It was believed that the uniform treatment would make programming (or at least system understanding) as there was less to learn.

    However, experience has taught that this was not a good idea since the structure of directories then becomes exposed. Early unix had a simple structure (and there was only one). Modern systems have more sophisticated structures and more importantly they are not fixed across implementations.

  6. Rename: As with files

  7. Link: Add a second name for a file; discussed below.

  8. Unlink: Remove a directory entry. This is how a file is deleted. But if there are many links, the file remains. Discussed in more detail below.

4.3: File System Implementation

4.3.1; Implementing Files

Contiguous allocation

Homework: 7.

Linked allocation

FAT (file allocation table)