Top Banner
CS 149: Operating Systems April 7 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak www.cs.sjsu.edu/~mak
39

CS 149: Operating Systems April 7 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak mak.

Jan 03, 2016

Download

Documents

Morgan Miller
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: CS 149: Operating Systems April 7 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak mak.

CS 149: Operating SystemsApril 7 Class Meeting

Department of Computer ScienceSan Jose State University

Spring 2015Instructor: Ron Mak

www.cs.sjsu.edu/~mak

Page 2: CS 149: Operating Systems April 7 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak mak.

2Computer Science Dept.Spring 2015: April 7

CS 149: Operating Systems© R. Mak

Unofficial Field Trip

Computer History Museum in Mt. View http://www.computerhistory.org/

Saturday, May 9, 11:30 – closing time

Special free admission. Do a self-guided tour of the new Revolution exhibit. See a life-size working model of Charles Babbage’s

Difference Engine in operation, a hand-cranked mechanical computer designed in the early 1800s.

Experience a fully restored IBM 1401 mainframe computer from the early 1960s in operation. General info: http://en.wikipedia.org/wiki/IBM_1401 My summer seminar: http://www.cs.sjsu.edu/~mak/1401/ Restoration:

http://ed-thelen.org/1401Project/1401RestorationPage.html

Page 3: CS 149: Operating Systems April 7 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak mak.

3Computer Science Dept.Spring 2015: April 7

CS 149: Operating Systems© R. Mak

Unofficial Field Trip

The new Revolution exhibit is now open! Walk through a timeline of the

First 2000 Years of Computing History. Historic computer systems, data processing equipment,

and other artifacts. Small theater presentations.

Atanasoff-Berry Computer

HollerithCensus

Machine

Page 4: CS 149: Operating Systems April 7 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak mak.

4Computer Science Dept.Spring 2015: April 7

CS 149: Operating Systems© R. Mak

Unofficial Field Trip Babbage Difference Engine,

fully operational. Hand-cranked mechanical

computer. Computed polynomial

functions. Designed by Charles

Babbage in the early to mid 1800s. Arguably the world’s

first computer scientist, lived 1791-1871.

He wasn’t able to build it because he lost his funding.

Live demo at 1:00

His plans survived and this working model was built. Includes a working printer!

http://www.computerhistory.org/babbage/

Page 5: CS 149: Operating Systems April 7 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak mak.

5Computer Science Dept.Spring 2015: April 7

CS 149: Operating Systems© R. Mak

Unofficial Field Trip IBM 1401 computer, fully restored and operational

A small transistor-based mainframe computer. Extremely popular with small businesses in the late 1950s

through the mid 1960s Maximum of 16K bytes of memory. 800 card/minute card reader (wire brushes). 600 line/minute line printer (impact). 6 magnetic tape drives, no disk drives.

Page 6: CS 149: Operating Systems April 7 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak mak.

6Computer Science Dept.Spring 2015: April 7

CS 149: Operating Systems© R. Mak

File Structure

UNIX supports a minimal set of file structures.

A file is simply a stream of bytes. Each byte is addressable by its offset

from the file beginning or end. User programs can organize these bytes

into fixed- or variable-length records.

Other operating systems (especially on older machines) supported other file structures.

Page 7: CS 149: Operating Systems April 7 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak mak.

7Computer Science Dept.Spring 2015: April 7

CS 149: Operating Systems© R. Mak

Sequential Access Method

Programs access the records in forward order, one after another.

The file pointer keeps track of the I/O location. Read the next record. Append to the end of the file. Rewind to the beginning of the file. Skip to record n

Operating Systems Concepts, 9th editionSilberschatz, Galvin, and Gagne (c) 2013 John Wiley & Sons. All rights reserved. 978-1-118-06333-0

Page 8: CS 149: Operating Systems April 7 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak mak.

8Computer Science Dept.Spring 2015: April 7

CS 149: Operating Systems© R. Mak

Direct (Random) Access Method

Programs can read or write records rapidly in any order. Each record has a position which is a relative block

number n relative to the beginning of the file. Fixed-length records.

read(n) write(n) position_to(n) read_next() write_next() rewrite(n)

Why?

Page 9: CS 149: Operating Systems April 7 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak mak.

9Computer Science Dept.Spring 2015: April 7

