Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
19 views3 pages

Unit2Concurrent Processes

The document discusses the concept of processes in computing, including their states and the role of the Process Control Block (PCB). It covers principles of concurrency, challenges, and solutions for problems like the Producer/Consumer and Mutual Exclusion. Additionally, it introduces synchronization mechanisms such as semaphores and classical concurrency problems, along with inter-process communication models.

Uploaded by

userdumb709
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)
19 views3 pages

Unit2Concurrent Processes

The document discusses the concept of processes in computing, including their states and the role of the Process Control Block (PCB). It covers principles of concurrency, challenges, and solutions for problems like the Producer/Consumer and Mutual Exclusion. Additionally, it introduces synchronization mechanisms such as semaphores and classical concurrency problems, along with inter-process communication models.

Uploaded by

userdumb709
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
You are on page 1/ 3

Concurrent Processes

Process Concept

• Process: A program in execution; includes the program code, current activity, and a process
control block (PCB).

• Process State: Represented by new, ready, running, waiting, and terminated states.

• Process Control Block (PCB): Contains process information like process state, program
counter, CPU registers, memory limits, etc.

Principle of Concurrency

• Concurrency: Execution of multiple processes simultaneously, which may or may not be


performing different tasks.

• Advantages: Improved resource utilization, better system performance, responsiveness, and


structure.

• Challenges: Coordination, synchronization, deadlocks, and race conditions.

Producer/Consumer Problem

• Producer: Generates data and places it in a buffer.

• Consumer: Takes data from the buffer for processing.

• Problem: Ensure producers do not produce when the buffer is full, and consumers do not
consume when the buffer is empty.

• Solution: Use synchronization mechanisms like semaphores or mutexes to manage access to


the buffer.

Mutual Exclusion and Critical Section Problem

• Mutual Exclusion: Ensures that multiple processes do not access a shared resource
simultaneously.

• Critical Section: Part of the code where shared resources are accessed.

• Critical Section Problem: Ensures mutual exclusion, progress, and bounded waiting.

o Mutual Exclusion: Only one process can be in the critical section.

o Progress: Only processes not in the remainder section can decide which process will
enter the critical section next.

o Bounded Waiting: Limit the number of times other processes can enter their critical
sections before a waiting process can enter.

Dekker’s Solution

• Dekker's Algorithm: One of the first algorithms to solve the mutual exclusion problem.

• Mechanism: Uses flags and turn variable to control access to the critical section.

• Drawback: Complexity and difficulty in proving correctness.


Peterson’s Solution

• Peterson’s Algorithm: Simplified algorithm for mutual exclusion.

• Mechanism: Uses two flags and a turn variable to ensure mutual exclusion.

• Steps:

1. Raise a flag indicating the desire to enter the critical section.

2. Set the turn to the other process.

3. Wait until the other process is not interested or it’s the process's turn.

Semaphores

• Semaphore: A synchronization primitive that can be used to control access to a common


resource by multiple processes.

• Types:

o Binary Semaphore: Also known as a mutex, has only two states: locked and
unlocked.

o Counting Semaphore: Can have a range of values and is used to control access to a
resource pool.

• Operations:

o wait (P): Decrements the semaphore value.

o signal (V): Increments the semaphore value.

Test and Set Operation

• Test-and-Set: An atomic instruction used to write to a memory location and return its old
value as a single atomic operation.

• Usage: Often used to implement locks and mutual exclusion.

Classical Problems in Concurrency

1. Dining Philosopher Problem

o Problem: Philosophers alternately think and eat. They need two forks to eat but only
one fork is placed between each pair of philosophers.

o Solution: Use semaphores or monitors to prevent deadlock and ensure all


philosophers get a chance to eat.

2. Sleeping Barber Problem

o Problem: A barber shop with one barber, one barber chair, and multiple waiting
room chairs. The barber sleeps if no customers are present and serves customers in
the order of their arrival.

o Solution: Use semaphores to manage the barber's sleep and wake states and to
ensure customers are served in order.
Inter-Process Communication (IPC) Models and Schemes

• Shared Memory: Processes communicate by accessing shared memory space.

• Message Passing: Processes communicate by sending and receiving messages.

• Pipes: Unidirectional communication channels between processes.

• Sockets: Endpoint for communication between processes over a network.

Process Generation

• Process Creation: Parent processes create child processes through system calls like fork() in
Unix.

• Process Termination: Processes terminate using system calls like exit(), which releases
resources and notifies the parent process.

You might also like