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

Similar documents
Operating Systems. Week 9 Recitation: Exam 2 Preview Review of Exam 2, Spring Paul Krzyzanowski. Rutgers University.

Main Points. File layout Directory layout

COMP 530: Operating Systems File Systems: Fundamentals

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

File System Implementation. Sunu Wibirama

CS 550 Operating Systems Spring File System

Operating Systems Design Exam 2 Review: Spring 2011

Operating Systems Design Exam 2 Review: Spring 2012

CS 416: Opera-ng Systems Design March 23, 2012

File Systems: Fundamentals

Operating Systems. Operating Systems Professor Sina Meraji U of T

File Systems: Fundamentals

File Systems. CS170 Fall 2018

File System Internals. Jo, Heeseung

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

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

Operating Systems. File Systems. Thomas Ropars.

Disk Scheduling COMPSCI 386

ECE 650 Systems Programming & Engineering. Spring 2018

we are here I/O & Storage Layers Recall: C Low level I/O Recall: C Low Level Operations CS162 Operating Systems and Systems Programming Lecture 18

Main Points. File layout Directory layout

File Systems. Before We Begin. So Far, We Have Considered. Motivation for File Systems. CSE 120: Principles of Operating Systems.

I/O and file systems. Dealing with device heterogeneity

Midterm Exam #3 Solutions November 30, 2016 CS162 Operating Systems

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

Lecture S3: File system data layout, naming

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

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

22 File Structure, Disk Scheduling

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

CIS Operating Systems File Systems. Professor Qiang Zeng Spring 2018

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

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

FILE SYSTEM IMPLEMENTATION. Sunu Wibirama

CS 537 Fall 2017 Review Session

we are here Page 1 Recall: How do we Hide I/O Latency? I/O & Storage Layers Recall: C Low level I/O

Operating Systems Design Exam 2 Review: Fall 2010

CIS Operating Systems File Systems. Professor Qiang Zeng Fall 2017

File Management By : Kaushik Vaghani

File System Concepts File Allocation Table (FAT) New Technology File System (NTFS) Extended File System (EXT) Master File Table (MFT)

Computer Systems Laboratory Sungkyunkwan University

File System Implementation

Introduction. Secondary Storage. File concept. File attributes

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

19 File Structure, Disk Scheduling

File Systems. Chapter 11, 13 OSPP

FILE SYSTEMS. CS124 Operating Systems Winter , Lecture 23

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

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

CS 318 Principles of Operating Systems

Final Exam Solutions May 17, 2013 CS162 Operating Systems

Page 1. Recap: File System Goals" Recap: Linked Allocation"

Chapter 11: Implementing File Systems

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

CS 318 Principles of Operating Systems

The UNIX Time- Sharing System

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

Table 12.2 Information Elements of a File Directory

CSCI 350 Ch. 13 File & Directory Implementations. Mark Redekopp Michael Shindler & Ramesh Govindan

Page 1. Review: Storage Performance" SSD Firmware Challenges" SSD Issues" CS162 Operating Systems and Systems Programming Lecture 14

CS162 Operating Systems and Systems Programming Lecture 14 File Systems (Part 2)"

Chapter 11: File System Implementation. Objectives

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

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

Chapter 14: File-System Implementation

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

Final Exam Preparation Questions

File System Implementation

CS4411 Intro. to Operating Systems Final Fall points 10 pages

e-pg Pathshala Subject: Computer Science Paper: Operating Systems Module 35: File Allocation Methods Module No: CS/OS/35 Quadrant 1 e-text

EI 338: Computer Systems Engineering (Operating Systems & Computer Architecture)

Ricardo Rocha. Department of Computer Science Faculty of Sciences University of Porto

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

File Layout and Directories

Department of Computer Engineering University of California at Santa Cruz. File Systems. Hai Tao

File. File System Implementation. Operations. Permissions and Data Layout. Storing and Accessing File Data. Opening a File

Chapter 12: File System Implementation

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

SMD149 - Operating Systems - File systems

ECE 598 Advanced Operating Systems Lecture 18

W4118 Operating Systems. Instructor: Junfeng Yang

Frequently asked questions from the previous class survey

File System: Interface and Implmentation

CS3600 SYSTEMS AND NETWORKS

Local File Stores. Job of a File Store. Physical Disk Layout CIS657

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

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

Lecture 19: File System Implementation. Mythili Vutukuru IIT Bombay

Fall COMP3511 Review