CS 149: Operating Systems© R. Mak

Other Access Methods

Build other access methods on top of direct-access. Example: An indexed access method.

Operating Systems Concepts, 9th editionSilberschatz, Galvin, and Gagne (c) 2013 John Wiley & Sons. All rights reserved. 978-1-118-06333-0

Page 10: CS 149: Operating Systems April 7 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak mak.

10Computer Science Dept.Spring 2015: April 7

CS 149: Operating Systems© R. Mak

Disk Structure

A disk can be subdivided into partitions.

Disks or partitions can be RAID-protected against failure.

Raw disk or partition: without a file system Formatted: with a file system

Volume: An entity containing a file system.

Each volume tracks its file system’s information in a device directory or volume table of contents.

Page 11: CS 149: Operating Systems April 7 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak mak.

11Computer Science Dept.Spring 2015: April 7

CS 149: Operating Systems© R. Mak

Disk Structure, cont’d

Operating Systems Concepts, 9th editionSilberschatz, Galvin, and Gagne (c) 2013 John Wiley & Sons. All rights reserved. 978-1-118-06333-0

Page 12: CS 149: Operating Systems April 7 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak mak.

12Computer Science Dept.Spring 2015: April 7

CS 149: Operating Systems© R. Mak

Disk Structure, cont’d

Along with general-purpose file systems, there are many special-purpose file systems.

Frequently, all the file systems reside within the same operating system or computer.

Page 13: CS 149: Operating Systems April 7 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak mak.

13Computer Science Dept.Spring 2015: April 7

CS 149: Operating Systems© R. Mak

Directories

A directory is a container (“folder”) of files.

Provides a way to organize a collection of files on disk.

Page 14: CS 149: Operating Systems April 7 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak mak.

14Computer Science Dept.Spring 2015: April 7

CS 149: Operating Systems© R. Mak

Directory Operations

Efficiency Locate a file quickly.

Naming Convenient to users. Two users can have same name for different files. The same file can have several different names.

Grouping Logical grouping of files by properties.

Page 15: CS 149: Operating Systems April 7 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak mak.

15Computer Science Dept.Spring 2015: April 7

CS 149: Operating Systems© R. Mak

Directory Operations, cont’d

Operations

Create a file Delete a file Search for a file Rename a file List a directory Traverse the file system

Page 16: CS 149: Operating Systems April 7 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak mak.

16Computer Science Dept.Spring 2015: April 7

CS 149: Operating Systems© R. Mak

Single-Level Directory

A single directory for all users.

Disadvantages: Naming Grouping

Operating Systems Concepts, 9th editionSilberschatz, Galvin, and Gagne (c) 2013 John Wiley & Sons. All rights reserved. 978-1-118-06333-0

Page 17: CS 149: Operating Systems April 7 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak mak.

17Computer Science Dept.Spring 2015: April 7

CS 149: Operating Systems© R. Mak

Two-Level Directory

The operating system maintains a master file directory.

Each user has a user file directory.

Operating Systems Concepts, 9th editionSilberschatz, Galvin, and Gagne (c) 2013 John Wiley & Sons. All rights reserved. 978-1-118-06333-0

Page 18: CS 149: Operating Systems April 7 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak mak.

18Computer Science Dept.Spring 2015: April 7

CS 149: Operating Systems© R. Mak

Two-Level Directory, cont’d

Advantages Different users can use the same file names. More efficient searching.

Disadvantages No grouping. Operating Systems Concepts, 9th edition

Silberschatz, Galvin, and Gagne (c) 2013 John Wiley & Sons. All rights reserved. 978-1-118-06333-0

Page 19: CS 149: Operating Systems April 7 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak mak.

19Computer Science Dept.Spring 2015: April 7

CS 149: Operating Systems© R. Mak

Tree-Structured Directories

Users can create their own subdirectories.

Operating Systems Concepts, 9th editionSilberschatz, Galvin, and Gagne (c) 2013 John Wiley & Sons. All rights reserved. 978-1-118-06333-0

Page 20: CS 149: Operating Systems April 7 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak mak.

20Computer Science Dept.Spring 2015: April 7

CS 149: Operating Systems© R. Mak

Acyclic-Graph Directories

Allow shared directories and files.

Links Resolve a link by locating the actual file or directory. Symbolic links

