Tutorial 5 Test1 Review. Q1: Which of the following models can be applied to operating systems? The onion model The dustbin model The manager model All.

Slides:



Advertisements
Similar presentations
1 Interprocess Communication 1. Ways of passing information 2. Guarded critical activities (e.g. updating shared data) 3. Proper sequencing in case of.
Advertisements

Operating Systems: Monitors 1 Monitors (C.A.R. Hoare) higher level construct than semaphores a package of grouped procedures, variables and data i.e. object.
Threads, SMP, and Microkernels
3.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Process An operating system executes a variety of programs: Batch system.
1 Processes and Threads Chapter Processes 2.2 Threads 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling.
More on Processes Chapter 3. Process image _the physical representation of a process in the OS _an address space consisting of code, data and stack segments.
CAS3SH3 Midterm Review. The midterm 50 min, Friday, Feb 27 th Materials through CPU scheduling closed book, closed note Types of questions: True & False,
Concurrency: Mutual Exclusion and Synchronization Chapter 5.
Tutorial 5 Test1 Review. Q1: Which of the following is an operating system theme or model as defined in lectures?
Chapter 6: Process Synchronization
Mutual Exclusion.
1 Concurrency: Mutual Exclusion and Synchronization Chapter 5.
Chapter 2: Processes Topics –Processes –Threads –Process Scheduling –Inter Process Communication (IPC) Reference: Operating Systems Design and Implementation.
Avishai Wool lecture Introduction to Systems Programming Lecture 4 Inter-Process / Inter-Thread Communication.
Review: Process Management Objective: –Enable fair multi-user, multiprocess computing on limited physical resources –Security and efficiency Process: running.
Inter Process Communication:  It is an essential aspect of process management. By allowing processes to communicate with each other: 1.We can synchronize.
1/28/2004CSCI 315 Operating Systems Design1 Operating System Structures & Processes Notice: The slides for this lecture have been largely based on those.
CSSE Operating Systems
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
The Structure of the “THE” -Multiprogramming System Edsger W. Dijkstra Jimmy Pierce.
1 Process Description and Control Chapter 3 = Why process? = What is a process? = How to represent processes? = How to control processes?
Race Conditions CS550 Operating Systems. Review So far, we have discussed Processes and Threads and talked about multithreading and MPI processes by example.
Process Description and Control A process is sometimes called a task, it is a program in execution.
CE Operating Systems Lecture 5 Processes. Overview of lecture In this lecture we will be looking at What is a process? Structure of a process Process.
Process Management. Processes Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication.
Concurrency: Mutual Exclusion and Synchronization Chapter 5.
Chapter 41 Processes Chapter 4. 2 Processes  Multiprogramming operating systems are built around the concept of process (also called task).  A process.
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-1 Process Concepts Department of Computer Science and Software.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Introduction to Concurrency.
CE Operating Systems Lecture 11 Windows – Object manager and process management.
Copyright © 1997 – 2014 Curt Hill Concurrent Execution of Programs An Overview.
Games Development 2 Concurrent Programming CO3301 Week 9.
Cpr E 308 Spring 2004 Real-time Scheduling Provide time guarantees Upper bound on response times –Programmer’s job! –Every level of the system Soft versus.
1 Announcements The fixing the bug part of Lab 4’s assignment 2 is now considered extra credit. Comments for the code should be on the parts you wrote.
CE Operating Systems Lecture 3 Overview of OS functions and structure.
Concurrency: Mutual Exclusion and Synchronization Chapter 5.
1 Concurrency: Mutual Exclusion and Synchronization Chapter 5.
CSE 451: Operating Systems Section 5 Midterm review.
CPS110: Implementing threads Landon Cox. Recap and looking ahead Hardware OS Applications Where we’ve been Where we’re going.
Concurrency & Context Switching Process Control Block What's in it and why? How is it used? Who sees it? 5 State Process Model State Labels. Causes of.
1 Computer Systems II Introduction to Processes. 2 First Two Major Computer System Evolution Steps Led to the idea of multiprogramming (multiple concurrent.
CS399 New Beginnings Jonathan Walpole. 2 Concurrent Programming & Synchronization Primitives.
Operating Systems CMPSC 473 Signals, Introduction to mutual exclusion September 28, Lecture 9 Instructor: Bhuvan Urgaonkar.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
Introduction Contain two or more CPU share common memory and peripherals. Provide greater system throughput. Multiple processor executing simultaneous.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 3: Processes Process Concept Process Scheduling Operations.
Concepts and Structures. Main difficulties with OS design synchronization ensure a program waiting for an I/O device receives the signal mutual exclusion.
Copyright © Curt Hill More on Operating Systems Continuation of Introduction.
Concurrent Programming in Java Based on Notes by J. Johns (based on Java in a Nutshell, Learning Java) Also Java Tutorial, Concurrent Programming in Java.
Threads, SMP, and Microkernels Chapter 4. Processes and Threads Operating systems use processes for two purposes - Resource allocation and resource ownership.
CS162 Section 2. True/False A thread needs to own a semaphore, meaning the thread has called semaphore.P(), before it can call semaphore.V() False: Any.
1 Module 3: Processes Reading: Chapter Next Module: –Inter-process Communication –Process Scheduling –Reading: Chapter 4.5, 6.1 – 6.3.
Tutorial 2: Homework 1 and Project 1
Chapter 3: Process Concept
Topic 3 (Textbook - Chapter 3) Processes
CS 6560: Operating Systems Design
Process Management Presented By Aditya Gupta Assistant Professor
Chapter 3: Process Concept
KERNEL ARCHITECTURE.
Lecture 2: Processes Part 1
Process & its States Lecture 5.
Shared Memory Programming
Chapter 3: Processes.
CS510 Operating System Foundations
CSE 153 Design of Operating Systems Winter 19
CS333 Intro to Operating Systems
CSE 153 Design of Operating Systems Winter 2019
CSE 542: Operating Systems
CSE 542: Operating Systems
Presentation transcript:

Tutorial 5 Test1 Review

Q1: Which of the following models can be applied to operating systems? The onion model The dustbin model The manager model All of the above

Q2: The MS-DOS operating system was really which type of system? A time-sharing system A microkernel A resident monitor A strictly layered system

Q3: Which of the following is NOT an advantage of an all-in-one operating system design? Access to different components within the operating system is efficient It is easier to verify the functioning of the operating system It is initially simpler to implement It can have the most functionality in the least space

Q4: What was the major task of job control languages? To suspend and resume jobs To prevent jobs getting into infinite loops and executing continuously To take control away from the operating system and give it to user level jobs To give commands to the operating system about processes and data

Q5: Which of the following is a requirement in order to create a time-sharing system? Memory protection Interruptible processors A relatively large amount of memory All of the above

Q6: Early smartphones had which of the following features? Large amounts of memory Fast processors Virtual memory None of the above

Q7: Which of the following is NOT an advantage of virtual machines? Virtual machines simplify the overall design of operating systems. Individual servers can be provided on a smaller number of real machines. Multiple operating systems can run simultaneously on the same hardware. There is a large increase in flexibility for data centres using virtual machines.

Q8: Which of the following was NOT included in Popek and Goldbergs requirements of virtualization? Fidelity - the software should run identically on the virtual machine as on a real machine. Performance - most instructions in the virtual machine should be run directly on the hardware. Simplicity - the implementation of the virtual machine monitor must be clear and simple. Safety - each virtual machine, and the virtual machine monitor should be safe from actions in another virtual machine.

Q9: Instructions which query the running state of a processor (i.e. kernel or user mode) make virtualization difficult. Which of the following best explains why? An instruction running in the kernel of a virtual machine would report that it was running in user mode. An instruction running in user mode of a virtual machine would report that it was running in kernel mode. An instruction running in the kernel of the host operating system would report that it was running in kernel mode. An instruction running in the kernel of the host operating system would report that it was running in user mode.

Q10: Even with the Global Interpreter Lock (GIL) in standard Python which means that only one thread can run at a time there is still a need for locks (as in the first assignment). Which of the following reasons best explains why this is so? If run on a multicore machine more than one thread can run simultaneously in the Python program. The GIL sometimes doesnt work allowing multiple threads to run simultaneously. A thread could still be interrupted (and another thread scheduled) while it is accessing a resource. The GIL is associated with threads, the locks which are still required are associated with processes.

Q11: Spin locks are required in some situations. Which of the following reasons justifies the use of spin locks? If the spin part of the spin lock is guaranteed to only take a very short period of time. In a multicore machine a spin lock is not so bad because work can still be done on the other cores. To provide higher level synchronization constructs such as semaphores with queues to put threads to sleep safely, we can make the operations appear atomic by locking parts of them with spin locks. All of the above

Q12: Here is the lecture version of Petersons software solution to the two thread lock problem: lock: flag[i] = true turn = j while (flag[j] && turn == j) end unlock: flag[i] = false Which of the following statements about this lock is TRUE? The lock relies on the fact that the line turn = j is executed atomically by each thread. It can be generalized to more than two threads by simply extending the size of the flag array. The i variable in this code represents an identifier associated with the other thread. The lock could allow one thread to enter the critical section twice if the other thread is waiting to enter the critical section. The statement "turn = j" even if executed simultaneously by both threads will only have one value stored in it (either 0 or 1, remember that in thread 0 the value j is 1 and in thread 1 the value j is 0). It will never have half of 1 and half of 0. This means that the while loop will always allow only one thread to continue.

Q13: Which of the following is NOT an advantage system level threads have over user level threads? They dont block threads in the same process when one of them blocks in the kernel. On a multicore machine system level threads from the same process can run simultaneously on the processor cores. They are simpler to create and switch between. Each system level thread can be scheduled independently by the operating system.

Q14: Given the following code what output comes from the child process? (The end keyword used in the print function means the output is separated by spaces rather than newlines.) import os def test(): print(1, end=' ') pid = os.fork() if pid == 0: print(2, end=' ') test() else: test() print(3, end=' ') print(4, end=' ') What would the answer be if the question asked for the output comes from the entire code?

Q15:How many times does the ps command get called from the following program? Remember that in Python 0 is equivalent to false. import os count = 0 os.system('ps') while count < 2: if os.fork(): os.system('ps') if os.fork(): os.system('ps') count +=

Q16: In assignment 1 part 1 which two threads/processes could access the ready_list at the same time? The main process and the high priority process The scheduler thread and the simple process thread The high and low priority processes The scheduler and controller threads

Q17: In Assignment 1 what best describes the purpose of the following line of code? os.waitpid(current_process.pid, os.WNOHANG) != (0, 0) It waits until the current process has finished. It waits until the current process is no longer hanging. It checks to see if the current process has finished. It checks to see if the current process is not hanging. os.WNOHANG The option for waitpid() to return immediately if no child process status is available immediately. The function returns (0, 0) in this case.

Q18: The following output from assignment 1 shows that a low priority process gets the resource for a second and third time even though two higher priority processes have requested the resource. What is the best explanation for this behaviour? Low priority: just about to request resource owner pid: Low priority: got resource High priority: just about to request resource owner pid: High priority: just about to request resource owner pid: Low priority: just about to request resource owner pid: Low priority: got resource Low priority: just about to request resource owner pid: Low priority: got resource The low priority process has had its priority improved because of the waiting higher priority processes The low priority process requests the resource while it is still holding the resource The low priority process was first in the queue and hence gets the resource repeatedly The high priority processes are letting the low priority process complete in order to get it out of the way as soon as possible

Q19: What is true about the following lines of code from assignment 1? r, w = os.pipe() controller_read = os.fdopen(r) controller_write = os.fdopen(w, mode='w', buffering=1) The controller needs to be able to write to this pipe. This pipe is used to convey request-reply-release messages to the processes which require the resource. This pipe needs to be created before any simple processes which require the resource are forked. This pipe is used to coordinate access to the ready_list.

Q19 cont. The controller needs to be able to write to this pipe. – wrong because this pipe was used by the controller to read from. The other processes wrote to this pipe. This pipe is used to convey request-reply-release messages to the processes which require the resource. – wrong because it is used for the request and release messages but not the reply message (sent by the controller). This pipe needs to be created before any simple processes which require the resource are forked. – right because the pipe had to be set up before the forks if the forked processes were going to use it to communicate with the controller. This pipe is used to coordinate access to the ready_list. – just wrong it had nothing to do with the ready_list.

Q20: Which of the following would you NOT normally expect to be in a Process Control Block? References to other processes References to device drivers References to allocated memory References to open files

Q21: Which of the following statements about the Unix exec system call is FALSE? Exec copies the currently running process then replaces it with a new program. All files which were open in the process which called exec remain open in the process after the exec. Calling exec throws away the memory associated with process. Exec checks to see if the file passed to it is executable. The exec doesn't copy the currently running process, the fork call does that. The exec replaces the currently running program with a new program but it doesn't do the copy.

Q22: Which of the following statements concerning the Windows operating system is FALSE? The Windows equivalent of a Process Control Block is stored in a variety of data structures. The Windows NT Kernel can use different environmental subsystems to run user applications. Windows process creation is a version of Unix process creation. Windows DLLs are loaded within the context of the newly created process.

Q23: Why is suspending a thread not generally regarded as a good idea? If a suspended thread releases locks it could cause lifelock. Suspended threads release any locks they are holding, possibly leaving resources in inconsistent states. Suspended threads take up unnecessary CPU cycles. If a suspended thread holds locks it could cause deadlock.

Q24: Which of the following statements concerning the Unix operating system is FALSE? A waiting process is placed on a queue associated with the kernel address of the resource the process is waiting for. A process only stays a zombie if its parent is still alive. A process with a priority of 40 has a better priority than a process with priority 20. Signals are used to notify processes when they have done something wrong.

Q25: In the following pseudocode solution to the Dining Philosophers problem, what could go wrong? do forever: status = "waiting" simultaneous_wait(left, right) status = "eating" simultaneous_signal(left, right) status = "thinking An unlucky process might never be able to get both left and right forks simultaneously. All processes might pick up one fork causing deadlock. Nothing is wrong, this is a good solution to the problem. Some processes will get extra turns to eat on a regular basis, violating the principle of fair treatment. In this case a process can't proceed unless it can get both forks at the same time. It never picks up just one and so deadlock can't happen. But it might be unlucky and every time its left fork is available its right fork is being used by its right neighbour and vice versa.

Q26: Which of the following statements about concurrency constructs is TRUE? Monitors are at least as powerful as semaphores. Semaphores are at least as powerful as locks. Locks are at least as powerful as monitors. All of the above.

Q27: Given three processes A, B, and C with corresponding burst times 20, 5, and 4, what is the average waiting time with a round-robin scheduler using a time slice of 5? The ready list is initially A, B, then C CBAACBAC B waits for 5C waits for 5A waits for 4 C waits for 5A waits for 5 Wait1=5+5=10Wait2=5+5=10Wait3=4Total=24 B is Done!C is Done! Average=8

Q28: With a logical clock system and assuming that the clocks work in integers what should the local logical clock of a system be changed to if its current value is 4 and it receives a message from another system with a time stamp of None of the above If the received timestamp is later than the current logical time of the receiving processor the logical time is bumped up.