Chapter 8: Filesystem Implementation

CS370 Operating Systems

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

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

Chapter 6: File Systems

Midterm II December 4 th, 2006 CS162: Operating Systems and Systems Programming

Question Points Score Total 100

CS 416: Opera-ng Systems Design May 2, 2012

Windows File System. File allocation table (FAT) NTFS - New Technology File System. used in Windows 95, and MS-DOS

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

Chapter 12: File System Implementation

Transcription:

EECE.4810/EECE.5730: Operating Systems Spring 2017 1. (16 points) Storage devices Final Exam Solution Assume you have a magnetic hard disk with tracks numbered from 0-127, track 0 being the outermost track. As a simplifying assumption, assume all tracks have 64 sectors numbered 0-63. Given the list of read requests to specific sectors listed below, show the order in which the sectors would be read using (a) shortest seek time first (SSTF) scheduling and (b) SCAN scheduling. Use the following assumptions: Given a sector, S, another sector in the same track as S will be closer (and therefore have a shorter seek time) than a sector in a different track. Seek time is directly proportional to the difference between track numbers. For example, moving from track 1 to track 2 would take half as long as moving from track 5 to track 7. Multiple sectors in the same track will be read in ascending order (lowest number first). The sequence should always start with the first request in the list (track 40, sector 5). Once that request has been serviced, all other requests can be serviced in any order. Request list: i. Track 40, sector 5 ii. Track 15, sector 60 iii. Track 100, sector 0 iv. Track 95, sector 12 v. Track 40, sector 63 vi. Track 0, sector 0 vii. Track 15, sector 59 viii. Track 127, sector 63 SOLUTION: The table below shows the ordering of requests for each of the two algorithms. The SCAN solution assumes the disk head starts by moving toward the center of the disk, toward higher track numbers. If you assume it starts by moving out, then the requests from track 15 are serviced first (once it completes servicing track 40), and the order will be the same as SSTF. SSTF SCAN 1 (i) T40, S5 (i) T40, S5 2 (v) T40, S63 (v) T40, S63 3 (vii) T15, S59 (iv) T95, S12 4 (ii) T15, S60 (iii) T100, S0 5 (vi) T0, S0 (viii) T127, S63 6 (iv) T95, S12 (vii) T15, S59 7 (iii) T100, S0 (ii) T15, S60 8 (viii) T127, S63 (vi) T0, S0 1

