Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
17 views

Assignments

Uploaded by

Anil Kumar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Assignments

Uploaded by

Anil Kumar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 29

Operating System Fundamentals

Assignment 1
Q1. Which of the following is not the responsibility of the operating system?
(A) Resource management
(B) Control the program execution
(C) Creation of a user-friendly environment
(D) Network management
(E) Compiler design
Ans: (E) Compiler design

Q2. Choose the incorrect option.


(A) System programs are associated with the operating system
(B) System programs are not necessarily part of the kernel
(C) System programs interact with the kernel to manage hardware resources
(D) System programs help user to manage the files
(E) System programs degrade the performance of the computer system
Ans: (E) System programs degrade the performance of the computer system

Q3. Which of the following is not an example of a system program?


(A) Disk cleanup tool
(B) Antivirus program
(C) Text editor
(D) Web browser
(E) GRUB (Grand Unified Bootloader) loader
Ans: (D) Web browser

Q4. What is the function of the command interpreter?


(A) Translating program in a high-level language into machine code
(B) Memory management
(C) Execute the user-specified command
(D) Controlling input/output operations
(E) Managing file system operations
Ans: (C) Execute the user-specified command

Q5. Which of the following is not part of a device controller?


(A) Data Register
(B) RAM
(C) Control Register
(D) Status register
(E) DMA controller
Ans: (B) RAM

Q6. Direct Memory Access (DMA) technique is used for


(A) Managing CPU clock speeds
(B) Transferring data between peripheral devices and memory without CPU intervention
(C) Managing hardware resources
(D) Managing the interrupts
(E) Executing the programs
Ans: (B) Transferring data between peripheral devices and memory without CPU intervention

Q7. Which of the following components is closest to the CPU?


(A) RAM
(B) L1 cache
(C) L2 cache
(D) L3 cache
(E) Secondary storage
Ans: (B) L1 cache

Q8. Which of the following is incorrect for an interactive Operating System (OS)?
(A) It is designed for batch processing
(B) It is designed to achieve a response time as low as possible
(C) It is designed to respond promptly to user inputs
(D) It is suitable for multi-programming environment
(E) It is suitable for multi-user system
Ans: (A) It is designed for batch processing

Q9. Which of the following components do not need a device driver?


(A) Monitor
(B) RAM
(C) Printer
(D) Mouse
(E) Keyboard
Ans: (B) RAM

Q10. An interrupt may not occur when


(A) a hardware component encounters an error or failure
(B) a data transfer between a peripheral device and memory is completed
(C) a user program requests to execute a system call
(D) a disk operation is completed
(E) the computer system intentionally turns off the interrupts
Ans: (E) the computer system intentionally turns off the interrupts

Assignment 2
Q1. What is the best activity performed by the operating system for process management?
(A) Allocation of memory to different processes.
(B) Management of input and output operations.
(C) Scheduling of processes to improve the system throughput.
(D) Handling of system errors.
(E) Handling of system interrupts.
Ans: (C) Scheduling of processes to improve the system throughput.

Q2. The operating system executes the memory management for


(A) handling the interrupts.
(B) improving the system throughput.
(C) interprocess communication among two processes.
(D) managing user interfaces.
(E) storage management.
Ans: (B) improving the system throughput

Q3. Choose the correct statement.


(A) A device driver converts data to be printed in a format that a printer can understand.
(B) A device driver connects the computer system to the Internet.
(C) A device driver is not useful for modern operating systems.
(D) A device driver only handles communication between the operating system and storage devices.
(E) A device driver executes operating system functions manually.
Ans: (A) A device driver converts data to be printed in a format that a printer can understand.

Q4. The caching mechanism is used in computer systems to


(A) allocate memory to different processes.
(B) store frequently accessed data in a temporary storage area for quicker access.
(C) ensure communication between memory and I/O devices.
(D) manage network protocols and data transmission.
(E) handel the system error.
Ans: (B) store frequently accessed data in a temporary storage area for quicker access.

Q5. A system call is


(A) the interface between a user program and the operating system.
(B) executed in user mode.
(C) the memory manager in a computer system.
(D) used to perform only I/O operations.
(E) used to perform only inter-process communication.
Ans: (A) the interface between a user program and the operating system.

Q6. Which system call creates a shared memory segment in Unix-like operating systems?
(A) shmdt()
(B) shmget()
(C) pipe()
(D) shmctl()
(E) shmsnd()
Ans: (B) shmget()

Q7. Which of the following is not a feature of the MS-DOS operating system?
(A) Command-Line Interface (CLI).
(B) Single-tasking.
(C) File Allocation Table (FAT) file system.
(D) Multi-tasking.
(E) Device Drivers
Ans: (D) Multi-tasking.

Q8. Which of the following is not a core feature of the UNIX-like operating system?
(A) Multi-user.
(B) Mult-programming.
(C) Process management.
(D) Error handling.
(E) Batch Processing.
Ans: (E) Batch Processing.

Q9. The umask() system call is used to


(A) set the file creation mode mask for processes.
(B) allocate memory dynamically for new processes.
(C) control the execution priority of processes.
(D) managing inter-process communication.
(E) release the resources upon completion of the execution of a process.
Ans: (A) set the file creation mode mask for processes.

Q10. The message-passing model allows processes to communicate


(A) by sharing a common memory region.
(B) by sending and receiving messages through the operating system.
(C) by directly modifying each other's memory.
(D) through a centralized messaging server.
(E) using hardware interrupts.
Ans: (B) by sending and receiving messages through the operating system.
Assignment 3

Q1. In the modular design of an operating system, the layer 0 represents


(A) user interface
(B) hardware
(C) firmware
(D)software
(E) process
Ans: (B) hardware

Q2. Which of the following operating systems is not based on microkernel system structure?
(A) Mach
(B) MINIX
(C) HURD
(D) QNX
(E) UNIX
Answer: (E) UNIX

Q3. The Android operating system is primarily based on the


(A) Windows
(B) iOS
(C) Linux
(D) FreeBSD
(E) UNIX
Answer: (C) Linux

Q4. Which of the following is the main function of a bootstrap loader?


(A) Manage hardware resources
(B) Load and execute the operating system kernel
(C) Provide a graphical user interface
(D) Handle user authentication
(E) Manage network connections
Answer: (B) Load and execute the operating system kernel

Q5. Which of the following system calls is used to create a new process in Unix-like operating
systems?
(A) fork()
(B) exec()
(C) create()
(D) spawn()
(E) process()
Answer: (A) fork()

Q6. Which of the following is not an attribute of a process?


(A) Process ID
(B) Program counter value
(C)Priority information
(D) Scheduling information
(E) File size
Answer: (E) File size

Q7. Which of the following is not included in the process control block?
(A) Process state and priority
(B) File descriptors and environment variables
(C) Program counter and stack pointer
(D) Memory management information
(E) Process termination time
Answer: (E) Process termination time

Q8. Which of the following is not a responsibility of the short-term scheduler?


(A) Allocating CPU to processes
(B) Managing process states
(C) Selecting process from ready queue.
(D) Handling process synchronization
(E) Implementing process scheduling policies
Answer: (D) Handling process synchronization

Q9. Which of the following is an invalid reason that a process enters the waiting state?
(A) The process requests input or output operations.
(B) The process requires a resource that is currently unavailable.
(C) The process is waiting for an event or signal from another process.
(D) The parent process is waiting for one or more of its child processes to complete execution.
(E) The process requests some memory, and the request is granted.
Answer: (E) The process requests some memory, and the request is granted.

