seg # page # offset

Similar documents
CS 3500 Final Exam Sample Questions

CS510 Operating System Foundations. Jonathan Walpole

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

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

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

Lecture 19: File System Implementation. Mythili Vutukuru IIT Bombay

CS 4284 Systems Capstone

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

File Systems. What do we need to know?

There are, of course, many other possible solutions and, if done correctly, those received full credit.

FAT (32 KB) 216 * 215 = 231 = 2GB

Operating System Concepts Ch. 11: File System Implementation

Long-term Information Storage Must store large amounts of data Information stored must survive the termination of the process using it Multiple proces

Chapter 14: File-System Implementation

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

Chapter 11: Implementing File

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

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

CSE 333 Lecture 9 - storage

SMD149 - Operating Systems - File systems

Chapter 12: File System Implementation

Common Misunderstandings from Exam 1 Material

Chapter 11: File System Implementation. Objectives

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

OPERATING SYSTEM. Chapter 12: File System Implementation

CS 318 Principles of Operating Systems

Implementation should be efficient. Provide an abstraction to the user. Abstraction should be useful. Ownership and permissions.

File Systems Ch 4. 1 CS 422 T W Bennet Mississippi College

Chapter 11: Implementing File Systems

CS4500/5500 Operating Systems File Systems and Implementations

CS 318 Principles of Operating Systems

Chapter 10: File System Implementation

ICS Principles of Operating Systems

File System Implementation

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

ECE 598 Advanced Operating Systems Lecture 18

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

Design Choices 2 / 29

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

Chapter 4. File Systems. Part 1

Chapter 12: File System Implementation

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

File Systems. CS 4410 Operating Systems. [R. Agarwal, L. Alvisi, A. Bracy, M. George, E. Sirer, R. Van Renesse]

Crash Consistency: FSCK and Journaling. Dongkun Shin, SKKU

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

Typical File Extensions File Structure

Chapter 11: Implementing File-Systems

File Management. Chapter 12

OPERATING SYSTEMS CS136

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

makes floppy bootable o next comes root directory file information ATTRIB command used to modify name

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

ECE 598 Advanced Operating Systems Lecture 14

CS3600 SYSTEMS AND NETWORKS

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

File Systems. CSE 2431: Introduction to Operating Systems Reading: Chap. 11, , 18.7, [OSC]

CS-537: Final Exam (Spring 2011) The Black Box

There is a general need for long-term and shared data storage: Files meet these requirements The file manager or file system within the OS

Universidad Carlos III de Madrid Computer Science and Engineering Department Operating Systems Course

COMP091 Operating Systems 1. File Systems

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

Section 11: File Systems and Reliability, Two Phase Commit

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

CS 537 Fall 2017 Review Session

CS 322 Operating Systems Practice Midterm Questions

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

Hard Drive Technologies

File System: Interface and Implmentation

Reinstalling Windows 95/98/ME/2000 Professional

File Systems 1. File Systems

File Systems 1. File Systems

CS720 - Operating Systems

Chapter 12 File-System Implementation

Week 12: File System Implementation

Operating Systems. Operating Systems Professor Sina Meraji U of T

COMP 3361: Operating Systems 1 Final Exam Winter 2009

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

Why files? 1. Storing a large amount of data 2. Long-term data retention 3. Access to the various processes in parallel

CS307: Operating Systems

Chapter 11: File System Implementation

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

File Management 1/34

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

Fully journaled filesystems. Low-level virtualization Filesystems on RAID Filesystems on Flash (Filesystems on DVD)

File System Internals. Jo, Heeseung

File Systems Management and Examples

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

File System Implementation

Lecture 2, September 4

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

File Systems: Consistency Issues

bytes per disk block (a block is usually called sector in the disk drive literature), sectors in each track, read/write heads, and cylinders (tracks).

Computer Systems Laboratory Sungkyunkwan University

Lecture 24: Filesystems: FAT, FFS, NTFS

Principles of Operating Systems

File Systems. CS170 Fall 2018

SCSI overview. SCSI domain consists of devices and an SDS

Chapter 5 Input/Output

Motivation. Operating Systems. File Systems. Outline. Files: The User s Point of View. File System Concepts. Solution? Files!

FILE SYSTEMS. CS124 Operating Systems Winter , Lecture 23

Transcription:

Operating Systems Sample Final Exam - SOLUTIONS Name (10 pts) 1. Suppose a memory allocator has a freelist with blocks of sizes as shown: 64 24 96 4096 Using a first-fit strategy, draw what happens to the freelist for the following sequence of requests: 1) Allocate a block of size 16 2) Allocate a block of size 48 3) Allocate a block of size 16 4) Allocate a block of size 256 1: 48 -> 24 -> 96 -> 4096 2: 24 -> 96 -> 4096 3: 8 -> 96 -> 4096 4: 8 -> 96 -> 3840 (10 pts) 2. The VAX used a paging system with 32-bit addresses, divided into three fields.. a 2 bit segment, 21 bits of page number, and 9 bits of offset. The 2-bit segment meant that each process could have up to four page tables associated to it (although segment 10 was used by the system and segment 11 was unused, leaving only segments 00 and 01 for the process). seg # page # offset 2 21 9 a. How large are the pages? 2^9 = 512 bytes. b. How large is each page table? (Give both # of entries and size in bytes.) Each table has 2^21 = 2M entries, each of which will need 4 bytes, so 8Mb. (10 pts) 3. Two threads simultaneously run the following code to insert an item onto a linked list. Here the_list is the global linked list, and item is a local variable for each thread. item->next = the_list; the_list = item; a. Explain how one thread s item could be left off the list. Thread one does item->next = the_list, thread 2 does the same. Then thread one does the_list=item, then thread 2 does it. Since the_list now points to thread 2 s item, and

