Operating System

106503
Back to Operating System

Module 3: Inter-process Communication

  1. Q1b. Under direct communication, each process that wants to communicate must explicitly name the recipient or sender of the communication. This mechanism is known as ______ (i) Naming (ii) Message Passing (iii) Mailboxes (iv) Chatting20242m

    Module 3: Inter-process Communication

    Under direct communication, each process that wants to communicate must explicitly name the recipient or sender of the communication. This mechanism is known as ______
    (i) Naming
    (ii) Message Passing
    (iii) Mailboxes
    (iv) Chatting

    View this question on its own page →
    Worked Solution

    Answer: (i) Naming (Direct Naming / Direct Communication)

    In IPC, direct communication requires sender/receiver to explicitly name each other (send(P,message), receive(Q,message)). This is called naming / direct addressing. Indirect uses mailboxes/ports. Message Passing is the overall category, Naming is the specific mechanism for direct.

  2. Q1e. Which of the following mechanisms is NOT typically used to achieve mutual exclusion? (i) Strict alternation (ii) Event counters (iii) Message passing (iv) Virtual memory20242m

    Module 3: Inter-process Communication

    Which of the following mechanisms is NOT typically used to achieve mutual exclusion?
    (i) Strict alternation
    (ii) Event counters
    (iii) Message passing
    (iv) Virtual memory

    View this question on its own page →
    Worked Solution

    Answer: (iv) Virtual memory

    Mutual exclusion solutions: busy-wait (Peterson, strict alternation), hardware (TSL, swap), semaphores, monitors, message passing, event counters. Virtual memory is memory management, not synchronization.

  3. Q1e. The Dining Philosopher Algorithm is a classic example of which problem? (i) CPU scheduling (ii) Memory fragmentation (iii) Process synchronization and deadlock (iv) File allocation20252m

    Module 3: Inter-process Communication

    The Dining Philosopher Algorithm is a classic example of which problem?

    (i) CPU scheduling
    (ii) Memory fragmentation
    (iii) Process synchronization and deadlock
    (iv) File allocation

    View this question on its own page →
    Worked Solution

    Answer: (iii) Process synchronization and deadlock

    Dining philosophers share forks (resources); illustrates synchronization, deadlock, starvation. Classic IPC problem solved by semaphores/monitors.

  4. Q1f. To avoid race condition the maximum number of processes that may simultaneously be inside the critical section is: (i) No Limit (ii) Two (iii) Three (iv) One20232m

    Module 3: Inter-process Communication

    To avoid race condition the maximum number of processes that may simultaneously be inside the critical section is:
    (i) No Limit
    (ii) Two
    (iii) Three
    (iv) One

    View this question on its own page →
    Worked Solution

    Answer: (iv) One

    Critical section property: at most one process may execute inside CS at any time to ensure mutual exclusion and avoid race condition.

  5. Q1h. What is the main problem that the "Critical Section" concept aims to solve in concurrent programming? (i) Memory overflow (ii) Infinite loop termination (iii) Race condition between processes (iv) Lack of CPU resources20242m

    Module 3: Inter-process Communication

    What is the main problem that the "Critical Section" concept aims to solve in concurrent programming?
    (i) Memory overflow
    (ii) Infinite loop termination
    (iii) Race condition between processes
    (iv) Lack of CPU resources

    View this question on its own page →
    Worked Solution

    Answer: (iii) Race condition between processes

    Critical section is code segment accessing shared data. Mutual exclusion ensures only one process executes CS at a time to prevent race where outcome depends on timing.

  6. Q1j. In Peterson's solution for two processes, which condition ensures mutual exclusion? (i) Both processes wait infinitely (ii) Only one process enters the critical section at a time (iii) Both processes enter the critical section together (iv) The process with a higher ID always wins20242m

    Module 3: Inter-process Communication

    In Peterson's solution for two processes, which condition ensures mutual exclusion?
    (i) Both processes wait infinitely
    (ii) Only one process enters the critical section at a time
    (iii) Both processes enter the critical section together
    (iv) The process with a higher ID always wins

    View this question on its own page →
    Worked Solution

    Answer: (ii) Only one process enters the critical section at a time

    Peterson's flags+turn ensures mutual exclusion, progress, bounded waiting for 2 processes without hardware support.

  7. Q4. What do you understand by race condition? Give few example of arising of race condition in concurrent processing.201914m

    Module 3: Inter-process Communication

    What do you understand by race condition?

    Give few example of arising of race condition in concurrent processing.

    View this question on its own page →
    Worked Solution

    Race Condition

    Occurs when multiple processes/threads access shared data concurrently and outcome depends on order of execution.
    Example: shared counter x=5, P1: x=x+1, P2: x=x-1 interleaved without sync can give wrong result. Other examples: lost update in database, inconsistent file write, printer spooler with two producers updating buffer indices.
    Requires mutual exclusion, atomic operations.

  8. Q4a. What do you understand by critical section problem. Discuss the requirements that a solution to the critical section problem must satisfy.20227m

    Module 3: Inter-process Communication

    What do you understand by critical section problem. Discuss the requirements that a solution to the critical section problem must satisfy.

    View this question on its own page →
    Worked Solution

    Critical Section Problem

    Code segment where shared resources accessed. Requirements: 1) Mutual Exclusion (only one in CS), 2) Progress (decision in finite time if no one in CS), 3) Bounded Waiting (limit on waiting). Solutions: software (Peterson), hardware (TSL, swap), semaphores, monitors.

  9. Q5. (a) Define semaphore. Give a scheme for implementation of semaphore primitives. (b) What do you mean by critical section problem? What is the solution to the critical section problem?201914m

    Module 3: Inter-process Communication

    (a) Define semaphore. Give a scheme for implementation of semaphore primitives.

    (b) What do you mean by critical section problem? What is the solution to the critical section problem?

    View this question on its own page →
    Worked Solution

    (a) Semaphore & Primitives

    Integer variable with atomic wait(S)/signal(V). Binary (0/1) vs counting. wait: while s≤0 wait, s-- ; signal: s++ and wake. Implementation via blocking queue, disable interrupts for atomicity.

    (b) Critical Section

    Segment accessing shared data. Requirements as before; solutions: mutex, semaphore (wait before CS, signal after), monitors.

  10. Q6a. What is Semaphore? Explain with algorithm the Dining-Philosophers Solution using Monitors.20247m

    Module 3: Inter-process Communication

    What is Semaphore? Explain with algorithm the Dining-Philosophers Solution using Monitors.

    View this question on its own page →
    Worked Solution

    Semaphore

    Integer sync variable. Dining Philosophers with Monitor: monitor with 5 condition vars, state[] = thinking/hungry/eating, test(i) checks neighbors not eating, pickup puts hungry then test, putdown sets thinking then tests neighbors. Monitor ensures mutex, prevents deadlock/starvation vs semaphore solution with deadlock risk.

  11. Budget App•POCKETLY

    Pocketly on Android

    Log daily food, travel, and hostel expenses instantly. Set monthly spending limits and see where your money goes without complex spreadsheets.

    Install Pocketly
  12. Q7a. State producer-consumer problem. Give a solution to this problem using semaphore. Justify that your solution guarantees mutual exclusion.20236m

    Module 3: Inter-process Communication

    State producer-consumer problem. Give a solution to this problem using semaphore. Justify that your solution guarantees mutual exclusion.

    View this question on its own page →
    Worked Solution

    Producer-Consumer with Semaphore

    Shared buffer size N, sem empty=N, full=0, mutex=1.
    Producer: wait(empty), wait(mutex), produce to buffer, signal(mutex), signal(full)
    Consumer: wait(full), wait(mutex), consume, signal(mutex), signal(empty)
    Guarantees mutual exclusion via mutex, and counting sems prevent overflow/underflow, bounded waiting.

  13. Q7a. Explain the Producer-Consumer problem and discuss how semaphores can be used to solve it.20257m

    Module 3: Inter-process Communication

    Explain the Producer-Consumer problem and discuss how semaphores can be used to solve it.

    View this question on its own page →
    Worked Solution

    Producer-Consumer

    As Q23: bounded buffer problem, solution with semaphores empty/full/mutex as above.

  14. Q7b. Discuss critical section problem. Illustrate the classic software-based solution to this problem known as Peterson's solution.20238m

    Module 3: Inter-process Communication

    Discuss critical section problem. Illustrate the classic software-based solution to this problem known as Peterson's solution.

    View this question on its own page →
    Worked Solution

    Critical Section & Peterson

    Critical section needs mutual exclusion, progress, bounded waiting. Peterson for 2 processes: shared flag[2], turn. Pi: flag[i]=true; turn=j; while(flag[j] && turn==j) wait; CS; flag[i]=false; remainder. Proves mutual exclusion.

  15. Q8b. Write an algorithm for Readers-Writers Problem solution using Semaphores.20257m

    Module 3: Inter-process Communication

    Write an algorithm for Readers-Writers Problem solution using Semaphores.

    View this question on its own page →
    Worked Solution

    Readers-Writers with Semaphores

    shared int readcount=0; sem mutex=1, wrt=1;
    Reader: wait(mutex); readcount++; if(readcount==1) wait(wrt); signal(mutex); read; wait(mutex); readcount--; if(readcount==0) signal(wrt); signal(mutex);
    Writer: wait(wrt); write; signal(wrt);
    Readers preference variant, writer may starve; for writer preference add extra sem.

  16. Q9d. Write short notes on: Peterson's solution20227m

    Module 3: Inter-process Communication

    Write short notes on: Peterson's solution

    View this question on its own page →
    Worked Solution

    Peterson's Solution

    Software mutual exclusion for 2 processes using flag[] and turn, guarantees mutex, progress, bounded waiting without hardware.