Unit 1
Operating system and functions, Classification of Operating systems- Batch, Interactive, Time-sharing, Real Time System, Multiprocessor Systems, Multiuser Systems, Multi-process Systems, Multithreaded Systems, Operating System Structure: Layered structure, System Components, Operating System services, Re-entrant Kernels, Monolithic and Microkernel Systems.
Q101 – Which of the following is/are not a valid reason for process creation?
(i) Created by OS
(ii) Interactive logon
(iii) Privileged instruction
(i), (ii)
(ii), (iii)
(i), (iii)
(iii) only
Ans – (4)
Explanation – A privileged instruction is not an appropriate justification for creating processes.
Q102 – Which of the following statements is/are always true?
(i) Time taken for mode switch is always greater than process switch.
(ii) Time taken for mode switch is always equal to process switch.
(iii) Time taken for mode switch is always less than process switch.
Â
(i) and (iii)
(ii) and (iii)
Only (i)
Only (iii)
Ans – (4)
Explanation – Switching between modes (from user to kernel or from kernel to user) only requires changing the CPU’s mode, making it faster than a full process context switch, which necessitates saving and restarting the entire process state.
Q103 – For each thread in a multithreaded process, there is a separate
Process control block
User address space
User and Kernel stack
Kernel space only
Ans – (3)
Explanation – For instance, each thread in a process executes its own stack for both user-mode execution (user stack) and kernel- mode execution(kernel stack). Function calls, local variables, and context are managed by these stacks while the thread is running.
Q104 – Which of the following needs to be saved on a context switch between processes?
General purpose registers
Translation look aside buffer
Program counter
All of the above
Ans – (4)
Explanation – General Purpose registers — these registers store temporary data for a running process. They need saving during a context switch to allow the process to continue .
Translation Lookaside Buffer (TLB) – The TLB stores converted virtual memory addresses to physical addresses. Saving it isn’t always necessary. The architecture in question could empty the TLB and fill it again when the new process runs, depending on the machine. But sometimes (based on the system) you might need to save it to ensure proper address translation.
Program Counter – The Program Counter holds the address of the next instruction to run. It must be saved on context switch so the process can start where it stopped.
Q105 – Many to many multithreading models is used in which of the following operating system?
Windows NT/2000 with thread fibres
Windows 95
Windows 98
Solaris Green threads
Ans – (1)
Explanation – The many to many multithreading models permit multiple user-level threads to be associated with multiple kernel-level threads. This approach provides flexibility in managing thread scheduling and execution, usually through a thread library. It allows applications to create more threads than there are kernel threads, which can be advantageous in certain scenarios.
Windows NT/2000 utilizes thread fibres to support the many-to-many threading model. Fibers are user-level threads that the application controls, while the kernel is responsible for their scheduling.
Q106 – Assume a program needs to implement threads, what are the resources that need to be encompassed in critical section?
(i) Global variables
(ii) Local variables
(iii) Static variables
(iv) Function parameters that are passed as a reference pointers
(v) Global constants
Â
(i), (ii), (iii), (v)
(i), (iv), (v)
(i), (iii), (v)
(i), (iii), (iv)
Ans – (4)
Explanation – A critical section is that portion of a program where shared resources are being accessed, and possibly modified by more than one thread. The shared resources whose potential interference in its use must be, therefore, guarded in the critical section must include at least.
Global variables are shared between threads and are thus required to be guarded whenever several threads access or modify them.
Like global variables, static variables preserve their values during function calls and are visible to all the threads. These need to be protected.
When function parameters are passed as reference pointers, they represent shared memory addresses which may be accessed by various threads. Again, these should also be guarded within the critical section to avoid a race.
Q107 – What are the necessary steps for a new process creation?
(i) Assign an identifier to the new process.
(ii) Suspend all other process.
(iii) Allocate space for the process.
(iv) Initialize process control block.
(v) Update process related data structures.
(vi) Update process state information wherever necessary.
(vii) Set the process to user mode.
(viii) Notify all the machines in the network about the new process.
(ix) Set the state of the new process as suspended.
Â
All except (ii), (v), (vi), (viii)
All except (ii), (vii), (viii), (ix)
All except (iv), (v), (vii), (ix)
All except (iii), (iv), (vii), (ix)
Ans – (2)
Explanation – Suspension of other processes is not needed for a new process creation.
The process is not set to user mode at creation time, it will enter user mode only when scheduled to run.
Process creation on a local machine does not require all the machines to be notified.
A new process is created mostly in the ready state and not suspended.
Q108 – The advantage of having multiple threads over multiple processes is
(i) Less time for creation
(ii) Less time for termination
(iii) Less time for switching
(iv) Kernel not involved in communication among threads
(i), (ii), (iii)
(i), (ii), (iv)
(ii), (iii), (iv)
(i), (ii), (iii), (iv)
Ans – (4)
Explanation – Threads have many benefits in comparison to processes because threads can share the same address space in a process; thus, overhead is reduced and efficiency is enhanced. Now let’s prove each statement
It takes less time for thread creation than process creation because for each process created, memory will be allocated, and the environment need to be set up. On the other hand, threads share existing memory.
It is faster to terminate a thread compared to a process since a thread does not need to release independent system resources as it would for a process.
The context switching between threads is faster compared to between processes because threads share the memory and there is no need to switch the memory address space.
In threads of the same process communication happens without interventing the Kernel by shared memory. Processes necessitate Inter-Process Communication (IPC) mechanisms. it may require a pipe, or a queue.
Q109 – For each of the following transition between process states, which transition is not possible?
Running –> Ready
Blocked –> Suspend
Ready –> Ready/Suspend
Blocked –> Running
Ans – (4)
Explanation – A blocked process is waiting for an event (e.g., I/O completion) and cannot directly transition to running.
Instead, after an event occurs, it moves directly to the ready state, and after that, the scheduler brings it into the running state.
Q110 – Which of the following is not an advantage of thread?
Inter-process communication.
Less memory space occupied by thread.
Less time to create and terminate than a process.
Context switching is faster.
Ans – (1)
Explanation – However, these have the advantage over processes in terms of the use of memory, faster creation and termination, and efficient context switching. However, inter-process communication (IPC) is not an advantage as that is not possible with threads. Each thread shares the same memory in the process. IPC is actually the need to communicate among different processes and not inside a process.
Q111 – In fork() system call, the return value to the parent process and the child process are respectively
PID of child process, 1
PID of child process, 0
PID of child, PID of parent process
PID of parent process, PID of child
Ans – (2)
Explanation – A new child process is created by duplicating the parent process in the fork() system call. Return values of the fork() differ for the parent and child processes.
Parent Process – fork() returns the PID (Process ID) of the child process to the parent. This enables the parent to recognize and control its child process.
Child Process – fork() returns 0 to the child process.
This facilitates the child process to know that it is running as a separate instance.
Q112 – A process executes the following segment of code
for(i = 1; i < 10; i++)
fork();
The number of new processes created is
1024
1023
1025
1028
Ans – (2)
Explanation – Each fork() generates a new process, and the new process also executes the remaining loop iterations.
A process is present at iteration i, it will generate one new process at that step.
The number of processes grows exponentially
Total processes = 2n where n is the number of calls to fork().
The loop iterates from i = 1 to i < 10, so there are 9 iterations.
Number of processes after 9 iterations, Total processes = 2^9 = 512 but this counts the original process.
The number of new processes created is 2^10 – 1 = 1023.
Q113 – An operating system can be mapped to a five-state process model. A new event has been designated as capable to pre-empt the existing processes in order to trigger a new process to complete. Select the correct statement from below
A new state needs to be added to the existing transition model to accommodate the changes.
The existing model still holds good.
Both the states and transition of the existing model have to be changed.
Only the transitions need to be modified.
Ans – (4)
Explanation – The question states that a new event can preempt existing processes to allow a new process to complete.
Pre-emption means that a running process is moved to the ready state if a higher-priority process arrives.
Why Only Transitions Need Modification?
The five-state model already accommodates process transitions.
However, there may be a need for another transition (potentially from Ready to Running) to represent an immediate execution of the new process when pre-empting an existing process.
No need to add another state because all possible states of a process are already available.
Q114 – Select the correct sequence of steps taken by the processor when an interrupt occurs
(i) Switch from user mode to kernel mode.
(ii) Set the program counter to the first instruction of the interrupt handling routine.
(iii) Save the current context.
Â
(i), (ii), (iii)
(i), (iii), (ii)
(iii), (ii), (i)
(ii), (i), (iii)
Ans – (3)
Explanation – The processor saves the current state, which includes registers, program counter, stack pointer, etc., so that execution can be resumed later.
The address of the interrupt service routine (ISR) is added to the program counter (PC) so the CPU knows where it should go for execution next.
The processor switches from user mode to kernel mode because interrupt handling requires privileged access to system resources.
Q115 – A processor while executing the instruction sequence of user mode process, received n interrupts. If no other activity is reported to processor during execution of the instruction sequence, what is the number of mode switches and process switches experienced?
2n, 2n
n, n
2n, 0
n, 0
Ans – (3)
Explanation – The processor changes mode from user mode to kernel mode each time an interrupt occurs and processes it.
After the interrupt is serviced, the processor returns to user mode from kernel mode.
Since there are n interrupts, there will be 2n mode switches per interrupt.
No process switches occur because the same process continues to run in user mode after each interrupt, and the interrupts do not involve switching to a different process.
Hence, the total number of process switches is 0.
Q116 – What is kernel-level thread?
(i) Threads that are spawned by OS kernel
(ii) Threads that are launched by user by directly accessing the kernel
(i) only
(ii) only
Both (i), (ii)
Neither (i) nor (ii)
Ans – (1)
Explanation – A kernel-level thread is a thread that is managed and scheduled by the operating system kernel. In this model, the kernel creates, schedules, and manages the threads. The kernel has direct control over the creation, scheduling, and management of threads.
Q117 – Which of the following does not interrupt a running process?
Device
Timer
Scheduler
Power failure
Ans – (3)
Explanation – The scheduler does not directly interrupt a process that is currently running. Its role is to decide which process will receive CPU time next. It can schedule a process to run when another process is pre-empted or completed, but it does not perform the interruption itself. The actual interruptions occur due to events such as timer interrupts, device interrupts, or system calls.
Q118 – Which of the following actions is/are typically not performed by the OS when switching context from process A to process B?
Saving current register values and restoring the register values for process B
Changing the address translation tables.
Swapping out the memory image of process A to the disk.
Both (2) and (3)
Ans – (3)
Explanation – Swapping out the memory image of process A to the disk – This operation is normally not performed for each context switch. Swapping is typically operated only when the system is under memory pressure i.e., not enough physical memory is available to execute all processes at a time, forcing to move the memory of a process to disk to gain more space.
Changing the address translation tables – This stage can be required when switching from processes that run in different address spaces, particularly when using very different memory mappings, such as separate page tables. The address translation will be modified in that the address translation mechanism of the operating system will be dynamically modified to satisfy the case that the new process needs to access the correct memory space.
Q119 – What is the purpose of jacketing?
Convert non-blocking system call to blocking system call
Convert blocking system call to non-blocking system call
Convert blocking system call into a new thread
Convert non-blocking system call into a new thread
Ans – (2)
Explanation – A method for converting a blocking system call into ‘non-blocking’ calls is known as jacketing.
In system calls, blocking refers to waiting for the process or thread to complete a task, such as reading from files or waiting on user input. Regardless of the operation being completed, non-blocking refers to the system call returning immediately.
Purpose of Jacketing
Rather than blocking the calling process, the system can “jacket” a system call. This can be done by converting a blocking I/O operation to non-blocking, so that the process does not have to wait for it’s completion, and instead has the opportunity to perform other tasks.
Q120 – Which of the following is the property of time sharing systems?
(i) Multiple User Access
(ii) Multiprogramming
Â
(i) only
(ii) only
Both (i) and (ii)
Neither (i) nor (ii)
Ans – (3)
Explanation – Multiple User Access is a key feature of time-sharing systems. These systems allow multiple users to access the system concurrently, with each user being given a small time slice of the CPU.
Multiprogramming is another important feature of time-sharing systems. It allows multiple programs to be loaded into memory and executed in an interleaved manner, making efficient use of the CPU.