The UNIX Time- Sharing System

Similar documents
File Systems. Kartik Gopalan. Chapter 4 From Tanenbaum s Modern Operating System

CS 550 Operating Systems Spring File System

File System Internals. Jo, Heeseung

Lecture 19: File System Implementation. Mythili Vutukuru IIT Bombay

File Systems. CS170 Fall 2018

File System: Interface and Implmentation

Da-Wei Chang CSIE.NCKU. Professor Hao-Ren Ke, National Chiao Tung University Professor Hsung-Pin Chang, National Chung Hsing University

Computer Systems Laboratory Sungkyunkwan University

Logical disks. Bach 2.2.1

Filesystem. Disclaimer: some slides are adopted from book authors slides with permission

CS370: System Architecture & Software [Fall 2014] Dept. Of Computer Science, Colorado State University

Filesystem. Disclaimer: some slides are adopted from book authors slides with permission 1

File System Internals. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

ECE 650 Systems Programming & Engineering. Spring 2018

Chapter 11: Implementing File Systems

File System Case Studies. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Classic Systems: Unix and THE. Presented by Hakim Weatherspoon

File Systems: Fundamentals

File Systems. ECE 650 Systems Programming & Engineering Duke University, Spring 2018

CS370: Operating Systems [Spring 2017] Dept. Of Computer Science, Colorado State University

File Layout and Directories

Introduction to OS. File Management. MOS Ch. 4. Mahmoud El-Gayyar. Mahmoud El-Gayyar / Introduction to OS 1

File Systems: Fundamentals

File System Case Studies. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Outlook. File-System Interface Allocation-Methods Free Space Management

ECE 598 Advanced Operating Systems Lecture 18

CHAPTER 11: IMPLEMENTING FILE SYSTEMS (COMPACT) By I-Chen Lin Textbook: Operating System Concepts 9th Ed.

CS370 Operating Systems

UNIX File System. UNIX File System. The UNIX file system has a hierarchical tree structure with the top in root.

CS2028 -UNIX INTERNALS

Frequently asked questions from the previous class survey

Filesystem. Disclaimer: some slides are adopted from book authors slides with permission 1

Chapter 11: Implementing File Systems

V. File System. SGG9: chapter 11. Files, directories, sharing FS layers, partitions, allocations, free space. TDIU11: Operating Systems

FILE SYSTEMS. CS124 Operating Systems Winter , Lecture 23

CS3600 SYSTEMS AND NETWORKS

CSE 120: Principles of Operating Systems. Lecture 10. File Systems. November 6, Prof. Joe Pasquale

UNIX File Systems. How UNIX Organizes and Accesses Files on Disk

Operating System Concepts Ch. 11: File System Implementation

OPERATING SYSTEM. Chapter 12: File System Implementation

Workloads. CS 537 Lecture 16 File Systems Internals. Goals. Allocation Strategies. Michael Swift

CS370 Operating Systems

CS 4284 Systems Capstone

File Management By : Kaushik Vaghani

File System Internals. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Table 12.2 Information Elements of a File Directory

Chapter 11: Implementing File

CS 318 Principles of Operating Systems

COMP 530: Operating Systems File Systems: Fundamentals

Introduction. Secondary Storage. File concept. File attributes

EECE.4810/EECE.5730: Operating Systems Spring 2017

Chapter 11: Implementing File Systems. Operating System Concepts 9 9h Edition

Chapter 11: File System Implementation. Objectives

FILE SYSTEMS, PART 2. CS124 Operating Systems Fall , Lecture 24

CS370 Operating Systems

File Systems. Todays Plan. Vera Goebel Thomas Plagemann. Department of Informatics University of Oslo

The Operating System Machine Level

CS 318 Principles of Operating Systems

Secondary Storage (Chp. 5.4 disk hardware, Chp. 6 File Systems, Tanenbaum)

COS 318: Operating Systems. Journaling, NFS and WAFL

Files. File Structure. File Systems. Structure Terms. File Management System. Chapter 12 File Management 12/6/2018

b. How many bits are there in the physical address?

Segmentation with Paging. Review. Segmentation with Page (MULTICS) Segmentation with Page (MULTICS) Segmentation with Page (MULTICS)

Pintos Project 4 File Systems. November 14, 2016

Chapter 12: File System Implementation

Chapter 12: File System Implementation

Chapter 10: File System Implementation

TDDB68 Concurrent Programming and Operating Systems. Lecture: File systems

[537] Fast File System. Tyler Harter

File. File System Implementation. File Metadata. File System Implementation. Direct Memory Access Cont. Hardware background: Direct Memory Access

Chapter 10: Case Studies. So what happens in a real operating system?

