ITF XXXXXXXXXXIntroduction to Operating Systems Assignment 2 Autumn 2020 Submission deadline Friday 18 September 2020, 10:00 am at Github. Instruction You have to earn AT LEAST 70 points in order to...

1 answer below »
The writing style is not so importsant, it only has to bee answered in a proper university way. How fast could you do this for me ?


ITF22519 - Introduction to Operating Systems Assignment 2 Autumn 2020 Submission deadline Friday 18 September 2020, 10:00 am at Github. Instruction You have to earn AT LEAST 70 points in order to pass this assignment. The assignment could be submitted as a single TXT or PDF file. You can choose between scanning your handwritten notes or typing the solutions directly on a computer. Scanned pages must be clearly legible. In exercises where you are asked to write a computer program, you must hand in the code along with the report. All the files should be put inside oblig2 directory of your own github repository. Students who fail the assignment, but have made a genuine effort at solving the exercises, are given a second attempt at revising their answers. All aids, including collaboration, are allowed, but the submission must be written by you and reflect your understanding of the subject. If we are not sure that the work you submitted demonstrates your clear understanding, we may request you to give an oral account. Problem 1 (5 pts) Discuss the difference between Kernel mode and User mode. Problem 2 (16 pts) Evaluate if each of the following statements is TRUE or FALSE. • Bash shell is a part of an operating system (OS). • A program which copies a file belongs to an OS. • Users can operate in Kernel mode thanks to procedure calls. • Interrupt is used to switch from User mode to Kernel mode. • In Kernel mode, some instructions are forbidden. 1 • Disks and I/O devices are abstracted as files by OS. • A process table is used to store information of a suspended process. • Two processes are connected by using a file. Problem 3 (4 pts) Suppose that you have an OS running on your smart TV or your laptop. Can that OS be used for wearable or sensor devices? Explain your answer. Problem 4 (5 pts) What happens when a program calls a system call? Problem 5 (20 pts) Questions in Chapter 2 of the main textbook • (5 pts) Question 1 In Fig. 2-2, three process states are shown. In theory, with three states, there could be six transitions, two out of each state. However, only four transitions are shown. Are there any circumstances in which either or both of the missing transitions might occur? • (5 pts) Question 8 Consider a multiprogrammed system with degree of 6 (i.e., six programs in memory at the same time). Assume that each process spends 40% of its time waiting for I/O. What will be the CPU utilization? • (5 pts) Question 6 A computer has 4 GB of RAM of which the operating system occupies 512 MB. The processes are all 256 MB (for simplicity) and have the same characteristics. If the goal is 99% CPU utilization, what is the maximum I/O wait that can be tolerated? • (5 pts) Question 7 Multiple jobs can run in parallel and finish faster than if they had run sequentially. Suppose that two jobs, each needing 20 minutes of CPU time, start simultaneously. How long will the last one take to complete if they run sequentially? How long if they run in parallel? Assume 50% I/O wait. Problem 6 (5 pts) Discuss shortly the differences between local, global, static and static local variables. (Hint: consider the location in the address space, scope (within function, files, etc.) or initializa- tion). 2 Problem 7 (10 pts) Consider the following code fragment: 1 int a, b; 2 3 void foo() 4 { 5 int a, b; 6 int c; 7 a = 1; 8 b = 1000; 9 c = 10; 10 11 printf("a = %d, b = %d, c = %d \n", a, b, c); 12 } 13 14 void main() 15 { 16 int c; 17 a = 2; 18 b = 2000; 19 c = 20; 20 21 foo(); 22 printf("a = %d, b = %d, c = %d\n", a, b, c); 23 } • (2.5 pts) What are local variables, global variables in this program? • (5 pts) Discuss shortly the output of the program? • (2.5 pts) Discuss shortly the output of the program if we remove line number 5? Problem 8 (10 pts) Consider the following code fragment: int pow_2_10; for(int i = 0; i < 10;="" i++)="" {="" static="" int="" b="2;" b="b*" 2;="" pow_2_10="b;" }="" •="" (5="" pts)="" predict="" the="" value="" of="" pow="" 2="" 10="" after="" the="" loop="" finishes.="" explain.="" 3="" •="" (2.5="" pts)="" discuss="" the="" value="" of="" pow="" 2="" 10="" if="" we="" remove="" static="" keyword.="" •="" (2.5="" pts)="" explain="" why="" we="" could="" not="" assign="" value="" of="" b="" to="" pow="" 2="" 10="" outside="" the="" for="" loop,="" like="" this:="" int="" pow_2_10;="" for(int="" i="0;" i="">< 10;="" i++)="" {="" static="" int="" b="2;" b="b*" 2;="" }="" pow_2_10="b;" problem="" 9="" (10="" pts)="" consider="" the="" following="" code="" fragment:="" while(n=""> 0) { N--; fork(); } Assume that N is a positive integer which is small enough to avoid fork bomb. • (5 pts) How many child processes are created? • (5 pts) How many parent processes are there? • (Bonus - 2.5 pts) What is a fork bomb? Problem 10 (5 pts) Consider the following code fragment: if (fork() == 0) a = a + 5; else a = a - 5; • (5 pts) Let x and y be the values of variable a in the parent and child process respec- tively. What can we infer about the difference of x and y after executing this code. Explain. • (Bonus - 5 pts) Let u and v be the addresses of variable a in the parent and child process respectively. What can we infer about the difference of u and v after executing this code. Explain. 4 Problem 11 (10 pts) The program in comparator.c reads two integers from the user input, compares them and prints out messages accordingly. The expected output of this program is shown below. However, there are some bugs inside this program which cause different errors. Fix the bugs and explain in short why there are those bugs. Remember to update the comparator.c accordingly. $ ./comparator Enter num1 and num2 1 2 num1 = 1, num2 = 2 num1 is smaller than num2 $ ./comparator Enter num1 and num2 2 2 num1 = 2, num2 = 2 num1 is equal to num2 $ ./comparator Enter num1 and num2 3 2 num1 = 3, num2 = 2 num1 is greater than num2 5 (5 pts) (16 pts) (4 pts) (5 pts) (20 pts) Questions in Chapter 2 of the main textbook (5 pts) (10 pts) (10 pts) (10 pts) (5 pts) (10 pts)
Answered Same DaySep 17, 2021

