1 / 25

Tutorial 3

Tutorial 3. Practice for Test1. 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

Download Presentation

Tutorial 3

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Tutorial 3 Practice for Test1

  2. 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

  3. 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

  4. 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

  5. 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

  6. 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

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

  8. 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.

  9. Q8: Which of the following was NOT included in Popek and Goldberg’s 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.

  10. 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.

  11. 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. 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 doesn’t 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.

  12. 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

  13. Q12: Here is the lecture version of Peterson’s software solution to the two thread lock problem:lock: flag[i] = true turn = j while (flag[j] && turn == j)endunlock: flag[i] = falseWhich 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.

  14. Q13: Which of the following is NOT an advantage system level threads have over user level threads? • They don’t 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.

  15. 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 osdef 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? • 1 3 4 • 2 1 4 • 1 3 4 2 1 4 • 2 1 1 3 4

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

  17. Q16: 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

  18. Q17: 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.

  19. Q18: 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.

  20. Q19: 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.

  21. Q20: 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.

  22. Q21: In the following pseudocode solution to the Dining Philosopher’s 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.

  23. Q22: 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.

  24. Q23: 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. • 9.66... • 15 • 8 • 3

  25. Q24: 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 6. • 6 • 5 • 3 • 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.”

More Related