Operating systems MCQ questions set 3 for competitive exams with answers
Operating
systems MCQ Set - 3
1.
The memory map of a multithreaded process looks similar to that of a single threaded
process except that the multithreaded one has
a. a copy of the data
segment per thread.
b. a stack for each thread.
c. a heap for each thread.
d. a heap and stack for
each thread
Click here to view answer and explanation
Ans : (b)
Answer: (b)
Each thread
requires a separate stack to be allocated for it (from the memory that is
shared among all threads).
What is a Memory Map of a Process?
A memory map of a process refers to the logical layout of memory
allocated to a process during its execution.
A typical process memory layout contains:
- Text (Code) Segment – Contains program instructions
- Data Segment – Stores global and static variables
- Heap – Used for dynamic memory allocation (malloc, new)
- Stack – Stores function calls, local variables, and return addresses
Key OS Rule about Threads
Threads within the same process share most memory, but each thread has its own stack.
Shared among all threads:
- Code (Text Segment)
- Data Segment
- Heap
- Open files and address space
Private to each thread:
- Stack
- Program Counter
- Registers
Why does each thread need its own stack?
Each thread requires a separate stack to:
- Maintain independent function calls
- Store its own local variables
Without separate stacks, threads would overwrite each other’s data,
leading to incorrect execution.
|
2.
In a thread-aware operating system, which information is no longer stored in the Process Control Block (PCB)?
a. saved registers.
b. process owner.
c. open files.
d. memory map.
Click here to view answer and explanation
Ans : (a)
Answer: (a)
Since each thread
has its own register set, the registers have to be saved per thread in the
Thread Control Block (TCB). The owner, process memory, and open files are
shared among all threads in a process so they can still be tracked in the
Process Control Block.
What is a Process Control Block (PCB)?
A Process Control Block (PCB) is a data structure used by the operating
system to store all the information required to manage a process.
A traditional PCB stores details such as the process ID, process owner, process state,
memory map (address space), open files, scheduling information, and CPU state
(registers and program counter).
What changes in a thread-aware operating system?
In a multithreaded system, a single process can have multiple threads.
Because of this, the operating system separates information into process-level and
thread-level data.
Process-level information is shared by all threads and remains in the PCB.
Thread-level information is private to each thread and is moved to a
Thread Control Block (TCB).
Key OS Rule
The CPU execution state belongs to a thread, not to a process.
The CPU execution state includes saved registers, the program counter, and the stack
pointer. Since each thread has its own execution state, this information cannot remain
in the PCB.
Therefore, the CPU state is moved from the PCB to the TCB.
Answer Explanation
Saved registers represent the CPU state. Because CPU state is different
for each thread, saved registers are stored in the Thread Control Block (TCB) and not
in the Process Control Block (PCB).
|
3.
Inverted page tables are
a. Faster than regular
page tables
b. Smaller than regular page tables
c. More flexible than
regular page tables
d. None of the above
Click here to view answer and explanation
Ans : (b)
Answer:
Inverted page tables contain one
entry per physical frame as opposed to one for each virtual page as in the
case of standard page tables. This makes it much smaller compared to standard
page tables. Inverted page tables are much smaller than regular page tables because they scale with physical memory size, not virtual address space size.
What is a Page Table?
In virtual memory systems, a page table maps virtual pages to
physical memory frames.
In a regular (forward) page table, there is one entry for each virtual page.
If a process has a large virtual address space, its normal page table
becomes very large.
What is an Inverted Page Table?
An inverted page table flips this idea around.
Instead of having an entry for every virtual page, it has
one entry per physical frame.
Physical memory usually has far fewer frames than the number
of possible virtual pages, so inverted page tables are smaller.
|
4.
Assume three jobs arrive at approximately the same time, but Job A arrives
slightly before Job B, and Job B arrives slightly before job C. Job A requires
2 sec of CPU, Job B is 8 secs, and Job C is 7 secs. Assume a time-slice of 1
sec. Given a FIFO scheduler, what is the turnaround time of job B?
a. 0 seconds
b. 2 seconds
c. 8 seconds
d. 10
seconds
Click here to view answer and explanation
Ans : (d)
Answer:
FIFO: A (until
2), B (until 10), C (until 17); B completes at time 10 seconds.
FIFO Scheduler
FIFO stands for First-In-First-Out
(also known as FCFS – First-Come, First-Served).
Under FIFO scheduling, jobs are executed in the
order in which they arrive.
Once a job starts running, it continues until it
finishes execution. There is no preemption.
The CPU switches to the next job only
after the current job completes.
What is Turnaround Time?
Turnaround time for a job is the total time taken from
its arrival to its completion.
Turnaround time is calculated as:
Turnaround Time = Completion Time − Arrival Time
Since Job B arrives roughly with the other jobs
(slightly after Job A and before Job C),
its arrival time is considered close to 0
under FIFO scheduling.
|
5.
Consider a disk with the following characteristics;
Find the number of heads for this disk.
• Number
of surfaces: 8 (= 23)
• Number
of tracks / surface: 512 K (= 219)
• Number
of bytes / track: 8 MB (= 223 bytes)
• Number
of sectors / track: 8 K (= 213)
• On-disk
cache: 16 MB (= 224 bytes)
a. 1
b. 2
c. 4
d. 8
**********
No comments:
Post a Comment