Q10. Which of the following is the primary function of the long-term scheduler?
(A) Allocating CPU to processes
(B) Manage the degree of multiprogramming
(C) Managing process states
(D) Handling process synchronization
(E) Implementing process scheduling policies
Answer: (B) Manage the degree of multiprogramming

Assignment 4
Q1. What is the purpose of a context switch in an operating system?
(A) Allocate memory to a new process
(B) Deallocate the memory from a process
(C) Save and restore the state of a process to allow multitasking
(D) Terminate a process
(E) Initialize a new process in the ready queue
Answer: (C) Save and restore the state of a process to allow multitasking

Q2. Which of the following system call is used to replace the current process image with a new process
image.
(A) fork()
(B) execl()
(C) exit()
(D) wait()
(E) sleep()
Answer: (B) execl()

Q3. What is the outcome of the following program?


#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
if (execlp("ls", "ls", "-l", NULL) == -1)
{
perror("execlp");
exit(EXIT_FAILURE);
}
printf("This line should not be reached\n");
return 0;
}
(A) The outcome is exactly same as the outcome of ls -l command
(B) The outcome is exactly same as the outcome of ls command
(C) The outcome is exactly same as the outcome of ls -a command
(D) The outcome is exactly same as the outcome of ls -h command
(E) The outcome is exactly same as the outcome of ls -t command
Answer: (A) The outcome is exactly same as the outcome of ls -l command

Q4. How many processes will be created by the following program?


#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
int n;
for(i=1;i<=n; i=i*2)
{
fork();
}
return 0;
}
(A) n
(B) n
2

(C) log n
2

(D) nlog n 2

(E) √n
Answer: (A) n

Q5. Choose the invalid option.


(A) The OS executes exit() system call when the process completes its execution successfully
(B) The OS executes exit() system call when the user explicitly requests the termination of the
process
(C) The OS executes exit() system call when the parent process decides to terminate a child process
(D) The OS executes exit() system call when the process decided to enter into waiting state
(E) The OS executes exit() system call when the process encounters an unrecoverable error or
exception
Answer: (D) The OS executes exit() system call when the process decided to enter into waiting state

Q6. Choose the invalid option. The wait() system call


(A) makes the parent process wait until all of its child processes have terminated
(B) returns the process identity of the terminated child process
(C) allows the parent process to retrieve the exit status of the terminated child process
(D) is used by a child process to wait for its parent process to terminate
(E) The wait() system call is used to prevent the creation of zombie processes
Answer: (D) is used by a child process to wait for its parent process to terminate.

Q7. Choose the incorrect option. The pipe() system call


(A) is used to create a unidirectional communication channel between processes
(B) returns two file descriptors, one for reading and one for writing
(C) can be used for inter-process communication between unrelated processes
(D) allows data to flow from the read end to the write end of the pipe
(E) is typically used for communication between a parent process and its child process
Answer: (D) allows data to flow from the read end to the write end of the pipe

Q8. Which of the following is not directely supported by thread?


(A) degree of multiprogramming
(B) system throughput
(C) multiprocessor arctitecture
(D) easy resource sharing
(E) lower context context switching
Answer: (A) degree of multiprogramming

Q9. A multiprocessor system


(A) supports parallel execution of instructions through multithreading
(B) allows multiple processes to execute asynchronously
(C) is suitable for executing strictly sequential processing tasks efficiently
(D) allows multiple processes run independently
(E) allows interprocess communication among independent processes
Answer: (C) is suitable for executing strictly sequential processing tasks efficiently

Q10. Which of the following system calls is not related to the shared memory interprocess communication?
(A) shmget()
(B) shmat()
(C) shmdt()
(D) shmctl()
(E) shmext()
Answer: (E) shmext()

Assignment 5

Q1. Assume we are running an application on a system with four processing cores. This
application has both serial (nonparallel) and parallel components. Also, assume that 60% of
this application are executed in parallel and 40% of the application is executed in serial. Based
on the Amdahl’s Law, this application gets a speedup (approx.) of
(A) 1.30 times
(B) 1.42 times
(C) 1.25 time
(D) 1.81 times
(E) 1.20 times
Answer: (D) 1.81 times

Q2. The many-to-one multithreading model supports


(A) Many user-level threads only
(B) Many kernel-level threads only
(C) One user-level thread and many kernel-level threads
(D) Many user-level threads and one kernel-level thread
(E) Many user-level threads and many kernel-level threads
Answer: (D) Many user-level threads and one kernel-level thread

Q3. Which is of the following multithreading model is unsuitable for multicore systems?
(A) Many-to-one
(B) One-to-one
(C) Many-to-Many
(D) One-to-Many
(E) Many-to-Partial
Answer: (A) Many-to-one

Q4. Which of the multithreading model blocks the entire process if a thread, which is a part
of the process, makes a blocking system call?
(A) Many-to-Many
(B) Many-to-one
(C) Many-to-Partial
(D) One-to-Many
(E) One-to-one
Answer: (B) Many-to-one

Q5. Which of the following operating systems does not support the Many-to-Many
multithreading model?
(A) Solaris
(B) HP-UX
(C) Tru64 UNIX
(D) IRIX
(E) Windows 11
Answer: (E) Windows 11

Q6. Which system calls allow the calling thread to wait for another thread to terminate?
(A) pthread_create
(B) pthread_exit
(C) pthread_join
(D) pthread_detach
(E) pthread_wait
Answer: (C) pthread_join

Q7. Which of the following statements about non-preemptive scheduling is NOT true?
(A) Once a process starts executing, it runs to completion before another process can begin.
(B) It is simpler to implement compared to preemptive scheduling.
(C) It can lead to longer waiting times for processes with short burst times.
(D) It allows the operating system to preempt a running process to give CPU time to a
higher-priority process.
(E) It is commonly used in batch-processing systems.
Answer: (D) It allows the operating system to preempt a running process to give CPU time to
a higher-priority process.

Q8. Which of the following is not the task of the dispatcher?


(A) A Dispatcher saves the context (state) of the currently running process.
(B) A Dispatcher restores the context of the next process to run.
(C) A Dispatcher helps to switch the CPU mode between user mode and kernel mode.
(D) A Dispatcher manages the main memory for process scheduling.
(E) A dispatcher provides the control of the CPU to that process that gets selected by the
short term-scheduler.
Answer: (D) A Dispatcher manages the main memory for process scheduling.

Q9. Choose the correct option for FCFS scheduling algorithm.


(A) It ensures the shortest average waiting time.
(B) It is suffered from the convoy effect.
(C) It is a preemptive scheduling algorithm.
(D) It guarantees maximum throughput.
(E) It uses a priority queue to manage processes.
Answer: (B) It is suffered from the convoy effect.

Q10. Which of the following is not a criterion used to evaluate CPU scheduling algorithms?
(A) Throughput
(B) Response time
(C) Memory usage
(D) Turnaround time
(E) Waiting time
Answer: (C) Memory usage

Assignment 6

Q1. Assume that the following processes are scheduled using the Shortest-Job-First process
scheduling policy. Determine the average waiting time.
Process Arrival time Burst time
P 1 1 3
P 2 0 2
P 3 3 2
P 4 2 4
(A) 3.5
(B) 2.5
(C) 1.5
(D) 4.5
(E) 0.5
Ans: (C) 1.5
Explanation: P2 (0—2), P1( 2 – 5), P3 (5 – 7), P4 (7 – 11). Waiting time = ((2-1)+(0-0) +( 5-3) +
(7-4)/4 = 1.5

Q2. Choose the correct statement about "Exponential Averaging" when predicting the next
CPU burst length in SJF scheduling.
(A) Exponential Averaging gives equal weight to all past CPU bursts.
(B) Exponential Averaging discards all previous history when predicting the next burst length.
(C) Exponential Averaging gives more weight to the recent CPU bursts while still considering
the entire history.
(D) Exponential Averaging is only applicable to non-preemptive scheduling algorithms.
(E) Exponential Averaging requires a fixed-size queue to store past burst lengths.
Answer: (C) Exponential Averaging gives more weight to the recent CPU bursts while still
considering the entire history.

Q3. The following processes are scheduled using the Robin process scheduling policy with a
time quantum of 3ms. Determine the average waiting time.
Process Arrival time Burst time
P 1 0 6
P 2 1 2
P 3 3 8
P 4 5 3
P 5 2 4
(A) 5.6
(B) 8.6
(C) 7.6
(D) 4.5
(E) 6.6

Answer: (B) 8.6


Explanation: P1 (0-3) P2 (5-5), P5 (5-8) P3(8-11) P4(11-14) P1(14-17) P5(17-18) P3(18-21)
P3(21-23)
Waiting time for P1 = (0-0)+(14-3) = 11
Waiting time for P2 = (3-1) = 2
Waiting time for P3 = (8-3)+(18-11) = 12
Waiting time for P4 = (11-5) = 6
Waiting time for P5 = (5-2) +(17-8)= 12
Average waiting time = (11+2+12+6+12)/5 = 8.6

Q4. Assume the following processes are scheduled using the Priority Scheduling process
scheduling algorithm. Determine the average waiting time. Assume a lower value in priority
means higher priority.
Process Priority Burst time Arrival time
P 1 2 2 0
P 2 1 3 0
P 3 3 5 0
P 4 5 7 0
P 5 4 4 0

(A) 6.4
(B) 5.0
(C) 6.8
(D) 5.8
(E) 5.2
Answer: (A) 6.4
Explanation: P2(0-3) P1(3-5) P3(5-10) P5(10-14) P4(14-21)
Average waiting time = (3+0+5+14+10)/5 = 32/4 = 6.4

Q5. Which of the following process scheduling algorithms does not suffer from the starvation
problem?
(A) Shortest Job First (SJF)
(B) Priority Scheduling
(C) Shortest Remaining Time First (SRTF)
(D) First-Come First-Served (FCFS)
(E) Multilevel Queue Scheduling
Answer: (D) First-Come First-Served (FCFS)

Q6. The "Progress" condition in the context of the Critical Section Problem refers
(A) If no process is in the critical section and some processes wish to enter it, the selection of
the next process must not be indefinitely postponed.
(B) Only one process can be in the critical section at a time.
(C) No process should wait forever to enter the critical section.
(D) If a process is in the critical section, no other process can enter until it has finished.
(E) Processes must be allowed to enter the critical section based on their priority.
Answer: (A) If no process is in the critical section and some processes wish to enter it, the
selection of the next process must not be indefinitely postponed.

Q7. The “race condition” in the context of the critical section problem
(A) occurs when multiple processes enter their critical sections simultaneously, leading to
unpredictable results.
(B) happens when a process is forced to wait indefinitely before entering its critical section.
(C) arises when the OS fails to schedule processes fairly.
(D) refers to the situation where two or more processes compete for CPU.
(E) is a condition where a process preempts another process in the middle of its critical
section.
Answer: (A) occurs when multiple processes enter their critical sections simultaneously,
leading to unpredictable results.

Q8. The solution to the critical section problem ensures which of the following(s)?
(A) Mutual exclusion
(B) Progress
(C) Bounded waiting
(D) Mutual Exclusion and Progress
(E) Mutual exclusion, Progress, and Bounded waiting
Answer: (E) Mutual exclusion, Progress, and Bounded waiting

Q9. Consider the producer-consumer problem with a bounded buffer. The processes share a
variable “count”. The initial value of the count is 5, and the maximum size of the buffer is 10.
Producer process Consumer process
while (true) while (true)
{ {
/* produce an item in next produced */ while (count == 0) ;
while (count == BUFFER_SIZE) ; /* do nothing */
/* do nothing */ next_consumed = buffer[out];
buffer[in] = next_produced; out = (out + 1) % BUFFER_SIZE;
in = (in + 1) % BUFFER_SIZE; count = count - 1;
count = count +1; /* consume the item in the next consumed */
} }
The statement count = count + 1 is implemented as
SP0: register1 = count
SP1: register1 = register1 + 1
SP2: count = register1
The statement count = count - 1 is implemented as
SC0: register2 = count
SC1: register2 = register2 - 1
SC2: count = register2
Assume that the CPU schedules the producer-consumer problem as follows: SP0, SC0, SP1,
SC1, SP2, and SC2. What is the final value of the count?
(A) 6
(B) 4
(C) 5
(D) 3
(E) 2
Answer: (B) 4

Q10. To solve the critical section problem, the general structure of a process P includes
i

(A) entry section


(B) exit section
(C) critical section
(D) remainder section
(E) All of the above
Answer: (E) All of the above

Assignment 7
Q1. Assume that two processes P and P trying to safely access a shared resource without
0 1

causing race conditions or data inconsistency. Here P and P share two variables: int turn, and
0 1

boolean flag[2]. Consider the structure of the process P and then choose the correct option.
1

do
{
flag[1] = true;
turn = 0;
while (flag[0] && turn ==0);
critical section
flag[1] = false;
remainder section
}
while (true);
(A) The above solution only achieves the mutual exclusion property.
(B) The above solution only achieves the progress requirement property.
(C) The above solution achieves only bounded-waiting property.
(D) The above solution is correct for solving the critical section problem for four processes.
(E) The above solution achieves mutual exclusion, progress requirement, and bounded-
waiting properties.
Answer: (E) The above solution achieves mutual exclusion, progress requirement, and
bounded-waiting properties.

Q2. Choose the correct statement.


(A) Busy waiting involves using special hardware instructions that make a process wait until
access to a critical section is granted.
(B) Busy waiting occurs when a process continuously checks a condition in a loop, using CPU
resources until the condition is met.
(C) Busy waiting is a software solution that eliminates the need for semaphores or mutexes
in process synchronization.
(D) Busy waiting helps improve CPU utilization by allowing a process to continue executing
while waiting for a resource.
(E) Busy waiting can be avoided by using priority inversion techniques.
Answer: (B) Busy waiting occurs when a process continuously checks a condition in a loop,
using CPU resources until the condition is met.

Q3. Choose the correct statement about test_and_set() instruction.


(A) It is a hardware-based solution that avoids busy waiting.
(B) it is used to implement spinlocks for mutual exclusion.
(C) It ensures that a process eventually enters its critical section.
(D) It can be used to release a lock once it is acquired.
(E) It is a process scheduling method.
Answer: (B) it is used to implement spinlocks for mutual exclusion.

Q4. The compare_and_swap instruction ensures


(A) Only mutual exclusion.
(B) Only progress requirement.
(C) Only bounded-waiting.
(D) mutual exclusion, progress requirement, and bounded-waiting.
(E) fair process scheduling among two processes.
Answer: (A) Only mutual exclusion.

Q5. Choose the correct statement.


(A) wait() increments the semaphore value, while signal() decrements it.
(B) wait() decrements the semaphore value and may block a process if the value becomes
negative.
(C) signal() decrements the semaphore value, and wait() increments it.
(D) signal()blocks a process until wait() is called.
(E) Both wait() and signal() are used to implement busy waiting.
Answer: (B) wait() decrements the semaphore value and may block a process if the value
becomes negative.

Q6. Choose the correct option for the counting semaphore.


(A) Counting semaphores can be used to provide mutual exclusion.
(B) Counting semaphores can be used to control access to a given resource consisting of
infinite instances.
(C) A Counting semaphore allows multiple processes to enter the critical section
simultaneously, up to a maximum limit.
(D) Counting semaphore is a semaphore that never needs initialization.
(E) Counting semaphore is used exclusively in binary locking mechanisms.
Answer: (C) A Counting semaphore allows multiple processes to enter the critical section
simultaneously, up to a maximum limit.

Q7. Choose the correct statement in the Bounded-Buffer (Producer-Consumer) problem


context.
(A) The buffer size determines the maximum number of items the producer can produce.
(B) If the buffer is full, the consumer is forced to wait until the producer produces more items.
(C) The producer must check if the buffer is full before adding an item to the buffer.
(D) The buffer size does not affect the synchronization between the producer and consumer.
(E) The consumer can consume items from the buffer even when empty.
Answer: (C) The producer must check if the buffer is full before adding an item to the buffer.

Q8. Assume that we have two processes, P1 and P2. Consider the following pseudocode. Here
semaphore S1 = 1; semaphore S2 = 0.
P1() P2()
{ {
while (true) while (true)
{ {
wait(S1); wait(S2);
Critical section Critical section
signal(S2); signal(S2);
} wait(S2);
} Critical section
signal(S1);
}
}
(A) It will execute the process in the sequence P1P2P1P2P1P2....
(B) It will execute the process in the sequence P2P1P2P1P2P1....
(C) It will execute the process in the sequence P1P2P2P1P2P2....
(D) It will execute the process in the sequence P2P1P1P2P1P1....
(E) It will execute the process in the sequence P1P1P2P2P1P1P2P2....
Answer: (C) It will execute the process in the sequence P1P2P2P1P2P2....

Q9. Consider the following code snippets involving two processes, P1 and P2, that use wait()
and signal() operations on two semaphores, S1 and S2, both initialized to 1. Which of the
following scenarios can lead to a deadlock?
P1() P2()
{ {
wait(S1); wait(S2);
wait(S2); wait(S1);
Critical Section Critical Section
signal(S2); signal(S1);
signal(S1); signal(S2);
} }
(A) If P1 executes wait(S1) first, and P2 executes wait(S2) first.
(B) If both P1 and P2 execute wait(S1) first.
(C) If both P1 and P2 execute wait(S2) first.
(D) If P1 executes wait(S1) first, and P2 executes wait(S1) first.
(E) If P1 executes signal(S1) first, and P2 executes signal(S2) first.
Answer: (A) If P1 executes wait(S1) first, and P2 executes wait(S2) first.

Q10. Consider a system with two low-priority processes, P and Q, and one high-priority
process, R. Semaphores S1 and S2 are initialized to 1.
P() Q() R()
{ { {
wait(S1); wait(S2); wait(S1);
Critical section Critical section wait(S2);
signal(S1); signal(S2); Critical section
} signal(S2);
} signal(S1);
}
Which of the following statements best describes a scenario involving priority inversion and
deadlock?
(A) P and Q will always run before H because they have higher priority.
(B) R may experience priority inversion if it gets blocked by P or Q, but does not lead to a
deadlock.
(C) R may experience priority inversion if P and Q both run and hold semaphores S1 and S2,
respectively, leading to a situation where R is blocked, and it may also lead to a deadlock.
(D) The system will not experience priority inversion or deadlock because semaphores are
initialized to 1.
(E) R never experiences priority inversion.
Answer: (C) R may experience priority inversion if P and Q both run and hold semaphores S1
and S2, respectively, leading to a situation where R is blocked, and it may also lead to a
deadlock.

Assignment 8

Q1. How do we describe the “starvation” situation for the “Dining Philosophers” problem?
(A) A deadlock situation where philosophers cannot make progress
(B) When a philosopher asks to share the forks from his neighbour philosophers.
(C) When a philosopher cannot pick up any forks and, therefore, cannot eat.
(D) A situation where philosophers leave the table without finishing their meal.
(E) Philosophers eating continuously without thinking
Answer: (C) When a philosopher cannot pick up any forks and, therefore, cannot eat.

Q2. Which of the following conditions must be satisfied for a deadlock to occur in an operating
system?
(A) Mutual Exclusion
(B) Hold and Wait
(C) No Preemption
(D) Circular Wait
(E) All of the above
Answer: (E) All of the above

Q3. Consider the following Resource Allocation Graphs (RAGs). Here p1, p2, p3, and p4 are
the processes, and r1, r2, and r3 are are the resources. Each dot for a resource represents the
instance of that resource type.

Choose the correct statement.


(A) The RAG in Fig. (A) has a deadlock, whereas the RAG in Fig. (B) has no deadlock.
(B) The RAG in Fig. (A) has no deadlock, whereas the RAG in Fig. (B) has a deadlock.
(C) Both the RAGs in Fig. (A) and Fig. (B) have no deadlock.
(D) Both the RAGs in Fig. (A) and Fig. (B) have deadlocks.
(E) Both the RAGs in Fig. (A) and Fig. (B) have partial deadlocks.
Answer: (A) The RAG in Fig. (A) has a deadlock, whereas the RAG in Fig. (B) has no deadlock.

Q4. Which of the following conditions describes deadlock avoidance?


(A) It ensures that a system never enters an unsafe state.
(B) Processes need not declare their maximum resource needs in advance.
(C) It allows deadlocks to occur and then handles them.
(D) It uses a resource allocation graph to detect deadlocks.
(E) It involves preempting resources from processes to break deadlocks.
Answer: (A) It ensures that a system never enters an unsafe state.

Q5. An operating system is in a safe state if


(A) Processes can be executed in some order without causing a deadlock.
(B) The corresponding resource allocation graph contains a cycle.
(C) Processes are granted resources even if they enter a deadlock situation.
(D) Processes are in a terminate state.
(E) Processes are in the suspended state.
Answer: (A) Processes can be executed in some order without causing a deadlock.

Q6. Which of the following functions is not a thread synchronization primitive?


(A) pthread_mutex_lock()
(B) pthread_mutex_unlock()
(C) pthread_mutex_join()
(D) pthread_mutex_destroy()
(E) pthread_mutex_rejoin()
Answer: (E) pthread_mutex_rejoin()
Q7. Assume that n is the number of vertices in the wait-for graph (single instance of each
resource type). The algorithm to detect a cycle in the wait-for graph requires an order of
(A) n operations
3

(B) n operations
(C) log n operations
2

(D) n operations
2

(E) nlog n operations


2

Answer: (D) n operations


2

Q8. Which of the following strategies is used to recover from the deadlock situation?
(A) Terminate all the deadlock processes.
(B) Terminate one process one at atime until the deadlock cycle is removed.
(C) Increase the priority of the process to eliminate the deadlock.
(D) Deallocate the resources from all the deadlock processes and allocate them to other
processes.
(E) All of the above.
Answer: (E) All of the above.

Q9. Which data structure is not needed to execute the Banker’s Algorithm?
(A) Available matrix
(B) Maximum resource matrix
(C) Allocation matrix
(D) Need matrix
(E) Prority matrix
Answer: (E) Prority matrix

Q10. A computer system has four types of resources: A, B, C, and D. The system currently has
13 instances of resource A, 7 instances of resource B, 6 instances of resource C, and 7
instances of resource D available. Consider the following snapshot of a system:

Process Current allocation Maximum demand


A B C D A B C D
P1 2 1 0 0 3 1 1 1
P2 3 1 0 1 6 2 2 1
P3 4 2 1 2 5 3 3 3
P4 2 1 2 1 3 2 2 1

Choose the correct answer.


(A) The system is unsafe and may lead to a deadlock.
(B) The system is unsafe but can automatically recover from a deadlock.
(C) The system is safe. The safe sequence is P1 -> P2 -> P3 -> P4.
(D) The system is safe. The safe sequence is P1 -> P3 -> P2 -> P4.
(E) None of the above.
Answer: (A) The system is unsafe and may lead to a deadlock.

Assignment 9

Q1. Assume that the computer system’s memory includes eight pages, and each page size is
1KB. The size of the physical memory is thirty-two pages. The number of bits required to
represent the logical address and physical address are
(A) 13 bits and 15 bits
(B) 12 bits and 16 bits
(C) 14 bits and 14 bits
(D) 11 bits and 17 bits
(E) 16 bits and 12 bits
Answer: (A) 13 bits and 15 bits
[No. of page is 8, size is 1KB, size of logical memory 8 × 1024 = 2 Bytes. No of pages = 32,
13

Physical memory size = 32 × 1024 Bytes = 2 Bytes.]


15

Q2. Choose the correct statement.


(A) Base register holds the starting address of a memory block or segment.
(B) Base register ensures that a program can only access memory locations within its allocated
segment.
(C) Base register allows the program to run correctly regardless of its actual location in
memory for dynamic memory allocation.
(D) Base register can reduce the need for frequent memory address recalculations.
(E) All of the above
Answer: (E) All of the above

Q3. Assume that a computer system uses m bits for logical address and n bits for physical
address. The logical address space size is 2 bytes, and the page size is 2 bytes. The number
m n

of bits required to represent the page number and offset are


(A) (n - m) bits, and n bits
(B) n bits, and m bits
(C) (m - n) bits, and n bits
(D) (m - n) bits, and m bits
(E) m bits, and n bits
Answer: (C) (m - n) bits, and n bits

Q4. The wastage of memory within a partition or paging is called as


(A) External fragmentation
(B) Internal fragmentation
(C) Segmentation
(D) De-fragmentation
(E) Segmented with paging
Answer: (B) Internal fragmentation

Q5. Assume that a computer system uses a paging scheme. The page size 4KB. The size of the
user process is 50000 bytes. What amount of memory will be wasted?
(A) 1632 Bytes
(B) 2048 bytes
(C) 3048 bytes
(D) 3248 Bytes
(E) 4092 Bytes
Answer: (D) 3248 Bytes
[Page size = 4KB = 4096 bytes. Total page required = 50000/4096 = 12.20 = 13 page. Allocated
memory = 13 pages × 4 KB/page = 18 × 4,096 bytes = 53248 bytes. Internal fragmentation =
73,728 bytes - 72,500 bytes = 1,228 bytes. Internal fragmentation = 53248 - 50000 bytes =
3248 bytes.]

Q6. Assume that a computer system is using the two-level paging scheme. The size of the
page is 4KB. Assume that the size of each entry in page tables is 4 bytes. The computer system
used a 64-bit logical address and a 64-bit physical address. The first-level page table has 232
entries, and each second-level page table also has 2 entries. The system uses a single MMU
20

register for the first-level page table entry. What is the size of the total memory consumed by
the first-level and second-level page tables?
(A) 16GB and 4MB
(B) 4MB and 15GB
(C) 8GB and 8GB
(D) 16GB and 4GB
(E) 16GB and 16GB
Answer: (A) 16GB and 4MB
[Size of the first-level page table = 2 × 4 bytes = 2 × 2 Bytes = 16GB. second-level page table
32 30 4

size = 2 × 4 bytes = 2 × 2 Bytes = 4MB.]


20 20 4

Q7. Assume that a computer system follows “fixed variable multiple partitions” memory
allocation method. The memory is partitioned as follows (in order):
Block Number Block Size
1 200KB
2 350KB
3 100KB
4 400KB
5 375KB

The Best-fit memory management algorithm places the following processes of size 218KB,
410KB, 115KB, 345KB, and 100KB (in order). What is the amount of internal and external
fragmentations?
(A) 600KB and 47KB
(B) 47KB and 400KB
(C) 47KB and 200KB
(D) 47KB and 600KB
(E) 200KB and 400KB
Answer: (D) 47KB and 600KB
[Processes 218KB and 115KB will be fitted in Blok 2. Process 345KB will be fitted in block 5.
Process 410KB can’t be fitted in any block. Process 100KB is fitted with Block 3. Therefore,
International fragmentation is = (350 - (218+115)) + (100-100) + (375-345) = 17 + 30 = 47KB.
External fragmentation is (200+400) = 600KB.]

Q8. Choose the correct statement.


(A) Compaction is possible only for variable-sized memory partitions
(B) Compaction is primarily used to reduce external fragmentation
(C) Compaction is only possible if dynamic memory allocation is available
(D) Compaction cannot be executed while I/O is in progress
(E) All of the above
Answer: (E) All of the above

Q9. The Segment-Table Base Register (STBR) is used to hold


(A) the size of each segment in memory
(B) the base address of the segment table
(C) the end address of each segment
(D) the physical address of the CPU registers
(E) the allocation status of system memory
Answer: (B) the base address of the segment table

Q10. The Page-Table Length Register (PTLR) is used in the paging scheme to
(A) hold the number of pages currently in use
(B) hold the base address of the page table
(C) manage the cache for page table entries
(D) store the addresses of the page table entries
(E) indicate the length of the page table in memory
Answer: (E) indicate the length of the page table in memory

Assignment 10

Q1. In a paging system with TLB. It takes 30ns to search the TLB, and 50ns to search for access
to the memory. If the TLB hit ratio is 85%, what is the effective memory access time?
(A) 83ns
(B) 87.5ns
(C) 85.5ns
(D) 84ns
(E) 80.5ns
Answer: (A) 83ns
[TLB hit time = Time to access TLB + Time to access memory = 30 ns + 50 ns = 80 ns. TLB miss
time = Time to access memory twice (one for page table lookup, one for actual memory
access) = 2 × 50 ns = 100ns. TLB hit ratio = 85% = 0.85. TLB miss ratio = 15% = 0.15. Effective
Memory Access (EAT) time = (0.85 × 80ns) + (0.15 × 100ns) = 83ns]

Q2. A computer system with 512 bytes of main memory runs a process with four segments of
unequal size. The process is loaded in the main memory using the following segment table.
Segment number Base Address (in decimal) Length (in bytes)
0 20 40
1 80 50
2 135 30
3 180 100
If the computer system uses the 11-bit addresses, what is the physical address corresponding
to the logical address 11000001101?
(A) 011001001
(B) 011001100
(C) 111001101
(D) 011001101
(E) Address is out of the segment
Answer: (D) 011001101
[Total number of segments is 4 = 2 . Therefore, the initial 2 bits (the two most significant
2

bits) represent the segment number. If the logical address is 11000001101, then the
segment number is 11, i.e., 3. The remaining 9 bits, i.e., 000001101 map to the actual
physical address. The decimal equivalent of 000001101 is 25. Segment 3 has a base address
of 180 (decimal). Therefore, 010011001 represents the physical address 180 + 25 = 205, i.e.,
011001101.]

Q3. Choose the correct statement for the hashed page table.
(A) It is primarily used in systems with small address spaces.
(B) It stores page table entries in a contiguous memory block.
(C) Each hashed table entry stores only the frame number of the corresponding page.
(D) It is generally faster than an inverted page table.
(E) It uses the virtual page number to compute the hash value, which determines the location
in the table.
Answer: (E) It uses the virtual page number to compute the hash value, which determines the
location in the table.

Q4. The physical address in an inverted page table memory management scheme is the
combination of
(A) process id and virtual page number
(B) index of the page table and virtual page number
(C) index of the page table and offset
(D) index of the page table and process id
(E) None of these
Answer: (C) index of the page table and offset

Q5.Choose the correct statement for Intel IA-32 architecture.


(A) It supports 64-bit general-purpose registers
(B) It supports 64-bit physical address space
(C) It supports a three-level paging scheme
(D) It supports 4KB or 4MB page sizes
(E) It does not support a paging scheme
Answer: (D) It supports 4KB or 4MB page sizes

Q6. The Effective Memory Access time for the Demand paging scheme is directly affected by
(A) degree of multi-programming
(B) number of pages
(C) number of frames
(D) size of memory
(E) page fault rate
Answer: (E) page fault rate

Q7. Choose the main benefit of using a hierarchical (multi-level) paging scheme over a single-
level paging scheme.
(A) It decreases the page fault rate
(B) It reduces memory access overhead
(C) It decreases the page table size
(D) It improves the physical memory utilization
(E) It simplifies the address translation process
Answer: (C) It decreases the page table size

Q8.Choose the correct statement.


(A) The valid bit in the page table entry indicates that the corresponding page is available in
the main memory.
(B) The invalid bit in the page table entry means the page is inaccessible and may cause a page
fault if referenced.
(C) The valid/invalid bits ensure that a process can only access its address space and not the
address space of other processes.
(D) The valid/invalid bits help make page replacement decisions.
(E) All of the above.
Answer: (E) All of the above.

Q9. Assume that a computer system uses an inverted page table for memory management.
The system uses a 16-bit virtual address, and each virtual address is of the form <process id,
virtual page number, offset>. The size of process id, virtual page number, and offset are 4 bits,
6 bits, and 6 bits, respectively. Assume that the system uses the physical address of 9 bits.
The page table of the system is given below.
Index (3 bits) Process id (4 bits) Virtual page number (6 bits)
000 0000 000111
001 1001 111001
010 0010 101010
011 1010 110011
100 0100 011100
101 1101 100101
110 0110 100110
111 1111 010111
If the CPU generates the virtual address 1010100101101010, what is the corresponding
physical address?
(A) 011101010
(B) 110101010
(C) 000101010
(D) 011101111
(E) 011111110
Answer: (A) 011101010
[The virtual address is 1010100101101010. Therefore, pid is 1010. The vpn is 100101, and
the offset is 101010. The pid will give the index in the page table. Here, the pid is 1010,
indicating the index is 011. The physical address is <index||offset>, and so 011101010 is the
physical address.]

Q10. Which actions occur when a page fault happens in a demand paging system?
(A) The process is terminated immediately.
(B) The requested page is loaded from secondary storage into physical memory.
(C) The process is suspended until all pages are swapped out.
(D) The page table entry is marked as invalid.
(E) The physical memory is immediately allocated to the process.
Answer: (B) The requested page is loaded from secondary storage into physical memory.

Assignment 11

Q1. Assuming that the memory frames are initially empty, for the page reference string: 5, 0,
2, 1, 0, 3, 0, 2, 4, 3, 0, 3, 2, 1, 3. Compute the number of page faults in the FIFO page
replacement policy with three memory frames.
(A) 11
(B) 12
(C) 13
(D) 14
(E) 15
Answer: (C) 13

str ref. 5 0 2 1 0 3 0 2 4 3 0 3 2 1 3
f0 5 5 5 1 1 1 1 2 2 2 0 0 0 0 3
f1 0 0 0 0 3 3 3 4 4 4 4 2 2 2
f2 2 2 2 2 0 0 0 3 3 3 3 1 1
Page fault? Y Y Y Y N Y Y Y Y Y Y N Y Y Y
Q2. Calculate the page fault rate for the following reference string: 5, 0, 2, 1, 0, 3, 0, 2, 4, 3, 0,
3, 2, 1, 3, using the optimal page-replacement algorithm with three frames.
(A) 40%
(B) 46.66%
(C) 60%
(D) 66.66%
(E) 53.33%
Answer: (E) 53.33%

str ref. 5 0 2 1 0 3 0 2 4 3 0 3 2 1 3
f0 5 5 5 1 1 3 3 3 3 3 3 3 3 3 3
f1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
f2 2 2 2 2 2 2 4 4 4 4 2 1 1
Page fault? Y Y Y Y N Y N N Y N N N Y Y N
Page fault rate = (8/15) × 100 = 53.33%

Q3. Consider a computer system executing a process of size 12KB in the main memory with
the following page reference strings: 5, 0, 2, 1, 0, 3, 0, 2, 4, 3, 0, 3, 2, 1, 3. The size of each
page is 4KB. Compute the number of page fault rate for the Least Recently Used (LRU) page
replacement algorithm for three frames.
(A) 46.66%
(B) 66.66%
(C) 53.33%
(D) 73.33%
(E) 63.33%
Answer: (D) 73.33%

str ref. 5 0 2 1 0 3 0 2 4 3 0 3 2 1 3
f0 5 5 5 1 1 1 1 2 2 2 0 0 0 1 1
f1 0 0 0 0 0 0 0 0 3 3 3 3 3 3
f2 2 2 2 3 3 3 4 4 4 4 2 2 2
Page fault? Y Y Y Y N Y N Y Y Y Y N Y Y N
Page fault rate = (11/15) × 100 = 73.33%

Q4. Consider a computer system with 12KB of main memory, and each frame/page size is
4KB. Assume that a process of size 20KB will be executed in the main memory with the
following page reference string 0, 1, 2, 3, 4, 1, 2, 0, 1, 2, 1, 4, 1. Compute the page fault rate
for the second-chance (clock) page replacement algorithm.
(A) 60%
(B) 50%
(C) 40%
(D) 70%
(E) 55%
Answer: (A) 60%

str 0 1 2 3 4 1 2 0 1 2 1 4 1
ref.
f0 0(0 0(0 →0(0 3(0) 3(0) →3(0 2(0) 2(0) 2(0) 2(1) 2(1) 2(1) →2(0
) ) ) ) )
f1 → 1(0 1(0) →1(0 4(0) 4(0) →4(0 0(0) 0(0) 0(0) 0(0) 4(0) 4(0)
) ) )
f2 → 2(0) 2(0) →2(0 1(0) 1(0) →1(0 →1(1 →1(1 →1(1 →1(0 1(1)
) ) ) ) ) )
Page Y Y Y Y Y Y Y Y N N N Y N
fault
?
Page fault rate = (9/15) × 100 = 60%

Q5. Assume that a computer system executes three processes P , P , and P . The P , P , and P
1 2 3 1 2 3

processes are allocated 32, 189, and 65 pages. The size of each frame is 4KB. The size of the
physical frame is 460KB. How many frames will be allocated to each process following the
“Proportional allocation” strategy?
(A) 13, 76, and 26
(B) 13, 75, and 27
(C) 12, 76, and 27
(D) 32, 189, and 65
(E) 14, 74, and 27
Answer: (A) 13, 76, and 26
Number of frames = 460/4 = 115. S = 32+189+65=286. P gets = (32/286) × 115 = 12.86 ≈ 13
1

frames. P gets = (189/286) × 115 = 75.99 ≈ 76 frames. P gets = (65/286) × 115 = 26.13 ≈ 26
2 3

frames.]

Q6. The optimal page replacement algorithm is not practical because


(A) memory access time is unknown
(B) page size is unknown
(C) TLB search time is unknown
(D) the size of the working set is unknown
(E) future memory references are unknown
Answer: (E) future memory references are unknown

Q7. Choose the correct statement concerning the Enhanced Second-Chance page
replacement algorithm.
(A) It is a modification of the FIFO page replacement algorithm.
(B) It uses reference and modification (dirty) bits to decide which page to replace.
(C) Pages with reference and modification bits set to 1 are replaced first.
(D) It only uses the reference bit to determine if a page gets a second chance.
(E) It does not consider the modification bit during page replacement.
Answer: (B) It uses reference and modification (dirty) bits to decide which page to replace.

Q8. Assume that a computer system executes a process in the main memory with the
following page reference strings: 3, 3, 4, 2, 3, 5, 3, 5, 1, 4. The initial working set window size
(∆) is 4. The initial working set window at time t = 0 contains the pages {5,4,1}, where
page 5 was referenced at time t = -2, page 4 at time t = −1, and page 1 at time t = 0. What is
the total number of page faults and the average number of page frames used by computing
the working set at each reference?
(A) 5 and 3.5
(B) 5 and 4.5
(C) 6 and 3.2
(D) 5 and 3.2
(E) 4 and 4.2
Answer: (D) 5 and 3.2

[∆=4, Initial pages in the working set window = {e,d,a}.


Ref. page Time Working set window (∆) Fault? Current window size
3 1 {5,4,1,3} Y 4
3 2 {4,1,3} N 3
4 3 {1,3,4} N 3
2 4 {3,4,2} Y 3
3 5 {4,2,3} N 3
5 6 {4,2,3,5} Y 4
3 7 {2,3,5} N 3
5 8 {3,5} N 2
1 9 {3,5,1} Y 3
4 10 {3,5,1,4} Y 4
Total number of page faults = 5. Average no. of page frames used by window set =
(4+3+3+3+3+4+3+2+3+4)/10 = 3.2]
Q9. The LRU algorithm can be implemented using
(A) Additional-Reference-Bits
(B) Counter
(C) Second-Chance Algorithm
(D) Stack
(E) All of the above
Answer: (E) All of the above

Q10. A global page replacement algorithm


(A) allocates a fixed number of frames to each process.
(B) replace a page within the frames allocated to the specific process.
(C) is more flexible but can cause one process to take a disproportionate amount of memory.
(D) ensures that each process gets an equal share of memory frames.
(E) ensures better locality of reference compared to local page replacement algorithms.
Answer: (C) is more flexible but can cause one process to take a disproportionate amount of
memory.
Assignment 12

