Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

CS 3113 Introduction to Operating Systems Final Exam ..., Exams of Operating Systems

The exam is closed book, notes and electronic devices. The exception is that you may have one page of personal notes (double sided). The exam is worth a total ...

Typology: Exams

2021/2022

Uploaded on 08/05/2022

char_s67
char_s67 🇱🇺

4.5

(109)

1.9K documents

1 / 13

Toggle sidebar

Partial preview of the text

Download CS 3113 Introduction to Operating Systems Final Exam ... and more Exams Operating Systems in PDF only on Docsity! CS 3113 Introduction to Operating Systems Final Exam December 13, 2019 General instructions: ˆ Please wait to open this exam booklet until you are told to do so. ˆ This examination booklet has 13 pages. You also have been issued a bubble sheet. ˆ Write your name, university ID number and date, and sign your name below. Also, write your name and ID number on your bubble sheet, and fill in the bubbles for your ID. ˆ The exam is closed book, notes and electronic devices. The exception is that you may have one page of personal notes (double sided). ˆ The exam is worth a total of 137 points (and 15% of your final grade). ˆ You have 2 hours to complete the exam. Be a smart test taker: if you get stuck on one problem go on to the next. ˆ Use your bubble sheet to answer all multiple-choice questions. Make sure that the question number and the bubble row number match when you are answering each question. If you cannot effectively erase an incorrect answer, mark an ’X’ over it. On my honor, I affirm that I have neither given nor received inappropriate aid in the completion of this exam. Signature: Name: ID Number: Date: Question Points Score Files and File Systems 24 Process Scheduling 40 System Calls and Protection 9 Processes and Threads 22 Characters and Strings 8 Resource Sharing 34 Total: 137 Part I. Files and File Systems 1. (2 points) True or False? When a process opens a file and then forks a child process, the two processes share the file offset. A. True B. False 2. (4 points) Assume the initial contents of file myfile and the execution of the follow- ing block of code. What are the final contents of myfile? Assume that there are no errors with permissions and that there are no newlines. myfile initial contents: pass Code block: FILE *fp = fopen ( ”myf i l e ” , ”a” ) ; i f ( fp == NULL ){ printf ( ”Error” ) ; exit (−1) ; } fprintf ( stdout , ” the exam”) ; fclose ( fp ) ; A. pass B. the exam C. pass the exam D. There is an error E. Answer not shown 3. (4 points) Assume that a disk block stores I inodes and that there are multiple, sequential blocks that store inodes. Assume also that the first inode block is disk block K. Given that we would like to access inode j, which block and element of the block, respectively, must we access? A. I + j/K and j%K B. K + j/I and j%I C. I + j%K and j/K D. K + j%I and j/I E. Answer not shown Page 2 14. (4 points) Consider a file system in which inodes contain a block index table, with one such table configured accordingly: Index Block 0 17 1 23 2 18 3 21 Assume a block size of 16. Which physical block is logical byte 45 of the file stored in? A. 17 B. 18 C. 21 D. 23 E. Answer not shown 15. (4 points) Which byte within the physical block is byte 45 stored in? A. 2 B. 3 C. 5 D. 13 E. Answer not shown 16. (4 points) Consider the following processes and burst times: Process Burst Length P1 7 P2 4 P3 10 Assuming that all of the processes arrive at time zero, but in the following order: P1, P2, P3, what is the average wait time if the processes are scheduled according to the first-come-first-served algorithm? A. 5 B. 6 C. 7 D. 13 E. Answer not shown 17. (4 points) Assuming that the same set of processes are scheduled according to the shortest-job-first algorithm, what is the average wait time? A. 5 B. 6 C. 7 D. 13 E. Answer not shown Page 5 Part III. System Calls and Protection 18. (3 points) Which of the following is not a class of system call. A. Process control B. Memory management C. Communication D. Device management E. All are classes of system calls 19. (2 points) True or False? The file system is always manipulated by code executing in a kernel mode. A. True B. False 20. (2 points) True or False? A system call allows the kernel to access user space code. A. True B. False 21. (2 points) True or False? strcmp() is a system call. A. True B. False Page 6 Part IV. Processes and Threads 22. (4 points) What number is printed by this program? i n t main ( i n t argc , char ** argv ) { i n t p1 [ 2 ] ; pipe ( p1 ) ; i n t pid ; i n t val = 42; i f ( ( pid = fork ( ) ) == −1) { fprintf ( stderr , ” Error f o r k i ng \n” ) ; exit (−1) ; } e l s e i f ( pid > 0) { close ( p1 [ 0 ] ) ; val = 7 ; write ( p1 [ 1 ] , &val , sizeof ( i n t ) ) ; wait ( NULL ) ; } e l s e { close ( p1 [ 1 ] ) ; i n t val2 = 3 ; read ( p1 [ 0 ] , &val2 , sizeof ( i n t ) ) ; val2 += val ; printf ( ”%d\n” , val2 ) ; } } A. 10 B. 45 C. 49 D. Answer not shown 23. (4 points) How many stars are output by this program? i n t main ( i n t argc , char ** argv ) { f o r ( i n t i = 0 ; i < 2 ; ++i ) { i n t pid = fork ( ) ; write (1 , ”*” , 1) ; i f ( pid > 0) { wait ( NULL ) ; } } } A. 3 B. 4 C. 6 D. 8 E. Answer not shown 24. (2 points) True or False? Different threads of the same program have their own stacks. A. True B. False Page 7 Part VI. Resource Sharing 31. (4 points) Consider the following solution to the dining philosophers problem where the philosophers are: P1, P2, ..., PK , and the chopsticks are C0, C1, ... (each is a binary semaphore initialized to state ’1’). Each philosopher i uses the following algorithm: whi le ( t rue ) { think ( ) wait ( chopstick [ i ] ) wait ( chopstick [ i /2 ] ) eat ( ) signal ( chopstick [ i /2 ] ) signal ( chopstick [ i ] ) } Can deadlock happen? A. Yes B. No 32. (2 points) True or False? Deadlock is a special case of starvation. A. True B. False 33. (4 points) Assume that there is exactly one unit of each resource, and that the allocations and requests are as follows: ˆ P1: allocated R1 and requested R2 ˆ P2: requested R1 and R2 In this state, is the resource manager allowed to allocate resource R2 to either P1 or P2? A. P1: No; P2: No B. P1: No; P2: Yes C. P1: Yes; P2: No D. P1: Yes; P2: Yes (either P1 or P2, not both at the same time) Page 10 34. (4 points) True or False? According to the Banker’s algorithm, the following system state is safe. Claim/Max Matrix Camera Printer Bluetooth Process A 2 1 2 Process B 5 5 3 Process C 5 4 4 Process D 1 0 2 Current Allocation Camera Printer Bluetooth Process A 1 1 0 Process B 2 4 1 Process C 4 2 3 Process D 1 0 1 Total Resources Camera Printer Bluetooth 8 7 6 A. True B. False 35. (3 points) Which of the following is a hardware solution to the mutual exclusion problem? A. Binary semaphore B. Counting semaphore C. Mutex D. Test-and-set E. Answer not shown 36. (4 points) Assume that there is exactly one unit of each resource, and that the allocations and requests are as follows: ˆ P1: allocated R1 and R2 ˆ P2: requested R1 and R3 ˆ P3: requested R2 and allocated R3 Has deadlock occurred? A. Yes B. No Page 11 37. (3 points) Which condition of deadlock is prevented by requiring that all resource requests by a process are made simultaneously? A. Hold and wait B. No preemption C. Exclusion D. Circular wait 38. (4 points) True or False? According to the Banker’s algorithm, the following system state is safe. Claim/Max Matrix Camera Printer Bluetooth Process A 7 5 4 Process B 7 2 3 Process C 3 2 5 Process D 4 0 2 Need Matrix Camera Printer Bluetooth Process A 4 3 3 Process B 4 0 1 Process C 2 1 4 Process D 1 0 1 Total Resources Camera Printer Bluetooth 11 5 6 A. True B. False Page 12
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved