0% found this document useful (0 votes)
94 views13 pages

Cs604p Solved Mcqs

The document contains multiple-choice questions (MCQs) related to operating systems, covering topics such as the Banker's Algorithm, the Dining Philosopher's Problem, the Producer-Consumer Problem, scheduling algorithms, memory management, and thread management. It also includes important formulas for calculating parameters related to these topics. Additionally, it provides command line instructions for directory and file management in a Unix-like environment.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
94 views13 pages

Cs604p Solved Mcqs

The document contains multiple-choice questions (MCQs) related to operating systems, covering topics such as the Banker's Algorithm, the Dining Philosopher's Problem, the Producer-Consumer Problem, scheduling algorithms, memory management, and thread management. It also includes important formulas for calculating parameters related to these topics. Additionally, it provides command line instructions for directory and file management in a Unix-like environment.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

CS604P (Operating System Practical) MCQS By ASIM FAROOQ

1. What is the primary purpose of the Banker's Algorithm?


- A. Resource allocation
- B. Deadlock avoidance
- C. Memory management
- D. Process synchronization
2. Which data structure is NOT used in the Banker's Algorithm?
- A. Available
- B. Allocation
- C. Need
- D. Semaphore
3. In the Banker's Algorithm, what does the "Need" matrix represent?
- A. Maximum demand of each process
- B. Current allocation to each process
- C. Remaining resource need of each process
- D. Available resources in the system
4. In a safe state, which condition must be true for all processes?
- A. Each process has less than its maximum demand
- B. Each process can be allocated its maximum demand
- C. There exists a safe sequence for all processes
- D. No process is in a waiting state
5. How is the safety of a state determined in the Banker's Algorithm?
- A. By simulating resource allocation and checking for deadlock
- B. By checking if all processes have their maximum demand
- C. By ensuring no process is in a waiting state
- D. By using semaphores for resource management
6. What does the Dining Philosopher’s Problem illustrate?
- A. Memory management issues
- B. Deadlock and synchronization issues
- C. Resource allocation strategies
- D. Process scheduling techniques
7. In the Dining Philosopher’s Problem, what do the philosophers represent?
- A. Processes
- B. Resources
- C. Threads
- D. Semaphores
8. Which strategy can prevent deadlock in the Dining Philosopher’s Problem?
- A. Allowing philosophers to pick up both forks simultaneously
- B. Making one philosopher pick up the right fork first
- C. Using a round-robin scheduling algorithm
- D. Increasing the number of forks
9. What is the condition for deadlock in the Dining Philosopher’s Problem?
- A. All philosophers are eating
- B. All philosophers are thinking
- C. All philosophers are waiting for a fork
- D. All philosophers have one fork
10. How can the circular wait condition be prevented in the Dining Philosopher’s Problem?
- A. By using a semaphore
- B. By allowing preemption
- C. By making one philosopher pick up the right fork first
- D. By using a monitor
11. What does the Producer-Consumer Problem illustrate?
- A. Deadlock prevention
- B. Process synchronization
- C. Memory management
- D. Disk scheduling
12. Which synchronization tool is commonly used in the Producer-Consumer Problem?
- A. Mutex
- B. Semaphore
- C. Monitor
- D. All of the above
13. In the Producer-Consumer Problem, what does the producer do?
- A. Consumes data from the buffer
- B. Generates data and puts it into the buffer
- C. Manages memory allocation
- D. Monitors buffer usage
14. What happens if the producer tries to add data to a full buffer?
- A. Data is lost
- B. Producer waits
- C. Buffer size increases
- D. Consumer is terminated
15. What is the role of the consumer in the Producer-Consumer Problem?
- A. Adds data to the buffer
- B. Removes data from the buffer
- C. Synchronizes producer actions
- D. Manages memory allocation
16. What is the main characteristic of the Round Robin scheduling algorithm?
- A. Non-preemptive
- B. Preemptive with fixed time slices
- C. Priority-based
- D. FIFO (First-In-First-Out)
17. How is the CPU time divided in the Round Robin scheduling algorithm?
- A. By process priority
- B. Equally among all processes
- C. Based on arrival time
- D. Using a fixed time quantum
18. What is the primary advantage of the Round Robin scheduling algorithm?
- A. Simple implementation
- B. Efficient memory usage
- C. Fairness in process execution
- D. Minimizes context switching
19. In Round Robin scheduling, what happens when a process's time quantum expires?
- A. The process is terminated
- B. The process is moved to the end of the ready queue
- C. The process's priority is increased
- D. The process continues execution
20. What is the typical value for the time quantum in Round Robin scheduling?
- A. A few milliseconds
- B. A few seconds
- C. Equal to the process burst time
- D. Equal to the process arrival time
21. What is the primary characteristic of the FCFS scheduling algorithm?
- A. Non-preemptive
- B. Preemptive
- C. Priority-based
- D. Round-robin
22. In FCFS scheduling, how are processes scheduled?
- A. Based on priority
- B. In the order they arrive
- C. Based on burst time
- D. Using a fixed time quantum
23. What is a potential drawback of the FCFS scheduling algorithm?
- A. Starvation of low-priority processes
- B. High overhead for context switching
- C. The convoy effect
- D. Unequal CPU allocation
24. How is the waiting time calculated in FCFS scheduling?
- A. By subtracting the burst time from the turnaround time
- B. By summing the burst times of all previous processes
- C. By dividing the burst time by the number of processes
- D. By adding the arrival time to the burst time
25. What is the turnaround time in FCFS scheduling?
- A. The time taken from process arrival to completion
- B. The time taken to switch context
- C. The time taken for a process to enter the ready queue
- D. The time taken for a process to be preempted
26. Which library is commonly used for thread management in C?
- A. `stdlib.h`
- B. `pthread.h`
- C. `unistd.h`
- D. `stdio.h`
27. What is the function used to create a new thread in POSIX threads?
- A. `pthread_create`
- B. `pthread_new`
- C. `pthread_spawn`
- D. `pthread_begin`
28. How is a thread terminated in POSIX threads?
- A. `pthread_stop`
- B. `pthread_exit`
- C. `pthread_end`
- D. `pthread_terminate`
29. What is the purpose of `pthread_join`?
- A. To create a new thread
- B. To wait for a thread to complete
- C. To terminate a thread
- D. To pause a thread
30. Which function retrieves the ID of the calling thread?
- A. `pthread_self`
- B. `pthread_id`
- C. `pthread_getid`
- D. `pthread_myid’
31. What is the primary purpose of paging in memory management?
- A. To allocate contiguous memory
- B. To allow non-contiguous memory allocation
- C. To increase disk space
- D. To manage CPU scheduling
32. How is the number of bits needed for the page number calculated?
- A. `log2(number_of_pages)`
- B. `log10(number_of_pages)`
- C. `sqrt(number_of_pages)`
- D. `number_of_pages / 2`
33. What does the page offset represent in paging?
- A. The frame number
- B. The displacement within the page
- C. The total number of pages
- D. The logical address
34. How is the logical address size calculated in a paging system?
- A. Sum of bits for page number and page offset
- B. Sum of bits for frame number and page offset
- C. Product of page size and number of pages
- D. Difference between logical and physical addresses
35. What is the purpose of the frame number in paging?
- A. To identify the process ID
- B. To locate the page in memory
- C. To manage CPU scheduling
- D. To calculate the logical address
36. What is the main principle behind the LRU page replacement algorithm?
- A. Replace the most frequently used page
- B. Replace the least recently used page
- C. Replace the page with the smallest size
- D. Replace the page with the highest priority
37. How does the LRU algorithm track page usage?
- A. Using a counter or stack
- B. Using a hash table
- C. Using a linked list
- D. Using a binary tree
38. What is a common data structure used to implement LRU?
- A. Stack
- B. Queue
- C. Linked list
- D. Tree
39. In LRU, what happens when a page is accessed?
- A. It is moved to the top of the stack
- B. It is moved to the bottom of the stack
- C. It is removed from the stack
- D. It is swapped with the least used page
40. What is the primary disadvantage of the LRU algorithm?
- A. High complexity for page replacement
- B. Requires additional memory for tracking usage
- C. High page fault rate
- D. Difficult to implement in hardware
41. What is the purpose of demand paging in memory management?
- A. To load entire processes into memory
- B. To load only necessary pages into memory
- C. To allocate contiguous memory blocks
- D. To manage CPU scheduling
42. How does demand paging improve system performance?
- A. By reducing swap time and physical memory usage
- B. By increasing the size of the page table
- C. By loading all pages of a process into memory
- D. By preempting running processes
43. What happens when a page not in memory is accessed in demand paging?
- A. A page fault occurs
- B. The process is terminated
- C. The page is swapped out
- D. The CPU is idle
44. In a column-major order, how are elements stored in memory?
- A. Row by row
- B. Column by column
- C. Diagonally
- D. Randomly
45. How does row-major order store elements in memory?
- A. Column by column
- B. Row by row
- C. Diagonally
- D. Randomly
46. What does a bit map represent in disk free-space management?
- A. Allocation of processes
- B. Free and allocated disk blocks
- C. CPU scheduling
- D. Memory segmentation
47. How is each disk block represented in a bit map?
- A. By an integer
- B. By a character
- C. By a single bit
- D. By a floating-point number
48. What does a bit value of 1 indicate in a bit map?
- A. The block is allocated
- B. The block is free
- C. The block is reserved
- D. The block is corrupted
49. How is the overhead of a bit map calculated?
- A. Number of disk blocks divided by 8
- B. Number of disk blocks multiplied by 8
- C. Number of disk blocks divided by 2
- D. Number of disk blocks multiplied by 2
50. What is an advantage of using a bit map for free-space management?
- A. Simplifies memory allocation
- B. Reduces memory fragmentation
- C. Efficient in finding free blocks
- D. Improves CPU scheduling
51. Which command is used to show the current working directory?
- A. `ls`
- B. `pwd`
- C. `cd`
- D. `dir`
52. What command would you use to change the current directory to the Desktop?
- A. `cd /Desktop`
- B. `cd ~/Desktop`
- C. `cd /home/Desktop`
- D. `cd /usr/Desktop`
53. How do you create a directory structure CS604/Files/CFiles?
- A. `mkdir -p CS604/Files/CFiles`
- B. `mkdir CS604/Files/CFiles`
- C. `mkdir -r CS604/Files/CFiles`
- D. `mkdir --recursive CS604/Files/CFiles`
54. Which command displays the contents of the Desktop directory?
- A. `ls /home/Desktop`
- B. `dir ~/Desktop`
- C. `ls ~/Desktop`
- D. `display ~/Desktop`
55. How can you remove a directory named CS604?
- A. `rmdir CS604`
- B. `rm -r CS604`
- C. `rm -rf CS604`
- D. `rm CS604’
56. Which command is used to compile a C program?
- A. `compile program.c`
- B. `gcc -o program program.c`
- C. `build program.c`
- D. `cc program.c`
57. What does the `-o` option in the `gcc` command specify?
- A. Optimization level
- B. Output file name
- C. Input file name
- D. Compilation mode
58. How do you execute a compiled program named `program`?
- A. `run program`
- B. `execute program`
- C. `./program`
- D. `program`
59. Which command is used to list files in the current directory?
- A. `dir`
- B. `ls`
- C. `show`
- D. `list`
60. How can you view the contents of a file named `[Link]`?
- A. `view [Link]`
- B. `open [Link]`
- C. `cat [Link]`
- D. `see [Link]`
Important Formulas for Operating System Topics
Banker's Algorithm for Deadlock Avoidance
Need Matrix Calculation:
Need[i][j] = Max[i][j] - Allocation[i][j]
Safety Check:
Available[j] >= Need[i][j]

Paging Parameters Calculation


Number of Bits for Page Number (p):
Bits for p = log2(number of pages)
Number of Bits for Frame Number (f):
Bits for f = log2(number of frames)
Number of Bits for Page Offset (d):
Bits for d = log2(page size)
Logical Address Size = Bits for p + Bits for d
Physical Address Size = Bits for f + Bits for d

Disk Free-Space Management with Bit Map


Bit Map Overhead Calculation:
Bit Map Overhead (in bytes) = [Total Number of Blocks / 8]

Thread Management
Thread Creation:
pthread_create(thread, attr, start_routine, arg)
Thread Termination:
pthread_exit(status)
Thread Joining:
pthread_join(thread, status)

Scheduling Algorithms
Waiting Time in FCFS:
Waiting Time = Turnaround Time - Burst Time
Turnaround Time:
Turnaround Time = Completion Time - Arrival Time
Round Robin Scheduling:
Waiting Time = Total Time in Queue - Burst Time

Least Recently Used (LRU) Page Replacement Algorithm


Tracking Usage:
Using a counter: Increment counter for each page access.
Using a stack: Move accessed page to the top.

Demand Paging
Page Fault Rate Calculation:
Page Fault Rate = Number of Page Faults / Total Number of Accesses

You might also like