Untitled

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Q4. (a) What are the three main purposes (goals) of an operating system?

In a typical operating system,


what are the basic two modes of operations? How to distinguish between basic modes of operations? Some
CPUs provide for more than two modes of operations - What are two possible uses of these multiple
modes? [2+(1+1)+2 = 6]

Answer:

The three main goals of an operating system are :


● Execute user programs and make solving user problems easier
● Make the computer system convenient to use
● Use the computer hardware in an efficient manner

In a typical operating system the basic two modes of operation are Kernel Mode and User Mode of operation.

One can differentiate between these modes on the basis of the mode bit provided by the hardware.

Having multiple CPU modes is useful for example Virtual Machine manager mode for guest VMs.

Q4. (b) Which of the following instructions should be privileged? [4]


a. Set value of timer. b. Read the clock.
c. Clear memory. d. Issue a trap instruction.
e. Turn off interrupts. f. Modify entries in device-status table.
g. Switch from user to kernel mode. h. Access I/O device.

Answer:

The instructions that should be privileged are:

 set value of timer,


 clear memory,
 turn off interrupts,
 modify entries in device-status table,
 access I/O device

These instructions require special privileges or permissions that are only granted to the operating system or
kernel. They are considered privileged because they can directly affect the operation of the system and can
potentially cause harm or damage if misused. The other instructions listed (b. Read the clock and c. Clear
memory) are not privileged and can be performed by user-level programs.

Q5. (a) What is a bootstrap program? Where is it stored in a computer? Mention its functionality. [2]

Answer:

A bootstrap program, also known as a bootstrap loader, is a program that loads the operating system
(OS) into the computer's memory when the computer is turned on. It is executed when a computer is
turned on or reset It is usually stored in non-volatile memory, such as the ROM (read-only memory) or
EEPROM (electrically erasable programmable read-only memory) chip, which is built into the
computer's hardware.

The functionality of the bootstrap program is to initiate the process of loading the OS into the


 
computer's memory by performing a series of tasks. These tasks include performing basic hardware
tests to ensure that the computer is functioning properly, detecting and initializing all hardware devices
connected to the computer, and finally loading the OS into the computer's memory. Once the OS is
loaded, control is transferred from the bootstrap program to the OS, and the computer is ready to run
applications.

Q5. (b) What are System Calls? What is the purpose of system calls? [2]

Answer:

System Calls are functions provided by the operating system to allow user-level processes to interact
with the kernel, which is the core part of the operating system. (1)

The purpose of system calls is to provide an interface between user-level applications and the kernel.
System calls allow applications to request services from the operating system, such as creating or
deleting files, managing memory, or communicating with other devices. They also enable the operating
system to manage hardware resources and provide a layer of security and protection to prevent
unauthorized access to system resources. (1)

Q5. (c) What is the purpose of the command interpreter? Why is it usually separate from the kernel? [2]

Answer:

The purpose of the command interpreter is to provide a user-friendly interface to interact with the
operating system. It accepts commands from the user, interprets them, and executes them by
communicating with the operating system's kernel. (1)

It is usually separate from the kernel for several reasons, such as:

● Security: Separating the command interpreter from the kernel helps to prevent unauthorized
users from accessing system resources.
● Flexibility: Separating the command interpreter from the kernel makes it easier to modify and
update the command interpreter without affecting the kernel.
● Compatibility: Separating the command interpreter from the kernel allows for different
command interpreters to be used with the same kernel, providing flexibility and compatibility
across different operating systems. (1)

Q5. (d) What system calls have to be executed by a command interpreter or shell for starting a new
process in LINUX? [2]

Answer:

In Unix systems, a fork system call followed by an exec system call need to be performed to start a new
process. The fork call clones the currently executing process, while the exec call overlays a new
process based on a different executable over the calling process.


 
Q5. (e) What is the main advantage of the layered approach to system design? What are the
disadvantages of the layered approach? [2]

Answer:

Advantages of layered operating systems:


One of the major advantages of layered operating systems is that they are decomposable, and hence
affects the separation of concerns and the different abstraction levels. Furthermore, a layered operating
system allows for good maintenance, whereby you will be able to make changes without affecting the
layer interfaces.

Disadvantages of layered operating systems


A major disadvantage, however, is that it can be difficult to precisely assign the functions to the right,
and the appropriate, layers. Moreover, given that there are too many layers, performance of the system
can be degraded quite massively making the computer run at a speed that is less than desirable.

Q6. (a) Draw the process state diagram (with proper labeling of the nodes and edges). Briefly explain
(with help of the diagram) when a new process is to be executed in the CPU. [4]

Answer:

When a new process needs to be executed it will follow the state diagram as described below:
1. New: the process is about to be created but not yet created, it is the program which is present in
secondary memory that will be picked up by OS to create the process.
2. Ready: The process is now loaded into the main memory and pushed into the ready queue,
where it is waiting to get the CPU time for its execution.
3. Run: The process is chosen by CPU for execution which can happen if the process being
executed previously gets preempted.
4. The process can finish its execution and directly go to Terminated state or it may need some
I/O operation or wait for some event completion before finishing and go to Waiting/Blocked
state. It can also be preempted due to the scheduling policy (priority or round robin etc.) or
some interrupt and go back to Ready state in the ready queue.
5. If the process is in Waiting and it has finished what it was waiting for, it goes back to Ready
state and waits until the scheduler picks it up to get executed again.
6. Finally when the process has executed completely, it goes to Terminated.


 
Q6. (b) What is an interrupt? Briefly discussed the steps involved in handling an interrupt request.
[1+2]

Answer:

In computing, an interrupt is a signal sent to the processor by a device or software, indicating that it
needs attention or a service from the processor. When an interrupt occurs, the processor temporarily
stops executing the current program and transfers control to a special program called an interrupt
handler or interrupt service routine (ISR) that is designed to handle the specific interrupt request.

Here are the basic steps involved in handling an interrupt request:

● Interrupt request: A device or software generates an interrupt request (IRQ), which is a signal
that interrupts the normal execution of the CPU.
● Interrupt handling: The CPU stops executing the current program and starts executing the
interrupt handler, which is a small program that manages the specific interrupt request.
● Save the context: Before executing the interrupt handler, the CPU saves the current state of the
program including the program counter, register values, and other information.
● Identify the source: The interrupt handler determines the source of the interrupt and performs
the necessary actions to handle the interrupt request. For example, it may read data from an
input device or update a timer.
● Interrupt acknowledgment: After the interrupt handler has completed its tasks, the CPU sends
an acknowledgement signal to the device or software that generated the interrupt request,
indicating that the interrupt has been handled.
● Restore the context: The CPU restores the saved context information like, the program counter
and register values, and resumes executing the original program at the point where it was
interrupted.
● Resume normal execution: The original program continues executing as if there was no
interruption, and the CPU waits for the next interrupt request.

Q6. (c) Given the following timeline of a system with a single-core CPU: [3]

Answer:

Time (ms) Event

0 Process A starts execution

10 Interrupt request generated by peripheral device

20 Interrupt service routine (ISR) starts execution

25 ISR completes and returns control to Process A

30 Process A resumes execution

Calculate the (i) total time taken to handle the interrupt request, (ii) the percentage of time that was spent
in the ISR; (iii) the percentage of time that was spent executing Process A.
[Assume: the interrupt request and the return from interrupt are instantaneous events]

T1> A runs for = (10-0) = 10 ms


 
T2> Then the interrupt request occurs which is processed in (20-10) = 10 ms, this includes the saving of
context A
T3> The ISR executes for (25-20) = 5 ms
T4> The loading back of context of A takes = (30-25) = 5 ms

(i) Total time taken to handle the request = T2 + T3 + T4 = 20 ms


(ii) Percentage of time that was spent in the ISR = 5/30 * 100% = 16.67%
(ii) Percentage of time that was spent executing Process A = 10/30 * 100% = 33.33%


 

You might also like