CS 111. Operating Systems Peter Reiher

Arvind Krishnamurthy Spring Implementing file system abstraction on top of raw disks

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring Lecture 18: Naming, Directories, and File Caching

CIS Operating Systems File Systems. Professor Qiang Zeng Fall 2017

Chapter 4 File Systems. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

ECE 550D Fundamentals of Computer Systems and Engineering. Fall 2017

CIS Operating Systems File Systems. Professor Qiang Zeng Spring 2018

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring Lecture 18: Naming, Directories, and File Caching

Chapter 8. Virtual Memory

Unix System Architecture, File System, and Shell Commands

File System Implementation

W4118 Operating Systems. Instructor: Junfeng Yang

File system internals Tanenbaum, Chapter 4. COMP3231 Operating Systems

CSE 120: Principles of Operating Systems. Lecture 10. File Systems. February 22, Prof. Joe Pasquale

File Systems. File system interface (logical view) File system implementation (physical view)

Che-Wei Chang Department of Computer Science and Information Engineering, Chang Gung University

Last Class: Memory management. Per-process Replacement

Final Exam Preparation Questions

File Systems. Information Server 1. Content. Motivation. Motivation. File Systems. File Systems. Files

Operating Systems. Lecture File system implementation. Master of Computer Science PUF - Hồ Chí Minh 2016/2017

File System Case Studies. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Chapter 12: File System Implementation

Typical File Extensions File Structure

OPERATING SYSTEMS II DPL. ING. CIPRIAN PUNGILĂ, PHD.

The Operating System Machine Level

Operating Systems CMPSC 473 File System Implementation April 10, Lecture 21 Instructor: Trent Jaeger

Chapter 12: File System Implementation. Operating System Concepts 9 th Edition

Chapter 7: File-System

File Systems. What do we need to know?

Transcription:

The UNIX Time- Sharing System Dennis M. Ritchie and Ken Thompson Bell Laboratories Communications of the ACM July 1974, Volume 17, Number 7

UNIX overview Unix is a general-purpose, multi-user, interactive operating system Originally developed for DEC PDP-7, -9, and -11 computers PDP-11/45 16-bit word (8-bit byte) computer 144KB main memory UNIX occupies 42KB 1MB fixed head disk Four 2.5MB removable disk cartridges One 40MB disk pack Also Picturephone, voice response, voice synthesizer, photo typesetter, digital switching network etc. Written in C language Now widely supported across almost all hardware platforms in various variants System V, FreeBSD, Linux, Solaris etc.

Major Innovations Hierarchical file system Compatible file, device, and inter-process I/O Background (asynchronous) and foreground processes Interactive Shell

Original use around 1969-70s preparation and formatting of patent applications and other textual material, the collection and processing of trouble data from various switching machines within the Bell System, and recording and checking telephone service orders

Now Widely used in Servers Desktops Laptops, Netbooks PDAs, phones Mainframes Embedded systems Real-time systems Switches, routers Almost any computing platform you can think of Perhaps paradoxically, the success of UNIX is largely due to the fact that it was not designed to meet any predefined objectives.

Inexpensive! UNIX can run on hardware costing as little as $40,000 Less than two man years were spent on the main system software. users of UNIX will find that the most important characteristics of the system are its simplicity, elegance, and ease of use.

File System Most important role of UNIX is to provide a filesystem. Why? Three types of files Ordinary files No particular structure imposed by OS Directories Mapping between filenames and files Special files I/O devices

Shared Files Hard Links prior to linking After the hard link is created After the original owner removes the file File still exists, but with count decremented

What is a File System? File system is the OS component that organizes data on the raw storage device. Data, by itself, is just a meaningless sequence of bits and bytes. Metadata is the information that describes the data. Also called attributes. Without meta-data, data itself will be incomprehensible. A File System defines Format of the data objects. The format/meaning of meta-data associated with each data object. E.g. File name, permissions, and size of a file. Location of the individual data blocks of for each data object. A framework to manage free space on the raw storage.

Virtual File System (VFS) VFS provides 1. A common system call interface to user applications to access different file systems implemented in the OS. 2. A common interface to file systems to plug into the operating system and provide services to user applications. User Applications File System 1 System Calls Virtual File System File System 2 File System Cache Device Drivers File System N Storage 1 Storage 2 Storage 3

Partitions and File-system Layout File System 1 File System 2 File System 3

Organizing Files on Disk: Contiguous Allocation (a) Contiguous allocation of disk space for 7 files (b) State of the disk after files D and E have been removed

Organizing Files on Disk: Singly Linked List of Blocks Advantage: Logically contiguous blocks can be discontiguous on disk Disadvantage: Random seeks are expensive. Requires traversal from the start.

