STAFFORDSHIRE UNIVERSITY Operating Systems Portfolio of exercises Benoît Taine (11029054) 20/11/2012 Apply to the solution of a range of problems, the fundamental concepts, principles and algorithms employed in the operation of a multi-user/multi-tasking operating systems. SUMMARY WEEK 1 .................................................................................................................................... 2 Tutorial questions ................................................................................................................................................ 2 WEEK 2 .................................................................................................................................... 2 Tutorial Questions ............................................................................................................................................... 2 WEEK 3 .................................................................................................................................... 2 Virtual machine exercise ..................................................................................................................................... 2 Tutorial questions ................................................................................................................................................ 2 WEEK 4 .................................................................................................................................... 3 Tutorial questions ................................................................................................................................................ 3 WEEK 5 .................................................................................................................................... 2 Tutorial question ................................................................................................................................................. 2 Virtual machine exercises with Linux processes .................................................................................................. 2 WEEK 6 .................................................................................................................................... 3 Tutorial question ................................................................................................................................................. 3 Virtual machine exercises – simple Windows system programming .................................................................. 5 WEEK 7 .................................................................................................................................... 6 Tutorial questions ................................................................................................................................................ 6 Virtual machine exercise – Linux interprocess communication ........................................................................... 6 WEEK 8 .................................................................................................................................... 7 Tutorial question ................................................................................................................................................. 7 WEEK 9 .................................................................................................................................... 8 Tutorial questions ................................................................................................................................................ 8 WEEK 10 .................................................................................................................................. 9 Tutorial questions ................................................................................................................................................ 9 Operating Systems Portfolio of exercises 1/12 WEEK 1 TUTORIAL QUESTIONS 6. How does the distinction between supervisor mode and user mode function as a rudimentary form of protection (security) system? (3 marks) User mode doesn't allow user to perform some tasks, like system administration or modification, while the supervisor mode has all the rights. 7. What are the differences between software interrupt (trap) and hardware interrupt? What is the use of each? (3 marks) A hardware interrupt is sent from a piece of hardware, like a pressed keyboard key. A software interrupt is thrown to let a program execute instructions with a higher priority. WEEK 2 TUTORIAL QUESTIONS 4. What is the purpose of system calls? Why are they necessary? (3 marks) It gives to the user programs an interface to use an operating system procedure. They are necessary to use threads or forked processes, or simply to use a file opening routine. WEEK 3 VIRTUAL MACHINE EXERCISE 16. Using an editor (can be the simple editor you used in 1), write a short (two or four line) shell script which applies sort and head to a test file and will give a sorted list of the first five lines in the file. (4 marks) #!/bin/sh sort "${1}" | head -n 5 TUTORIAL QUESTIONS 12. The ability of a process to create a new process is an important capability, but it has dangers. Consider the consequences of allowing a user to run the process below. Assume that fork() is a system call that creates a new child process. int main() { while (true) { fork(); } } a) What would the consequences of allowing such a process to run? (2 marks) Operating Systems Portfolio of exercises 2/12 Running a fork bomb program has never been a good idea. The system will try to create an infinite number of process control blocks and crash. b) Suppose that you are an operating systems designer and have been asked to build in safeguards against such processes. Assume that you have decided that it is inappropriate to reject certain processes, and that the best approach is to place certain runtime controls on them. What controls might the operating system use to detect processes like the above at runtime? (4 marks) We can limit the number of processes a user is allowed to execute at the same time. On Linux systems, we use the ulimit command or the /etc/security/limits.conf file to configure this number. WEEK 4 TUTORIAL QUESTIONS 6. Consider the following set of processes, with the length of the CPU-burst time given in milliseconds: Process Burst time Priority P1 5 2 P2 1 1 P3 3 3 P4 1 4 P5 7 3 At time 0, the processes are queued in the order of arrival P1, P2, P3, P4, P5. a) Draw four Gantt charts illustrating the execution of these processes using: (8 marks) FCFS Non-preemptive priority SJF Round Robin FCFS P1 P2 P3 P4 P5 0 5 6 9 10 17 SJF P2 P4 P3 P1 P5 0 1 2 5 10 17 Non-preemptive priority P2 P1 P3 P5 P4 0 1 6 9 16 17 Round Robin P1 P2 P3 P4 P5 P1 P3 P5 P1 P3 P5 P1 P5 P1 P5 P5 P5 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 b) What is the turnaround time of each process for each of the scheduling algorithms in part a? (8 marks) Operating Systems Portfolio of exercises 3/12 FCFS SJF NP P RR P1 1 10 6 15 P2 6 1 1 3 P3 9 5 8 11 P4 10 17 17 14 P5 17 16 16 17 c) What is the waiting time of each process for each of the scheduling algorithms in part a? (8 marks) FCFS SJF NP P RR P1 0 5 1 13 P2 5 0 0 2 P3 6 2 6 10 P4 9 1 16 4 P5 10 10 8 13 Average 6 3.6 5.6 8.4 d) Which of the schedules in part a results in the minimal average waiting time (over all processes)? (2 marks) The SJF has the lowest average waiting time. 8. Explain how interleaving of the execution of processes can corrupt shared data values. The following are common scheduling criteria: a) I/O boundedness of a process f) Frequency of a process being pre- empted by higher priority process b) Processor boundedness of a process g) Priorities of processes waiting for c) Whether the process is batch or resources held by other processes interactive h) Accumulated waiting time d) Urgency of a fast response i) Accumulated execution time e) Process priority j) Estimated run-time to completion For each of the following, indicate which of the preceding scheduling criteria is most appropriate i) In a real-time spacecraft monitoring iii) How often does the process system, the computer must respond voluntarily give up the processor for I/O immediately to signals received from the before its quantum has expired. spacecraft iv) Is the user present and expecting fast ii) Although a process has been receiving interactive response times, or is the user occasional service, it is making only absent. nominal progress. Operating Systems Portfolio of exercises 1/12 v) One goal of processor scheduling is to vii) Nearly complete processes should have higher minimize average waiting times priorities. vi) Processes holding resources in demand by other processes should have higher priorities. (7 marks) I II III IV V VI VII D A H C J G E WEEK 5 TUTORIAL QUESTION 5. What are the four necessary conditions needed before deadlock can occur? (4 marks) If the system has mutual exclusions, a hold and wait condition, no pre-emption and circular wait, it could generate a deadlock condition. The solution used to prevent deadlock conditions is to make sure the system won’t have any circular wait. VIRTUAL MACHINE EXERCISES WITH LINUX PROCESSES 17. Use your forktest.c program as the basis, but modify it by deleting the printf that occur under the if and the else that output the PIDs and replace them with code for the parent to output the series of odd numbers in an infinite loop and for the child process to output the series of
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages13 Page
-
File Size-