Q1. Suppose that a disk drive has 200 cylinders numbered 0 to 199. Consider a disk queue
with I/O requests on the following cylinders in their arriving order: 54, 95, 73, 130, 25, 48,
110, 30, 45, 180, and 190. The disk head is assumed to be at cylinder 24. Starting from the
current head position, what is the total distance (in cylinders) the disk arm moves to satisfy
all the pending requests for the FCFS disk-scheduling algorithm?
(A) 580 cylinders
(B) 589 cylinders
(C) 643 cylinders
(D) 570 cylinders
(E) 585 cylinders
Answer: (A) 580 cylinders
[The read/write head moves as follows: 24 → 54 → 95 → 73 → 130 → 25 → 48 → 110 → 30
→ 45 → 180 → 190. Total head movement is (54-24)+(95-54)+(95-73)+(130-73)+(130-
25)+(48-23)+(110-48)+(110-30)+(45-30)+(180-45)+(190-180) = 30 + 41 + 22 + 57 + 105 + 23 +
62 + 80 + 15 + 135 + 10 = 580 cylinders.]

Q2. In a demand-paging system, the paging device has an average latency of 6ms, seek time
of 5ms, and transfer time of 0.1ms. The disk has a queue of waiting processes. The average
waiting time is 5ms. If the memory access time is 150ns and the page fault rate is 10%. The
effective memory access time is
(A) 1.61ms
(B) 1.22ms
(C) 2.712ms
(D) 1.50ms
(E) 1.45ms
Answer: (A) 1.61ms
[Page fault service time is (6+5+0.1+5) = 16.10ms. Memory access time = 150ns =
0.000150ms. EAT = (0.10 × 16.10) + (1-0.10) ×0.00015 = 1.610135ms = 1.61ms]

