Question: Write a multithreaded C program to simulate the Networked Servers Problem, a synchronization problem where servers are trying to access shared network resources. The goal
Write a multithreaded C program to simulate the Networked Servers Problem, a
synchronization problem where servers are trying to access shared network resources. The
goal is to ensure mutual exclusion and prevent resource starvation using Semaphores.
Design:
There are servers in a data center, each trying to perform data processing tasks that
require access to two network channels left and right
Each network channel is shared by adjacent servers. The last network channel is
shared by the last server and the first server.
A server can only process data when it has access to both its left and right network
channels.
Each network channel can only be used by one server at a time.
Each server takes second to do data processing. You can use sleep for this
The challenge is to design a solution where:
Mutual exclusion is maintained no two servers can access the same network
channel simultaneously
Starvation is prevented every server should get a chance to access the network
channels
Use Semaphores to represent the network channels and ensure proper synchronization among
the servers.
Input:
None
Output:
Each server should print messages indicating when they are waiting attempting
to acquire network channels and processing after acquiring both channels
The program should terminate after each server has processed data times.
Example:
Server is processing
Server is waiting
Server is waiting
Server is processing
Server is waiting
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