Operating Systems Concepts, 9th editionSilberschatz, Galvin, and Gagne (c) 2013 John Wiley & Sons. All rights reserved. 978-1-118-06333-0

Page 21: CS 149: Operating Systems April 7 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak mak.

21Computer Science Dept.Spring 2015: April 7

CS 149: Operating Systems© R. Mak

File Path Names

Absolute path name

Begins with the root / Example: /usr/local/make

Relative path name

Search begins with the current directory . current directory .. parent directory

Example: cd /usrls local/make

Page 22: CS 149: Operating Systems April 7 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak mak.

22Computer Science Dept.Spring 2015: April 7

CS 149: Operating Systems© R. Mak

File Path Names, cont’d

Modern Operating Systems, 3rd ed.Andrew Tanenbaum(c) 2008 Prentice-Hall, Inc.. 0-13-600663-9All rights reserved

Page 23: CS 149: Operating Systems April 7 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak mak.

23Computer Science Dept.Spring 2015: April 7

CS 149: Operating Systems© R. Mak

Mounting a File System

Mount an external file system in order to access it.

This file system can be located on another disk or on some external removable medium (such as a DVD ROM).

Define a mount point in the current file system. Usually, it’s an empty directory.

Page 24: CS 149: Operating Systems April 7 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak mak.

24Computer Science Dept.Spring 2015: April 7

CS 149: Operating Systems© R. Mak

Mounting a File System, cont’d

Mount the external file system onto the mount point.

Now the contents of the external file system appear under the directory name of the mount point.

If the mount point was not an empty directory, the files that were stored in that directory are now hidden and inaccessible.

Page 25: CS 149: Operating Systems April 7 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak mak.

25Computer Science Dept.Spring 2015: April 7

CS 149: Operating Systems© R. Mak

Mounting a File System, cont’d

a) The current file system

b) A volume on /devices/dskOperating Systems Concepts, 9th editionSilberschatz, Galvin, and Gagne (c) 2013 John Wiley & Sons. All rights reserved. 978-1-118-06333-0

Page 26: CS 149: Operating Systems April 7 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak mak.

26Computer Science Dept.Spring 2015: April 7

CS 149: Operating Systems© R. Mak

Mounting a File System, cont’d

The result of mounting /devices/dsk onto /users. The previous contents of /users

are no longer accessible.Operating Systems Concepts, 9th editionSilberschatz, Galvin, and Gagne (c) 2013 John Wiley & Sons. All rights reserved. 978-1-118-06333-0

Page 27: CS 149: Operating Systems April 7 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak mak.

27Computer Science Dept.Spring 2015: April 7

CS 149: Operating Systems© R. Mak

File Protection

The file owner or creator should be able to control:

What can be done to the file By whom

Types of access:

Read Write Execute

Append Delete List

Page 28: CS 149: Operating Systems April 7 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak mak.

28Computer Science Dept.Spring 2015: April 7

CS 149: Operating Systems© R. Mak

File Protection in UNIX

Types of access: read, write, execute (RWX) Three classes of users and sample access:

RWXa) owner access 7 1 1 1b) group access 6 1 1 0c) public access 4 1 0 0

For a particular file or directory (such as game), define an appropriate access with thechmod command.

owner group public

chmod 764 game

Page 29: CS 149: Operating Systems April 7 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak mak.

29Computer Science Dept.Spring 2015: April 7

CS 149: Operating Systems© R. Mak

File Protection in UNIX, cont’d

Sample UNIX file listing via the ls command. Access rights to each file and directory

are at the left.

Page 30: CS 149: Operating Systems April 7 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak mak.

30Computer Science Dept.Spring 2015: April 7

CS 149: Operating Systems© R. Mak

Layered File System Architecture

I/O control

Device drivers Interrupt handlers

Basic file system

Issue generic commands to the device drivers.

Manage memory buffers and caches that hold file system, directory, and data blocks.

Operating Systems Concepts, 9th editionSilberschatz, Galvin, and Gagne (c) 2013 John Wiley & Sons. All rights reserved. 978-1-118-06333-0

Page 31: CS 149: Operating Systems April 7 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak mak.

31Computer Science Dept.Spring 2015: April 7

CS 149: Operating Systems© R. Mak

Layered File System Architecture, cont’d