Answer To: ITF XXXXXXXXXXIntroduction to Operating Systems Assignment 2 Autumn 2020 Submission deadline Friday...

Arun Shankar answered on Sep 18 2021
133 Votes
1. Problem 1
A computer operates in two different modes - user mode and kernel mode. The
system is in user mode when it is running a user application like the word processor,
or a powerpoint pre
sentation. When this application requests the help of the OS -
say, to do input/output, or when an interrupt or a system call occurs, the system
switches to kernel mode. Some privileged instructions can be run only in kernel
mode. Input and output management, interrupt instructions, context switching
between processes etc. happen in kernel mode.
2. Problem 2
FALSE
FALSE
FALSE
TRUE
TRUE
TRUE
FALSE
FALSE
3. Problem 3
Yes, but an OS for a wearable or a sensor device has to respond to external stimuli.
So, the OS will need to have additional features coded into it.
4. Problem 4
First, the user process makes the call to the wrapper function in the C library. The
system stores the syscall number - a unique ID of the system call - and some process
related information in registers. A software interrupt switches the system to kernel
mode. The current process is suspended, and the interrupt handler is executed. The
system call handler is called, and the system call runs in kernel space. Its return code
is then stored in some register.
5. Problem 5
(a) Yes, there can be a transition from the “blocked” state to the “running” state. If a
process is blocked on I/O, and the I/O finishes, the process can go from “blocked”
state to the “running” if the CPU is idle.
(b) Since there are 6 processes, and each process spends 40% of the time waiting for
I/O, the probability that all 6 of them are waiting for I/O is 0.4​6​ = 0.004096.
Therefore, CPU utilization = 1- 0.004096 = 0.995904
(c)
Available RAM = 4GB - 512 MB = 3584 MB
Since each process is 256MB,
number of simultaneous processes = 3584/256 = 14
Let a process be waiting for I/O p % of the time. Then,
Maximum I/O that can be tolerated = 1-p​14​ = 0.99. Solving for p, p =...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here