Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit



School of Computer Science

Systems Programming in C and C++

Online Quiz

2021


Systems Programming in C and C++


Continuous assessment

Question 1

Briefly answer the following questions.

(a) Specify whether the following statement about device drivers characteristics are correct or not (Mention ONLY if it’s correct or not).

(i) The device driver handles the interrupts generated by the peripheral device

(ii)  It is responsible for moving data between peripheral devices and local storage

(iii) The device driver communicates directly with the device controller

(b)  Explain the differences between user mode and kernel mode.

(c) Why is an efficient implementation of inter-process communication critical for the efficiency of microkernels?

(d) You are asked to write a device driver for a digital camera, which contains a tape to store the videos, in a microkernel system.  The device driver has to fulfil two functions.   Firstly,  it has to access the data which is on the tape in the digital camera, and secondly it has to control the movements of the tape (move it forward, backwards and stop it).  Which parts of the device driver must be implemented in the microkernel, and which parts may be implemented as services in user mode? Justify your answer.


Question 2

(a) Specify whether the following statement about preemptive scheduling policies are correct or not (Mention ONLY if it’s correct or not).

(i) A process can be interrupted, and the CPU switched to execute a different process.

(ii) The waiting and response times are reduced compared to non-preemptive schedul-ing.

(iii) The overall throughput of the system is guaranteed to be better than with non-preemptive scheduling policies.

(b) You have been asked to compile a Linux kernel that will be deployed on a critical micro-controller device.  You need to take a decision whether you set the CON- FIG MODULES parameter to Y or N. Specify the appropriate configuration for that parameter and briefly justify your decision.

(c) The C program shown below is compiled and run on a UNIX machine.  Predict all possible outputs that this program will print to the console and explain your answer.



(d) The following two concurrently executing process A and  B that makes use of a shared variable Z with the initial value of 2.  How many possible distinct value(s) Z

can have after both processes are complete (Figure  1).



Question 3

(a)  Briefly answer the following questions.

(i)  Explain the difference between starvation and deadlock?

(ii)  Describe what happens when the system runs out of physical memory? What happens if the program tries to access an address that is not in the physical memory?

(iii) What is thrashing and what is the reason it happens?

(b) Consider a concurrent system with three processes A, B and C (Table  1). The sys-

tem receives multiple requests, and places them in a request queue that is accessible by all the three processes A, B, and C. For each request, we would like to enforce an order such that the request must first be processed by B, then A, then C, and finally by B before it can be removed and discarded from the queue. Provide a (semaphore based) solution to synchronize A, B and C and ensure that the solution does not

contain any deadlock. Show a deadlock free trace as well.



(c) Consider the following memory map containing three process P1, P2 and P3 (Fig- ure 2).  Assume a new process P4 arrives with a memory requirement of 2 KB.


Explain the result of using first fit, best fit and worst fit algorithms for the given memory map (Figure 2).  Generate new memory maps after applying these algo- rithms.