File-organization module

Manage logical and physical blocks of files.

Translate logical block addresses to physical block address.

Logical file system

Manage file metadata. File control blocks

(UNIX inodes)Operating Systems Concepts, 9th editionSilberschatz, Galvin, and Gagne (c) 2013 John Wiley & Sons. All rights reserved. 978-1-118-06333-0

Page 32: CS 149: Operating Systems April 7 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak mak.

32Computer Science Dept.Spring 2015: April 7

CS 149: Operating Systems© R. Mak

File System Layout on Disk

Master Boot Record (MBR)

Located at sector 0 of the disk Used to boot the computer Contains the disk partition table Contains code to boot the computer

The MBR code locates the active disk partition.

Read and execute the boot block of the active partition.

Load the operating system residing in the partition.

Page 33: CS 149: Operating Systems April 7 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak mak.

33Computer Science Dept.Spring 2015: April 7

CS 149: Operating Systems© R. Mak

File System Layout on Disk, cont’d

The superblock

Contains key parameters about the file system that is read into main memory.

File-control blocks (UNIX inodes)

Array of data structures, one per file. Information about each file:

Where its disk blocks are located, etc.

Page 34: CS 149: Operating Systems April 7 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak mak.

34Computer Science Dept.Spring 2015: April 7

CS 149: Operating Systems© R. Mak

File System Layout on Disk, cont’d

Root directory Other directories and files

Modern Operating Systems, 3rd ed.Andrew Tanenbaum(c) 2008 Prentice-Hall, Inc.. 0-13-600663-9All rights reserved

Page 35: CS 149: Operating Systems April 7 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak mak.

35Computer Science Dept.Spring 2015: April 7

CS 149: Operating Systems© R. Mak

Contiguous File Allocation

Each file occupies a set of contiguous blocks.

Usually best performance. Simple: Requires only the

starting location (block #) and length (block count).

Problems Finding space for file Knowing the file size External fragmentation Need for compaction

Still used today on CD ROMs and DVDs.

Operating Systems Concepts, 9th editionSilberschatz, Galvin, and Gagne (c) 2013 John Wiley & Sons. All rights reserved. 978-1-118-06333-0

Page 36: CS 149: Operating Systems April 7 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak mak.

36Computer Science Dept.Spring 2015: April 7

CS 149: Operating Systems© R. Mak

Linked File Allocation

Each file is a linked list of blocks. No external fragmentation. No compaction.

Each block contains a pointer to the next block. Free space management system

called when a new block needed. Improve efficiency by clustering

blocks into groups, but increases internal fragmentation.

Locating a block can take many I/Os and disk seeks. Poor random access performance. Reliability can be a problem. Operating Systems Concepts, 9th edition

Silberschatz, Galvin, and Gagne (c) 2013 John Wiley & Sons. All rights reserved. 978-1-118-06333-0

Page 37: CS 149: Operating Systems April 7 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak mak.

37Computer Science Dept.Spring 2015: April 7

CS 149: Operating Systems© R. Mak

File Allocation Table (FAT)

At the beginning of a volume Indexed by block number Much like a linked list. Used by Microsoft Windows.

Needs to be cached in memory for performance.

Simple to allocate a new block. Operating Systems Concepts, 9th edition

Silberschatz, Galvin, and Gagne (c) 2013 John Wiley & Sons. All rights reserved. 978-1-118-06333-0

Page 38: CS 149: Operating Systems April 7 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak mak.

38Computer Science Dept.Spring 2015: April 7

CS 149: Operating Systems© R. Mak

Indexed File Allocation

Each file has its own index block, an array of disk-block addresses.

No external fragmentation.

Overhead of the index block.

Operating Systems Concepts, 9th editionSilberschatz, Galvin, and Gagne (c) 2013 John Wiley & Sons. All rights reserved. 978-1-118-06333-0

Page 39: CS 149: Operating Systems April 7 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak mak.

39Computer Science Dept.Spring 2015: April 7

CS 149: Operating Systems© R. Mak

UNIX Inode

Operating Systems Concepts, 9th editionSilberschatz, Galvin, and Gagne (c) 2013 John Wiley & Sons. All rights reserved. 978-1-118-06333-0

UNIX inode has pointers to: direct blocks single indirect blocks double indirect blocks triple indirect blocks