Q3. Suppose that a disk drive has 500 cylinders numbered 0 to 499. The drive currently serves
a request at cylinder 143; the previous request was at cylinder 125. The queue of pending
requests, in FIFO order, is 86, 170, 213, 474, 148, 109, 222, 450, and 330. Starting from the
current head position, what is the total distance (in cylinders) the disk arm moves to satisfy
all the pending requests for the SSTF disk-scheduling algorithm?
(A) 680 cylinders
(B) 580 cylinders
(C) 700 cylinders
(D) 750 cylinders
(E) 719 cylinders
Answer: (E) 719 cylinders
[The current head position is at cylinder 143. The head will move to cylinder 148 with a
minimum seek distance |148 − 143| = 5. Therefore, the SSTF schedule is 170, 213, 222, 330,
450, 474, 109, and 86. The total seek distance is |148 - 143| + |170 - 148| + |213 - 170| + |222 -
213| + |330 - 222| + |450 - 330| + |474 - 450| + |109 - 474| + |86 - 109| = 719 cylinders.]

Q4. Suppose that a disk drive has 140 cylinders numbered 0 to 139. Consider a disk queue
with requests for I/O to blocks on cylinders 6, 10, 12, 54, 97, 73, 128, 15, 44, 110, 34, and 45
in that order. Assume that the head is moving toward decreasing the order of the cylinder
numbers. Initially, the disk head is at cylinder 20. Starting from the current head position,
what is the total distance (in cylinders) the disk arm moves to satisfy all the pending requests
for the SCAN disk-scheduling algorithm?
(A) 150 cylinders
(B) 155 cylinders
(C) 158 cylinders
(D) 165 cylinders
(E) 170 cylinders
Answer: (C) 158 cylinders
[The read/write head is moved as follows: 20 → 15 →12 →10 →6 →0 →34 →44 →45 →54
→73 →97 →110 →128 →139. Total read/write movement is |20-15|+|15-12|+|12-
10|+|10-6|+|6-0|+|34-0|+|44-34|+|45-44|+|54-45|+|73-54|+|97-73|+|110-97|+|128-
110|+|139-128|= 5+3+2+4+6+34+10+1+9+19+24+13+18=158 cylinders.]