thread 2 s item->next field points to the start of the old list, thread 1 s item is not on the list. b. What are the implications for the malloc() function from this course? It s not thread safe. In particular, freed memory may be lost as in part a. What would you change in malloc() to fix the problem? Add a mutex to protect the freelist. (10 pts)4. Suppose the virtual memory map for a process looks like the diagram on the left, with unmapped areas shown in white. Which of the following operations will result in a segmentation fault? System Use ffffffff X Read at $00000008 c0000000 Write at $1FFFFFF0 Heap Code Stack System Use 40000000 20000000 00000000 Read at $20000008 X Write at $20000008 X Read at $3FFFFFF0 Write at $40000010 Read at $40000010 X Write at $B0000008 (10 pts) 5. Consider two threads running at once: Thread 1: lock(a_lock); a++; if (a == 10) { lock(b_lock); b++; unlock(b_lock); a = 0; unlock(a_lock) Thread 2: lock(b_lock); b--; if (b == 0) { lock(a_lock); a--; unlock(a_lock); unlock(b_lock)

Suppose a is initially 9 and b is initially 1. If both threads execute at the same time, what are the possible outcomes? 1: a = 0 and b = 1 (t1 finishes then t2 starts) 2: a =9 and b = 0 (t2 finishes then t1 starts) 3: both threads hang (10 pts) 6. A floppy disk has the following free space bitmap: 1 1 1 1 1 0 0 0 1 1 1 1 1 1 0 0 0 1 0 0 1 1 1 1 1 0 1 1 1 1 1 0 0 8 1 6 2 4 The superblock is stored in block 0, and the root directory is stored in block 1. The root directory contains: Filename Start block Size (in blocks) afile 2 3 bigfile 20 11 ccode.c 8 4 This file system is inconsistent. What is wrong? How would you suggest repairing it to minimize potential data loss? Bits at 12, 13, 17, 25 are inconsistent with files. Fix by changing size of ccode.c to 6, marking bit 25 as 1, marking bit 17 as 0. (10 pts) 7. A disk backup program copies every file on a hard disk to tape so that the disk can be restored in case of a crash. a. How do hard links affect the program? What can it do to deal with hard links? Multiple directory entries for same file, not one of which is special. It can mark each file on disk when it backs it up so that it only makes one backup of each file, and then note when a hard link needs to be rebuilt on restoring. b. How do symbolic links affect the program? What can it do to deal with symbolic links? Needs to detect symbolic links and save the link, not the file it links to. Also, for links to directories, the program shouldn t follow the symbolic link when walking the directory tree. (10 pts) 8. Sun s Network File System (NFS) is stateless. Discuss the implications for:

a. Opening and closing files. Open/close only affects internal state of the filesystem, so they can t be used. Instead, pass filename as an argument with every read/write call. b. Absolute and relative pathnames. Relative pathnames require a current directory, which is state. All pathnames need to be absolute. c. Random file access. This is not a problem. d. Sequential file access. Keeping a current position in the file requires state, and so cannot be done. All read/write calls need to include the file location. (10 pts) 9. Optical WORM disk drives are used by companies that need to store a large amount of data in a permanent, unalterable way. For example, companies use WORM drives to comply with S.E.C. rules for keeping financial records. WORM stands for write-once-read-many, which means that every sector of an initially blank disk can be written to exactly once, after which it becomes permanently read only. This might be accomplished by burning pits into the disk with a laser. Unlike a CD-ROM, which must be written all at once, a the sectors of a WORM drive can be used up slowly over time. Users will create files, then change them or even delete them, although the disk keeps a permanent record of the older versions. In designing a file system for a WORM drive, would you choose contiguous file allocation, linked file allocation (such as a FAT), or indexed file allocation? Give reasons why your choice is better than the other two. Indexed would be the best. When a file is changed, can give it a new inode and re-index the data if necessary. This way if a file only adds new blocks or has a few changes, the unchanged data blocks do not need to be rewritten. Contiguous is ok. By leaving free blocks at the end of a file, appending to a file wouldn t require rewriting the entire file, but any other change to the file would require a completely new copy to be made.

Linked allocation is bad because the FAT table would need to be rewritten every time a file changed. (10 pts)10. Give an example of a single command line Unix command that will create three processes. ps sort more (10 pts)11. Name two services provided by the TCP layer. Process-to-process communication via ports. Reliable, ordered, byte stream, persistent connections. (10 pts)12. What is the purpose of this program? Be specific - explain what the command line arguments are used for and what the output means. This program is a port scanner, which looks at a machine on the internet and discovers open ports - ports with a listening server attached. It attempts to open a TCP connection to every port on host (given by argv[1]) in the range from start to end (argv[2] and argv[3]). When a connection is accepted, it prints a message that that port is open. Note: This program is from a past final, and uses the old code for address resolution and socket connection. It s a good question, but I d have to change it substantially to ask it on our test. int main(int argc, char *argv[]) { // check arguments if (argc!= 4) { cerr << "usage: " << argv[0] << " host start end" << endl; exit(1); int pstart = atoi(argv[2]); int pend = atoi(argv[3]); // look up target host information struct hostent *targ_host = gethostbyname(argv[1]); if (targ_host == NULL) exit(1); // create socket int sock = socket(af_inet,sock_stream,0); if (sock < 0) exit(1); // build target s address description struct sockaddr_in targ_addr; memcpy(&targ_addr.sin_addr,targ_host->h_addr,targ_host->h_length); targ_addr.sin_family = AF_INET; // main loop

for (int p = pstart; p <= pend; p++) { targ_addr.sin_port = htons(p); // try to connect if (connect(sock,(sockaddr *)&targ_addr,sizeof(targ_addr))) { ; // failed - do nothing else { cout << p << " is open" << endl; close(sock);