2. (18 + 6 points) File system implementation a. (6 points) Operating systems often contain direct support for one specific file type but otherwise require applications to impose other types based on file structure. What one type must the operating system support, and why? SOLUTION: Operating systems must support executable files because loading and running a program requires intervention from the kernel. b. (6 points) The open-file table, which contains information about open files, is typically split into one centralized table and several per-process tables. Name one piece of information stored in the centralized table and explain why it is kept centrally, and name one piece of information stored in a per-process table and explain why it is kept on a per-process basis. SOLUTION: We discussed the following information in class and which table (central or perprocess) it is kept in. One thing from each list is sufficient for this problem. Central table o File open count (# processes accessing file) when this number reaches 0, file can be closed. A central copy is more space efficient and easier to synchronize access to than multiple per-process copies. o Disk location of the file the physical file location. Since every file access must go through the file system anyway, no need to keep multiple copies of this info. Per-process table o File pointer location at which current process may read/write file. May be different for every process. o Access rights allowed operations on this file for this process. Again, may be different for every process. c. (6 points) A file created on a Unix system should be readable to the public, readable and executable to its group, and readable, writeable, and executable to its owner. What 3-digit integer represents the access rights for this file? Briefly explain your answer. SOLUTION: When specifying Unix access rights using a single integer, each digit is a three bit value in which the leftmost bit enables read access (if it s set to 1), the middle bit enables write access, and the rightmost bit enables execute access. The digits are ordered as (left to right) owner, group, and public. Therefore, the access rights should be written as follows: Owner: R W X à 111 2 = 7 Group: R X à 101 2 = 5 Public: R à 100 2 = 4 Therefore, the three-digit integer representing this file s access rights is 754. 2

1 (continued) d. (6 points, EECE.5730 only) We discussed the different layers of a typical file system, from the logical file system down to the device drivers. Some of these layers deal with logical addresses within a file, while others deal with physical addresses. Explain how and when logical file addresses and physical file addresses are used. SOLUTION: Logical file addresses represent an offset within the file as a logical unit, a file is seen as a contiguous collection of blocks, starting with block 0. The application and logical file system use these addresses. Physical file addresses represent an actual block location on disk. Multiple blocks within the same file may have contiguous addresses or they may be scattered, depending on the block allocation scheme used. The basic file system and I/O control levels of the file system use these addresses. 3

3. (18 + 9 points) Block allocation and free space management a. (6 points) Explain the difference between extent-based file allocation and linked file allocation. SOLUTION: Extent-based file allocation is a form of contiguous allocation in which a file is broken into multiple contiguous chunks (extents); linked file allocation typically allocates space in units of one block, although blocks can be clustered together for performance, and builds a linked list of blocks. The biggest difference is in how the addresses are stored. In an extent-based system, the file system stores the starting address and size of each extent as part of the file s metadata. In a linked file allocation system, the file system stores the address of the first file block as part of the metadata, and each block stores the address of the block that follows it in the linked list. b. (6 points) Explain the difference between basic linked allocation of file blocks and the file allocation table (FAT) block allocation scheme. SOLUTION: Both schemes maintain a linked list of file blocks. In basic linked allocation, each block contains the address of the block that follows it in the linked list. In a FAT block allocation scheme, the linked list is stored in a table (the FAT) within the file metadata. c. (6 points) The two most common methods for managing free space in a file system are bitmaps and linked free space lists. Give one benefit of a bitmap over a linked free space list, and one benefit of a linked free space list over a bitmap. SOLUTION: Bitmaps make it relatively simple to find free blocks, especially when contiguous groups of blocks are requested. A linked free space list is much more space efficient than a bitmap. 4

3 (continued) d. (9 points, EECE.5730 only) Recall our discussion of the Berkeley Fast File System (FFS), which organizes its inodes as shown below. Each inode contains 12 direct pointers to disk blocks, as well as three other pointers an indirect pointer, a doubly indirect pointer, and a triply indirect pointer. (Only the inode array and a single inode are shown not all pointers.) Assume each pointer is 32 bits and each disk block is 8 KB. If a file in this file system is 16 GB, how much space is allocated to store all of the pointers (whether direct or indirect) required to access all blocks in that file? Show all of your work for full credit. Inode Array Inode Triple Indirect Blocks Double Indirect Blocks Indirect Blocks Data Blocks File Metadata Direct Pointer Direct Pointer Indirect Pointer Dbl. Indirect Ptr. Tripl. Indirect Ptr. SOLUTION: What the original picture didn t show is how the pointers are used each pointer goes to a single 8 KB disk block. The first 12 blocks those accessed by the direct pointers contain data, while the other blocks contain more pointers to more blocks. The number of additional levels of block pointers depends on the level of indirection. (Full picture above) To determine the amount of space required to store the block pointers, consider the following: The file is 16 GB = 2 34 bytes, while each block is 8 KB = 2 13 bytes. So, the file is composed of 2 34 / 2 13 = 2 21 blocks, each of which requires its own pointer. Each indirect block contains 2 13 / 2 2 = 2 11 pointers, since a pointer is 4 = 2 2 bytes. The necessary pointers are organized as follows: o Direct pointers account for 12 blocks o The indirect pointer points to one indirect block, which points to 2 11 blocks. o That leaves 2 21 2 11 blocks unaccounted for (the 12 blocks handled by the direct pointers are insignificant in this calculation) o 2 21 2 11 = 2 11 * (2 10 1) à since each indirect block points to 2 11 blocks, we need 2 10 1 of the indirect blocks that the doubly-indirect block points to. o The triply-indirect pointer is unused (but still takes up space) So, the total amount of pointer space is the sum of the space in the inode, indirect block, doublyindirect block, and 2 10 1 indirect blocks pointed to by the doubly-indirect block: (15 * 4 bytes) + (8 KB) + (8 KB) + ((2 10 1) * 8 KB = 60 + 2 13 + 2 13 + 2 23 2 13 = 2 23 + 2 13 + 60 bytes = 8396860 bytes 5

(12 points) Reliability a. (6 points) Explain why methods for ensuring reliability in file systems center on operations that write a single sector. SOLUTION: Writing a single sector is the only atomic operation disks support, so methods for reliability in file systems preventing loss of data aim to make multi-step changes to the file system reliant on that one atomic operation. b. (6 points) A Linux variant called TxOS, developed at the University of Texas, supports transactions with shadowing by decomposing inodes into two parts: a header that contains infrequently modified data about each file, and a data component holding fields that are commonly modified by system calls. The header contains a pointer to the related data component, and the data component contains a pointer to the header. Explain how this inode organization makes it relatively easy to implement shadowing for changes to a file s metadata. SOLUTION: Shadowing requires the file system to create a shadow copy of any data to be changed while maintaining a pointer to the current version. Changes are made to the shadow copy and committed by changing the pointer from the current version to the shadow copy. By splitting the metadata into a header and data section, creating a shadow copy of the frequently changed data without copying the header is simple. The pointer within the header section can be pointed to the shadow copy of the data once changes to it are complete. 6

4. (21 points) Distributed systems a. (6 points) In a distributed system, a process running on one node sends a byte stream to another node; the byte stream is split into several messages. How will the system recognize and handle (i) messages received out of order and (ii) dropped messages? In your answer, specify which process (sender or receiver) is responsible for detecting each of these issues. SOLUTION: (i) The header of each message contains a sequence number. The receiving process can use this number to place messages in the correct order. (ii) The sending process waits for acknowledgement that each message has been received. If that acknowledgement is not received within a predefined amount of time, the sending process assumes the message was dropped and retransmits it. b. (6 points) Distributed file systems often allow nodes to cache local copies of shared data, using either write-through or write-back policies to handle changes to those data. List one benefit of using write-through file caching, and one benefit of using write-back file caching. SOLUTION: Write-through caching provides good reliability, as every change to a cached copy is written to the permanent state of the file. Write-back caching provides better performance, as multiple repeated writes are significantly slower than only writing data back when strictly necessary. c. (9 points) A client process uses a binary search tree to store a set of 32-bit integers, one integer per node. The 32-bit address of the tree s root node is passed as the only argument to a remote procedure call to be executed in a server process. If the binary search tree contains 15 values, what is the minimum amount of space required to marshal the parameter or parameters of this function such that the remote procedure can access the entire binary search tree stored by the client? Show your work for full credit. SOLUTION: The amount of space required for the binary search tree is dependent on the organization of data within it, but a complete binary tree one in which every level is full can be efficiently stored in an array, with the root of the tree in the first array location, its in the next two locations, and so on. The number of nodes should be passed at the beginning of the array so the tree can be unpacked at the server. A sample array organization is shown below. 15 8 4 12 2 6 10 14 1 3 5 7 9 11 13 15 # nodes root of root of 4 of 12 of 2 of 6 of 10 of 14 Each integer in the array takes up 4 bytes, while the number of nodes can potentially be stored in just a single byte. The minimum amount of space required to store this tree is therefore: (15 nodes) * (4 bytes/node) + (1 byte for # nodes) = 60 + 1 = 61 bytes 7

5. (15 + 5 points) Protection and security a. (9 points) Given the access matrix below, answer questions (i)-(iii). Objects Domains F 1 F 2 F 3 D 1 D 2 D 3 D 4 read* D 1 write control write* D 2 owner read D 3 read* owner D 4 write write control i. Can a process in domain D 1 grant read privileges for object F 3 to a process in domain D 2? Why or why not? SOLUTION: Yes D 1 has control rights for D 2. ii. Can a process in domain D 3 revoke the write privileges of a process in domain D 1 for object F 3? Why or why not? SOLUTION: No D 3 would need owner rights for F 3 to revoke privileges in another domain. iii. Can a process in domain D 2 give read, write, and execute privileges for object F 2 to a process in domain D 3? Why or why not? SOLUTION: Yes D 2 has owner rights for F 2. 8

6 (continued) b. (6 points) Two professors are discussing the security of a distributed system in which the key used to encrypt messages is known. Professor A claims that knowing the encryption key will allow him to decrypt any message sent between nodes in the system once he determines the type of cryptography used, thus making the system insecure. Professor B claims it is possible for the system to be secure, depending on what method is used to encrypt messages. Which professor is right, and why? SOLUTION: Professor B is correct. Asymmetric encryption schemes use two different keys a public key for encryption and private keys for decryption. Since the type of encryption used is not specified, it s possible the system is using asymmetric encryption and is therefore secure. c. (5 points, EECE.5730 only) Briefly explain how default access rights are implemented in an access list. SOLUTION: An access list is a per-object collection of access rights, organized as pairs of domains and their associated access rights. A default domain can be added to the access list any domain that is not explicitly listed in the access list will use the rights associated with the default domain. 9