Q5. Suppose that a disk drive has 500 cylinders numbered 0 to 499. Consider a disk queue
with requests for I/O to blocks on cylinders 10, 120, 147, 312, 180, 444, 355, 470, 290, and
170, in that order. Assume that the head is moving toward decreasing the order of the
cylinder numbers. Initially, the disk head is at cylinder 100. Starting from the current head
position, what is the total distance (in cylinders) the disk arm moves to satisfy all the pending
requests for the C-SCAN disk-scheduling algorithm?
(A) 1328 cylinders
(B) 1220 cylinders
(C) 1350 cylinders
(D) 1380 cylinders
(E) 1280 cylinders
Answer: (A) 1328 cylinders
[The read/write head is moved as follows: 100 →10 →0 →499 →120 →147 →170 →180
→290 →312 →355 →444 →470. Total read/write head movement is |100 - 10|+ |10 -
0|+|499-0|+|499 - 120|+ |147 - 120|+ |170 - 147|+ |180 - 170|+ |290 - 180|+ |312 - 290|+ |355 -
312|+ |444 - 355|+ |470 - 444|= 90 + 10 + 499 + 379 + 27 + 23 + 10 + 110 + 22 + 43 + 89 + 26 =
1328 cylinders.]

Q6. Suppose that a disk drive has 400 cylinders numbered 0 to 399. Consider a disk queue
with I/O requests on the following cylinders in their arriving order: 26, 120, 226, 354, 197,
373, 228, 315, 244, 110, 34, and 45. The read/write head is positioned at cylinder 123 and
moving in the direction of decreasing cylinder number. Starting from the current head
position 123, what is the total distance (in cylinders) the disk arm moves to satisfy all the
pending requests for the LOOK disk-scheduling algorithm?
(A) 345 cylinders
(B) 245 cylinders
(C) 444 cylinders
(D) 440 cylinders
(E) 340 cylinders
Answer: (C) 444 cylinders
[The read/write head is moved as follows: 123 → 120 → 110 → 45 → 34 → 26→197 → 226 →
228 → 244 → 315 → 354 → 373. Total head movement is (123-120)+(120-110)+(110-45)+(45-
34)+(34-26)+(197-26)+(226-197)+(228-226)+(244-228)+(315-244)+(354-315)+(373-354) = 3 +
10 + 65 + 11 + 8 + 171 + 29 + 2 + 16 + 71 + 39 + 19 = 444 cylinders]

Q7. Suppose that a disk drive has 200 cylinders numbered 0 to 199. Consider a disk queue
with I/O requests on the following cylinders in their arriving order: 54, 95, 73, 130, 25, 48,
110, 30, 45, 180, and 190. The read/write head is positioned at cylinder 43 and moving in the
direction of decreasing cylinder number. Starting from the current head position 43, what is
the total distance (in cylinders) the disk arm moves to satisfy all the pending requests for the
C-LOOK disk-scheduling algorithm?
(A) 328 cylinders
(B) 324 cylinders
(C) 320 cylinders
(D) 316 cylinders
(E) 312 cylinders
Answer: (A) 328 cylinders
[The read/write head is moved as follows: 43 → 30 → 25 → 190 → 180 → 130 → 110 → 95
→ 73 → 54 → 48 → 45. Total head movement is (43-30) + (30-25) + (190-25) +(190-180) +
(180-130) +(130-110) +(110-95) +(95-73) +(73-54) +(54-48) + (48-45) = 13 + 5 + 165 + 10 + 50
+ 20 + 15 + 22 + 19 + 6 + 3 = 328 cylinders.]

Q8. Choose the disk space allocation methods that allow efficient random access to file blocks
and minimise external fragmentation.
(A) Contiguous Allocation
(B) Linked Allocation
(C) Indexed Allocation
(D) File Allocation Table (FAT)
(E) Free Space Management
Answer: (C) Indexed Allocation

Q9. When the object files have been linked properly and are ready to run, they are known as
(A) archive files
(B) batch files
(C) object files
(D) executable files
(E) library files
Answer: (D) executable files

Q10. RAID structure is used to


(A) improve the performance of the data storage system
(B) improve the reliability of the data storage system
(C) make the data storage system fault-tolerant
(D) improve the data recovery
(E) All of the above
Answer: (E) All of the above

Which of the following is not an input device for a computer system?

(A) Keyboard

(B) Light Pen

(C) Barcode Reader

(D) Arithmetic-logic unit

(E) Microphone
Accepted Answers:
(D) Arithmetic-logic unit

Which of the following is not an output device for a computer system?

(A) Printer

(B) Monitor

(C) Speaker

(D) Headphone

(E) Joy Stick


Accepted Answers:
(E) Joy Stick

Which of the following task is not performed by the arithmetic-logic unit (ALU)?

(A) Addition and subtraction operations

(B) Division by zero operation

(C) Increment and Decrement operations

(D) OR, AND, and XOR operations

(E) One's complement operation


Accepted Answers:
(B) Division by zero operation

Which of the following language is directly understood by the computer system?

(A) JAVA

(B) Python

(C) Machine/Binary
(D) C++

(E) FORTRAN 77
Accepted Answers:
(C) Machine/Binary
Which of the following is the main component or brain of the computer system?

(A) Main memory

(B) Secondary memory

(C) CPU

(D) Input unit

(E) Output unit


(C) CPU
Which of the following is a volatile memory of a computer system?

(A) Read-only memory (RAM)

(B) Random access memory (RAM)

(C) Magnetic disk

(D) Solid-state disk

(E) Optical disk


Accepted Answers:
(B) Random access memory (RAM)
A pointer variable (C programming) is used to

(A) hold the address of the current instruction executed by the processor

(B) hold the address of the next instruction to be executed by the processor

(C) hold the address of another variable

(D) hold a constant value

(E) hold the address of an input/output device


Accepted Answers:
(C) hold the address of another variable
The memory address register (MAR) of the processor is used to

(A) hold the address of the next instruction to be executed by the processor

(B) hold the address of the current instruction to be fetched from the memory

(C) hold the data to be used by the processor at the next clock cycle

(D) hold (temporarily) the data being processed and the results of calculations

(E) help to exchange the data between an I/O device and the processor
Accepted Answers:
(B) hold the address of the current instruction to be fetched from the memory
What will be the output of the following program code?

#include<stdio.h>
int main()
{
float x = 20.20;
void *p = &x;
printf("%f\n", (float)*p);
return 0;
}

(A) Compile-time error

(B) Run-time error


(C) Segmentation fault

(D) 20.20

(E) 20
Accepted Answers:
(A) Compile-time error
What is the pointer equivalent expression of a[i]?

(A) *(a+i)

(B) (a+i)

(C) &(a+i)

(D) (a[0]+i)

(E) *a+i
Accepted Answers:
(A) *(a+i)

You might also like