Organizing Files on Disk: File Allocation Table Linked list allocation using a file allocation table in RAM Doesn t need a separate next pointer within each block But random seeks are still expensive

i-nodes (index nodes) Each file is described by an i-node i-node stores the metadata for the file Metadata = file info + location of data blocks i-nodes are stored on the disk An i-node is to a file what a page-table is to a virtual address space Page table maps virtual page number in a virtual address space > physical page frame number in DRAM i-node maps logical block number in a file > physical block location on disk

Unix i-node (index node) Small files can be accessed quickly If each block is 4KB First 48KB of file reachable from 12 direct blocks Next 4MB available from single-indirect blocks Next 4GB available from double-indirect blocks Next 4TB available through the triple-indirect blocks Any block can be found with at most 3 disk accesses

Another view of a UNIX i-node Ref: Tanenbaum s OS book The whole data structure above is ONE i-node for ONE file i-node grows dynamically as the file grows Just like page-tables, i-node tracks a giant array broken up into many pieces

most unusual feature Located in /dev Just like ordinary files. Special files But read/write requests result in activation of the associated device. Advantages of treating I/O devices as files: File and device I/O are similar File and device names have same syntax and meaning. Programs that operate on files can also operate on devices. Same protection mechanisms as regular files

Removable file system Different parts of filesystem can be on different devices mount Allows a storage device to be referenced as a subtree of existing rooted filesystem. Hard links across mounted file systems disallowed. Why?

Each user has a userid Protection Files marked as owned with userid of the creator Seven protection bits Six bits for read, write, and execute permissions for user, group, and others 7 th bit set-user-id bit Temporarily change the userid of current user to the owner when file is executed as a program. Allows the safe use of privileged programs that require access to special system files (e.g. system logs). Actual userid of the invoker is available to the program for credential checks.

I/O calls filep = open (name, flag) Create system call creates and opens a new file. Truncates to zero if file exists. filep is a file descriptor Notion of a file descriptor hasn t changed over the years No locking provided by OS for multi-user access Lets users figure out synchronization. Locks are neither necessary nor sufficient. Why? Internal OS locks for consistency of data structures n = read(filep, buffer, count) Read returns 0 when end of file (EOF) reached n = write(filep, buffer, count) Write beyond end of file grows the file automatically location = seek(filep, base, offset) For random I/O

Processes and images processid = fork(label) filep = pipe( ) execute(file, args, argo,..., arg,+) processid = wait( ) exit (status)

Shell Triggered upon login by the init process Can be replaced by other commands command arg1 arg2 - argn ls > there ed < script Filters: ls grep foo wc -l Multitasking ls; ed as source > output & as source > output & ls > files & (date; ls) > x &

read/write buffering System buffers to hide block I/O activity Users can read/write at any byte granularity OS converts these to block-level I/O

File System Cache Small area in main memory that stores frequently accessed data blocks in the file system. Before accessing the disk, look in the FS cache. If data block is in FS cache, no need to go to disk. Periodically, purge the cache of infrequently used data blocks. Claim: If the cache works well, then most I/O accesses to the physical disk will be writes. Why?

Data Structure for File-System Cache Cache Lookup: Pages in cache are looked up via a hash table for fast access. Cache Eviction: Another doubly-linked list maintained to identify least-recently used (LRU) victim pages that are periodically purged. Is the victim page dirty? Then write to disk. Else discard.

Virtual memory page cache and FS cache Often they are managed in a unified manner Meaning: one common page-cache is used for managing pages for both virtual memory and file system. For example, Linux maintains one common set of data structures to keep track of active and inactive (LRU) pages.

Log-Structured File Systems With CPUs faster, memory larger disk caches are also getting larger increasing number of read requests come from file system cache Thus, most disk accesses will be writes LFS treats the entire disk as a log all writes are initially buffered in memory periodically commit the writes to the end of the disk log When file is opened, locate i-node, then find blocks

Quiz on Inodes All blocks in a disk are of size 4KB (4096 bytes). A disk block can store either data or metadata (but not both). Each block address, i.e. a block s location on the disk, is 8-bytes in size Assume that all file attributes other than data block addresses, take up negligible space in the top-level block of inode block. Last three entries of the top-level block of inode contain single, double, and triple indirect block addresses. Rest of the space in the top-level inode (between end of attributes and singleindirect block address) is used to store direct block addresses. Question 1: What is the largest size of a file that can be accessed through direct block entries? direct + single indirect block entries? direct + single + double indirect block entries? direct + single + double + triple indirect block entries? Question 2: What is the size of an inode (in bytes) for a 32GB file?