Unit5 - Subjective Questions

CSE325 • Practice Questions with Detailed Answers

1

Explain the fundamental differences between a Process and a Thread in the context of Operating Systems.

2

Describe the syntax and parameters of the pthread_create function in the POSIX thread library.

3

What is a Race Condition? Explain with a conceptual example involving a shared variable.

4

Define the Critical Section Problem. What are the three conditions that a solution to the critical section problem must satisfy?

5

What is a Mutex Lock? Explain the functions used to initialize, lock, and unlock a mutex in Pthreads.

6

Explain the role of pthread_join and pthread_exit. Why is pthread_join necessary in the main thread?

7

Differentiate between Binary Semaphores and Counting Semaphores.

8

Describe the Producer-Consumer Problem and outline how Semaphores can be used to solve it.

9

What are the standard POSIX semaphore operations? Explain the difference between sem_wait and sem_post.

10

Compare Mutex Locks and Semaphores. When would you choose one over the other?

11

What is a Deadlock in the context of multithreading using Mutexes? Provide a scenario using two mutexes.

12

How can arguments be passed to a thread function in POSIX? Give a code snippet example.

13

Explain the concept of Thread Attributes and specifically the distinction between Joinable and Detached threads.

14

What does pthread_self() return, and how is it useful in a multithreaded program?

15

Derive a solution for the Readers-Writers Problem (First variation: Readers preference) using Semaphores.

16

Explain the purpose of pthread_mutex_trylock. How does it differ from standard pthread_mutex_lock?

17

What is the Dining Philosophers Problem? Briefly describe the synchronization challenge it represents.

18

In the context of synchronization, what is a Spinlock? How does it differ from a Mutex?

19

Write a C code snippet using Mutex to safely increment a global counter variable accessed by multiple threads.

20

What are condition variables in Pthreads, and why are they usually used in conjunction with a mutex?