PRACTICE SET
Operating Systems Practice Set 1
Unit 1 · Introduction to Operating Systems
Time: 45 MinutesTotal Marks: 25
Note: Answer all questions. Write your own answer first, then compare it with the answer given below each question.
SECTION A
1.Answer all questions in brief. 2 × 5 = 10| Q.No | Questions | Marks |
|---|
| (a) | Define an operating system and state its two main goals. | 2 | | Answer An operating system is the software that manages a computer's hardware and gives programs a simple, safe way to use it. Its two main goals are convenience (make the computer easy to use) and efficiency (keep the CPU, memory and devices well used). | | (b) | Differentiate between user mode and kernel mode. | 2 | | Answer A mode bit in the CPU records the mode. In kernel mode every instruction may run, including privileged ones such as I/O and timer control. In user mode privileged instructions are refused, so a program must ask the kernel through a system call. A trap or interrupt switches the CPU to kernel mode; the return switches it back. | | (c) | What is a system call? Give two examples. | 2 | | Answer A system call is the way a running program asks the kernel for a service it cannot perform itself, such as reading a file. Examples: fork() to create a process, open() and read() to use a file, write() to send output. | | (d) | Distinguish between multiprogramming and time-sharing. | 2 | | Answer Multiprogramming keeps several jobs in memory and switches the CPU to another job when the current one waits for I/O; its aim is to keep the CPU busy. Time-sharing goes further: it switches between jobs after a short time slice even when none is waiting, so that many interactive users each get a quick response. | | (e) | What is booting? Name the program that starts it. | 2 | | Answer Booting is the process of starting the computer and loading the operating system kernel into memory. It is started by the bootstrap program (bootloader), kept in firmware (ROM/UEFI), which runs checks, finds the kernel on disk, loads it and passes control to it. |
SECTION B
2.Answer all questions. 5 × 3 = 15| Q.No | Questions | Marks |
|---|
| (a) | Explain the following types of operating system with one example of each: batch, multiprogrammed, time-sharing and real-time. | 5 | | Answer Batch: jobs with similar needs are collected and run one after another with no user interaction. Example: early IBM mainframe payroll runs. Multiprogrammed: several jobs stay in memory; when one waits for I/O the CPU runs another, so the CPU is rarely idle. Example: IBM OS/360. Time-sharing: the CPU switches among users after a short time slice, so each interactive user feels the machine is theirs. Example: UNIX, Linux on a shared server. Real-time: results must arrive within a fixed deadline. A hard real-time system fails if a deadline is missed (airbag or pacemaker control); a soft real-time system only loses quality (video streaming). Examples: VxWorks, FreeRTOS. | | (b) | Compare the monolithic, layered and microkernel structures of an operating system. | 5 | | Answer Monolithic: the whole kernel (file system, scheduler, drivers, memory manager) runs as one program in kernel mode. It is fast because parts call each other directly, but a fault in one part can crash everything and it is hard to maintain. Example: traditional UNIX, Linux. Layered: the system is built in layers, each using only the services of the layer below it (layer 0 hardware, top layer user interface). Easy to design and debug one layer at a time, but slower because a request passes through many layers, and choosing the order of layers is difficult. Microkernel: only the essentials (scheduling, inter-process communication, basic memory management) stay in the kernel; drivers and file systems run as user-mode servers. It is reliable, secure and easy to extend, but message passing between servers adds overhead. Example: Mach, QNX, MINIX 3. | | (c) | Describe, step by step, what happens when a user program calls read() to read from a file. | 5 | | Answer 1. The program calls the read() function of the C library, passing the file descriptor, a buffer address and a byte count. 2. The library function places the system call number for read and its parameters in registers (or in a block of memory whose address is in a register). 3. It executes a trap (system call) instruction. The CPU switches to kernel mode and jumps to the kernel's system call handler. 4. The handler uses the system call number as an index into the system call table and calls the kernel's read routine. 5. The kernel checks the parameters, finds the file, asks the device driver for the data (the process may wait while the disk works) and copies the data into the user's buffer. 6. The kernel puts the result (number of bytes read, or an error) in a register, switches back to user mode and returns to the instruction after the trap. 7. The library function returns that value to the program. |
|