1 Friday, July 07, 2006 “Vision without action is a daydream, Action without a vision is a...

39
1 Friday, July 07, 2006 “Vision without action is a daydream, Action without a vision is a nightmare.- Japanese Proverb
  • date post

    21-Dec-2015
  • Category

    Documents

  • view

    214
  • download

    0

Transcript of 1 Friday, July 07, 2006 “Vision without action is a daydream, Action without a vision is a...

1

Friday, July 07, 2006

“Vision without action is a daydream,

Action without a vision is a nightmare.”

- Japanese Proverb

2

Segmentation vs. Paging

Linear address spaces?Can address space exceed the size of

physical memory?Can procedures and data be distinguished

separately?Is sharing of procedures facilitated?

3

Long-term Information Storage

1. Must store large amounts of data

2. Information stored must survive the termination of the process using it

3. Multiple processes must be able to access the information concurrently

4

File naming

Shield user from details of how information is stored

Names can be as long as 255 charactersUpper case and lower case

5

Extensions

Unix does not enforce extensions Convenience for the user

May be required by programs e.g. C compilers

Windows is aware of extensions and we can specify which program is associated with an extension

6

File Structure

Three kinds of files Unstructured sequence of bytes

• OS does not know what is inside the file• Any meaning is imposed by the user programs• Approach used by UNIX and Windows

Record sequence• Fixed length records

Tree• Record retrieved through a key• Large mainframe computers for commercial data

processing

7

The DECSYSTEM-20 minicomputer example.

8

Flexibility lost if OS enforces all file types

9

Every Operating system must recognize one file type: its own executable file.

Executable binary file in UNIX Will execute file only if it has a proper

format Header with Magic number, sizes of text and

data segments, address where execution starts etc.

10

File AccessSequential access

read all bytes/records from the beginning cannot jump around, could rewind or back up convenient when medium was mag tape

Random access (Modern OSs) bytes/records read in any order essential for data base systems read can be …

• move file marker (seek), then read or …

• read and then move file marker

11

File Attributes

Name OwnerDate and time of creationModificationProtection informationSize…

12

File Operations

1. Create

2. Delete

3. Open

4. Close

5. Read

6. Write

7. Append

8. Seek

9. Get attributes

10. Set Attributes

11. Rename

13

open system call Fetch file attributes and disk addresses into

main memory do that later accesses can be carried out quickly.

File descriptor (small integer for use in subsequent operations)

close system call file should be closed to free up internal disk

space.

14

DirectoriesSingle-Level Directory Systems

A single level directory system contains 4 files owned by 3 different people, A, B, and C

15

Two-level Directory Systems

Letters indicate owners of the directories and files

Shared system programs

16

Hierarchical Directory Systems

A hierarchical directory system (used in modern file systems)

17A UNIX directory tree

Path Names

18

File System Implementation

A possible file system layout

Master Boot Record, usually in sector 0, is used to boot the computer.

One partition is marked as active.

Super block contains key parameters about the file system, such as number of blocks, magic number etc.

19

Implementing Files

(a) Contiguous allocation of disk space for 7 files(b) State of the disk after files D and E have been removed

20

Contiguous allocation

Simple to implementEasy to locate blocks given the disk address

of first blockRead performance for the entire file is very

good Why? How many Seeks?

21

Contiguous allocation

Problems: FragmentationFiles can grow in sizeIs declaring the maximum size of file a

good idea?

22

Contiguous allocation

Widely used on CD-ROMs

23

Implementing Files (cont’d)

Storing a file as a linked list of disk blocks

24

No space lost to external fragmentation.We need to store only the disk address of the

first block.Random access is slow: To get to block N,

must read n-1 blocks before it.Amount of data stored is no longer power of

two because the pointer takes some bytes.

25

Implementing Files (cont’d)

Linked list allocation using a file allocation table in RAM

Take the pointer away from each disk block and put it in a table in memory.

We need to store only the starting block number.

26

FAT

Main disadvantage: Entire table must be kept in memory The table holding linked lists is proportional to

the size of disk 40GB disk with 1KB block size 40 million

entries

27

Implementing Files (cont’d)

An example i-node

Index-node or i-node

A data structure associated with each file to keep track of which blocks belong to which file.

I-node need only be in memory when the corresponding file is open.

Using i-nodes require an array that is proportional to the maximum number of files that may be open at once.

28

Nearly all file system store files as fixed-size blocks.

Internal fragmentationSmall blocks

Good for disk utilization Bad for performance

In Unix: 1KB blocks are commonly used

29

Every file in Unix has a unique number (i-number) that identifies it.

This i-number is used as an index into the table of i-nodes.

A directory is simply a file that contains a set of (i-number, file name) pairs.

30

Implementing Directories

(a) A simple directory (Windows)fixed size entriesdisk addresses and attributes in directory entry

(b) Directory in which each entry just refers to an i-node (Unix)

31

Shared Files

File system containing a shared file

32

(a) Two directories before linking/usr/jim/memo to ast's directory

(b) The same directories after linking

33

Shared Files

Hard Link

(a) Situation prior to linking

(b) After the link is created

(c) Increments the counter in the file’s i-node

34

Symbolic linking

Create a new file of type LINK.This file contains just the path name of the

file to which it is linked

35

Links

Hard linksWhat if the original owner removes the file.Owner’s quota being used

Symbolic linksFile to store path takes up one disk block of

space.Extra i-node needed for each symbolic link.Need to parse the path to get to its i-node.

36

Sharing Files

Two processes can share a mapped file.

A new file mapped simultaneously into two processes

37

Unix System callsmmapunmap

38

UNIX File System

Disk layout in classical UNIX systems

39

UNIX File System

The relation between the file descriptor table, the open file description