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

All Quizzes on Operating Systems I | CSCI 4630, Exams of Operating Systems

Material Type: Exam; Class: Operating Systems I; Subject: Computer Science; University: East Carolina University; Term: Spring 2002;

Typology: Exams

Pre 2010

Uploaded on 07/30/2009

koofers-user-zha
koofers-user-zha 🇺🇸

10 documents

1 / 17

Toggle sidebar

Partial preview of the text

Download All Quizzes on Operating Systems I | CSCI 4630 and more Exams Operating Systems in PDF only on Docsity! Operating Systems — CSCI 4630 Robert Hochberg, Instructor Spring Semester, 2002 Office: Austin 325B Phone: 328-0126 Email: hochberg@cs.ecu.edu Website: www.cs.ecu.edu/~hochberg Official Office Hours MWF 9-10am MW 11:15-12:15 But also by appt., of course. Also, stop by any time for help, but call first to make sure I'm in. “IF YOU GET STUCK, DON’T STAY STUCK.” Text: Modern Operating Systems by Tannenbaum, 2nd Edition. Homework: In a class at this level, I expect you to keep up with the material by reading the appropriate sections in the text (a reading guide will be provided on the course website). Therefore written homework will not be given. Instead, there will be quizzes to make sure you are doing the reading, and programming assignments to give you the hands-on experience. Quizzes: There will be 10 unannounced 10-point quizzes during the semester. If you are absent for a quiz, your grade will be 0. Programs: There will be 5 programming assignments, each worth 30 points. Late work will absolutely not be accepted. Exams: You will have two 50-minute in-class exams, worth 100 points each, and one cumulative final exam, during finals week, worth 150 points. Final Grade: With quizzes, programs, regular exams and the final, you will have 100 + 150 + 200 + 150 = 600 points available. You will receive: at least an A if you get > 539 at least a B if you get > 479 at least a C if you get > 419 at least a D if you get > 359 Notes: There are no make-up exams or quizzes available after the fact. Absences may be excused in advance on a per-case basis. It is the responsibility of the student to stay on top of the material, by doing the reading and attending the classes. If you miss a class, see me or another student to find out about announcements, material covered, etc... DO NOT FALL BEHIND! This is the kiss of death in any computer science course, especially one like this, where the material is at times rather abstract, new material builds on old material and there are frequent definitions. Remember, you learn a new thing by doing it, not by watching it. You must work in this class in order to succeed; and often, time spent on the programming assignments makes the difference. East Carolina University seeks to fully comply with the Americans with Disabilities Act (ADA). Students requesting accommodations based on a covered disability must go to the Department for Disability Support Services, located in Brewster A-114, to verify the disability before any accommodations can occur. The telephone number is 252-328-6799. Operating Systems Name__________________________ Quiz #1A January 18, 2002 1. We said that operating systems can be viewed in two different ways. (For a hint, the initials of these two ways are “R.M.” and “E.M.”) List these two ways, and give a very brief, one-sentence description of each. Resource Manager: The OS deals with the hardware components of the computer. Extended Machine: The OS presents the computer to the user in a usable format. 2. Draw a diagram showing the three states that a process can be in and the possible transitions between those states. 3. What is the “process table,” and what is the most important information stored therein? 5. For each of the following, answer either “User Threads” or “Kernel Threads.” [8] a. Which implementation requires more overhead on a context switch? b. Which implementation is more allows for quicker thread-switching? c. Which implementation would be better for a process doing lots of I/O? d. Which implementation could be provided by a library on top of a non-threading OS? 6. Barnes and Noble maintains a database containing the account balance for each B&N CafeCard holder. Unfortunately, this database does not implement any method to guarantee protected access to its data. Let B be the variable which contains the balance (initially $30) in some account, and suppose that two people use their cards at the same time, to purchase drinks costing $5 and $3 respectively: a. Give an example of a sequence of events which could result in the wrong value being saved back to the database. [5] b. What are all possible final values that could occur following these two transactions? [6] 7. We described two operations P(s) and V(s) on a semaphore s. [6] a. What does P do? b. What does V do? c. What is special about the way P and V are performed that enable them to solve the “race conditions” problem? 8. Give a bit of code (or pseudocode) for the P and V operations: [10] void P(semaphore &s){ } void V(semaphore &s){ } 9. What is meant by a “binary semaphore?” [4] 10. We discussed monitors and how they can be used for interprocess synchronization [6] a. Briefly describe what a monitor looks like in a program b. Which of the following is most responsible for making sure monitors guarantee mutual exclusion: The programmer, the OS, the kernel, the compiler or the user? 11. What is meant by a “test and set lock” (TSL) instruction? In particular, mention what the return value of a TSL instruction is, and mention what is special about the way TSL instructions are executed. [5] 12. Below is a bit of code which attempts to solve the producer-consumer problem with semaphores. It doesn’t work. Make appropriate corrections in the initialization, Producer and Consumer code. [10] Initialization: full = 0; //initialize semaphore empty = 0; //initialize semaphore mutex = 0; //initialize a mutual exclusion semaphore Producer: while(1){ Produce_item(thing); P(empty); V(mutex); Insert_item(thing); P(mutex); V(empty) } Consumer: while(1){ P(full); V(mutex); Remove_item(thing); P(mutex); V(full) Consume_item(thing); } Operating Systems Name__________________________ Quiz #4 March 20, 2002 1. Draw the trajectory diagram for the two processes shown below, which request the resources in the order shown. (As a polite reminder, I’ve drawn a sample trajectory diagram to the right.) Process 1 Process 2 Request A Request B Release A Release B Request B Request A Release B Request B Release B Release A 2. For the processes and resource requests given above, is it possible for deadlock to occur? Explain your answer, referring to your diagram. 3. Suppose that each of k processes that run on a certain system will be using the CPU at any given time with probability p, independently of one another. What is the probability that at any given time, all k processes will be blocked — that is, will not be able to use the CPU. Operating Systems Name__________________________________ Exam II April 8, 2002 This exam has 11 questions. Please make sure that you have them all. There are a total of 110 points on the exam, which includes 10 “extra credit” points. Each problem is worth 10 points. 1. Let us begin with some questions about Linux scheduling: a. How long is a jiffy in Linux scheduling b. What is the arithmetical relationship between goodness, priority and quantum in the Linux scheduling algorithm? c. Process A has a priority of 32 and a quantum of 16. Suppose it uses none of its quantum for each of the next two “epochs,” that is, each of the next two times that quantum values are re-computed. What will its final priority and quantum be? d. Process B has priority 18. What is the largest its quantum could become? Explain. 2. What are the 4 conditions necessary for deadlocks to occur? Give a brief description of each. a. b. c. d. 3. One way of avoiding deadlocks is to linearly order the resources. Explain in one sentence what this means. 4. To the right is a resource / process diagram showing processes that have locked, or are waiting for, various resources. (A second copy is provided beneath it in case you want to do some scrap work.) a. Has deadlock occurred? b. Suppose an algorithm does depth-first-search from vertex A: 1. List an order in which vertices might be visited for the first time. That is, list the vertices in the order in which they become “gray”, as described in class. 2. Say at what point in the algorithm, following your list above, we would have discovered whether or not there was a deadlock 5. Suppose a bitmap is used to keep track of which blocks of memory are used and which are free. How large, in bytes, would such a bitmap be if a computer had 64MB of memory and used blocks of size 32 bytes? 6. Here is a linked list showing memory usage. Process P was just placed into the queue, and now process Q, of size 10, enters the scene. Into which hole would this process be placed if we use: a. best fit b. first fit c. next fit d. worst fit Operating Systems Name__________________________ Quiz #5 April 12, 2002 1. We saw 3 different implementations of the “Least Recently Used” algorithm. Fill in the blanks below to describe each of them: a. In one implementation we kept a ___-bit counter which was incremented on every ____________________________. Each page’s entry in the page table was stamped with this counter each time that page was referenced. b. In another implementation we kept an n×n matrix, where n is the number of pages. This matrix started out as all 0s, and each time page i was referenced, we every bit in ________ i to ___ and then every bit in ________ i to ___. Then when we needed to evict a page, we selected the page whose ________, interpreted as a binary number, was ________. 2. Finish this description of the second chance algorithm: In the second-chance algorithm, we keep a queue of pages together with their “R” bits. When we have to decide which page to evict, we first consider the page at the front of the queue. If that page’s “R” bit is 0, then... But if the “R” bit is 1, then... 3. What is the basic difference between the “second chance” and “clock” algorithms? Operating Systems Name__________________________ Quiz #6 April 22, 2002 1. How large can a file be without having to use that file’s inode’s double or triple redirect blocks? Assume block size of 1024 bytes and addresses of size 4 bytes. 2. What information is stored in a directory file? (Include only that information stored in the directory file.) Operating Systems Name____________________________ Quiz #7 April 29, 2002 For all three problems below, assume you are in a directory with exactly one entry, “file1,” (aside from the usual “.” and “..”). 1. What will be printed out when the following code is executed (output on the right): Explain your answer briefly: 2. What will be printed out when the following code is executed (output on the right): void main(){ cout << “Place 1\n”; execlp(“ls”, “ls”); cout << “Place 2\n”; execlp(“ls”, “ls”, “-i”); cout << “Place 3\n”; } void main(){ if(fork() == 0); execlp(“ls”, “ls”); else{ fork(); cout << “Greetings\n”; } } _________________________________ _________________________________ _________________________________ _________________________________ _________________________________ _________________________________
Docsity logo



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