1.How does multiprogramming differ from uniprogramming? List two advantages of multiprogramming over uniprogramming. Answer: Multiprogramming enables the user to run several jobs/tasks simultaneouslty rather than one at a time in uniprogramming. -> Significantly higher resource utilization. -> Facilitates process interaction (for example clipboards, spoolers, etc.) 2.Problem 1.8 from the AOS text. Under what circumstances would a user be better off using a time sharing system, rather than a PC or a single user workstation? Answer: If the user/process requires interaction with several users (ex. whiteboards) or several users/processed need ot have acess to a shared resource (ex. file) then a time sharing system would be the best option. 3.Problem 2.3 form the AOS text. What are the differences between a trap and an interrupt? What is the use of each function? Answer: An interrupt is a hardware-generated change-of-flow within the system. An interrupt handler is summoned to deal with the cause of the interrupt; control is then returned to the interrupted context and instruction. A trap is a software-generated interrupt. An interrupt can be used to signal the completion of an I/O to obviate the need for device polling. A trap can be used to call operating system routines or to catch arithmetic errors. 4 Problem 2.6 from AOS text. Some computer systems do not provide a privileged mode of operation in hardware. Consider whether it is possible to construct a secure operating system for these computers. Give arguments both that it is and that it is not possible. Answer: An operating system for a machine of this type would need to remain in control (or monitor mode) at all times. This could be accomplished by two methods: a. Software interpretation of all user programs (like some BASIC, APL, and LISP systems, for example). The software interpreter would provide, in software, what the hardware does not provide. b. Require meant that all programs be written in high-level languages so that all object code is compiler-produced. The compiler would generate (either in-line or by function calls) the protection checks that the hardware is missing. 5 What is a context switch? What are the actions taken by a kernel for a context switch? Answer: A context switch is the act of swithcing between processes. Thw kernel saves the state (PCB, context) of the current process, loads the state (PCB, context) of the new process scheduled to run. 6 Using the fork()}, waitpid(), exit() and exec() system calls, write a program in which a parent process creates two child processes. The first child executes the ls program to list all files in a directory. The second child prints "I am the second child" and sleeps for 30 seconds. The parent process waits for the second child to finish and prints "Second child finished" before exiting. You may write your program in pseudo-code. void main () { int ChildPID, ChildPID2; ChildPID = fork(); // create 1st child if (ChildPID == 0) { // this is the child exec (ls); } else{ // this is the parent ChildPID2 = fork(); // create the second child if (ChildPID2 == 0) { // this is the second child printf ("I am the second child !!!"); sleep (30); exit(0); } else { // this is the parent waitpid (ChildPID2); } }