Question

Objective: Create programs that are run independently and can use simple IPC using FIFOs/named pipes to...

Objective: Create programs that are run independently and can use simple IPC using FIFOs/named pipes to pass information back and forth in a client/server fashion. The information/request from the client will look like simple semaphore system calls and will include information for the server to be able to identify which client requested it and what request it is and its associated parameters.

This assignment requires the analysis, implementation, testing and documentation of two C program that use C on the Linux server sapphire or your own Linux box or virtual machine. A server program and a client program that will be run concurrently.

Server program:

The server program will implement ONE semaphore that multiple clients can issue request to lock and unlock.

Server program will be an iterative server which can receive requests from multiple clients, although it process the requests in a serial fashion, one at a time, i.e., request from client one, request from client three, request from client two etc. So,

  • Server will need to create a well-known FIFOs where it will read its inputs from the clients and open it in READ mode (will block of course until a client opens the fifo in write mode). After the first client connects, the server should also open the well known fifo in write mode, to prevent the server from quitting when there are no clients connected.
  • Server will then go into a loop to read from the pipe to receive requests from clients that will consist of the following types of request:
    1. Requests from a new clients asking to “connect” to the server, this requests should include the client ID/number and the name of that client-specific FIFO (used by the client to receive replies from the server). Server should open that FIFO in WRITE mode, save the file descriptor and the client ID/number into a CONNECTED CLIENTS table for use when replies need to be sent to THAT client.

  1. 1-System call-like Request from a connected client requesting to “lock the semaphore” – a wait request. If the semaphore is free (unlocked) a reply should be sent immediately to the client indicating the semaphore has been locked the reply would allow the client to continue. If the semaphore is not free (locked by another client), the request (client) should be put in a wait queue and NO reply should be sent to the client (which will effectively block the client from continuing at this point.

  1. 2-System call-like Request from a connected client requesting to “unlock the semaphore” – a signal request. At this point, if no other client is waiting for the semaphore, the semaphore should be unlocked and a simple ack reply should be sent to the client. If at least one client is waiting for the semaphore, in addition to the ack sent to the client doing the signal request, one of the clients waiting for the semaphore should be removed from the wait queue and a reply should be sent to THAT client indicating that it now owns the semaphore and effectively unblocking it and allowing it to continue.
  2. Client request to disconnect from the server. In this case, the server should reply with an OK message to that client and then close THAT client’s fifo and remove the client’s entry from the CONNECTED CLIENTS table.

  1. There should be a “special request-STOP” that can be sent by a client to indicate to the server that it should close all fifos and terminate (this is not normally part of a standard server code which should run indefinitely, but will give you a way to gracefully shutdown the server. This should ONLY be processed if the client requesting it is the last connected client.

After each of these five types of requests, the server should print to the screen enough information to show which client is requesting and what the request was (client ID/number, type of requests, and associates parameters if any). It should also print the reply being sent.

Client Program:

The client program will “connect” to the server through the well-known FIFO and send requests through it to the server, more specifically, the client program should:

  • Acquire from the user (through the command line or reading from the keyboard) what the client number this instance of the program will be (i.e., client 1, client 2, etc.)
  • Open the well-known server’s fifo in write mode to communicate with the server (which will unblock the server from its fifo open call)
  • Create the client-specific FIFO using an appropriate name (e.g., ClientNfifo, where N is the client number) and send the initial “connect request” to the server including Client number AND name of the client-specific FIFO.
  • Open the client-specific FIFO in READ mode to be able to read replies from the server. This will block the client until the server opens the fifo in write mode.
  • After this, the client should go into a loop that will run for a predetermined number of times (say 30-50 times) after the loops (described below) is run the client will ask the user what to do next? providing three choices:
    • 1 – Run the loop again

  • 2 – EXIT - indicates THIS client does not want to issue more requests to the server, it should close its pipes and exit.

  • 3 – STOP - indicates THIS client does not want to issue more requests to the server, and it should also send a STOP request to the server (so that it can gracefully terminate) before closing its pipes and exiting. No more clients can connect to the server after this.

Description of the loop:

The body of the loop will consist of:

{

          // NON – CRITICAL SECTION

An inner loop that will also run 20-30 times where the client will continually print a message (maybe every second or so) to the screen indicating that it is processing in its NON-CRITICAL SECTION

After the NON-CRITICAL SECTION LOOP the client should print a message:

          WAITING TO GET INTO THE CRITICAL SECTION

          *Send a wait request to the server (locking the semaphore) and wait for a reply

          // CRITICAL SECTION

An inner loop that will also run 20-30 times where the client will continually print a message (maybe every second or so) to the screen indicating that it is processing in its CRITICAL SECTION

          After the CRITICAL SECTION LOOP the client should print a message:

          LEAVING THE CRITICAL SECTION

          *Send a signal request to the server (freeing the semaphore) and wait for a reply

}

** You should implement a Wait and Signal function that are called from inside the loop when appropriate. The Wait function should send a wait request to the server and expect a reply before returning. The Signal function should send a signal request to the server and expect a reply before returning.

0 0
Add a comment Improve this question Transcribed image text
Know the answer?
Add Answer to:
Objective: Create programs that are run independently and can use simple IPC using FIFOs/named pipes to...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Here is the description of the client and server programs that you need to develop in C using TCP: Suppose we have a simple student query system, where the server keeps student's info in an array...

    Here is the description of the client and server programs that you need to develop in C using TCP: Suppose we have a simple student query system, where the server keeps student's info in an array of struct student_info ( char abc123171 char name [101 double GPA; To simplify the tasks, the server should create a static array of 10 students with random abc123, name, and GPA in the server program. Then the server waits for clients. When a client...

  • Write two C programs that run a server program and a client program concurrently. Server program:...

    Write two C programs that run a server program and a client program concurrently. Server program: The server program provides a simple search for a specific value in an array sent to it from a client. If the value appears in the array, the server indicates the index of the first occurrence of that value in the array. The server sends the client search value and its array position. If the value does not occur in the array, only the...

  • Using python 3 to create the UDP Ping Clien and server. Using UDP sockets, you will...

    Using python 3 to create the UDP Ping Clien and server. Using UDP sockets, you will write a client and server program that enables the client to determine the round-trip time (RTT) to the server. To determine the RTT delay, the client records the time on sending a ping request to the server, and then records the time on receiving a ping response from the server. The difference in the two times is the RTT. The ping message contains 2...

  • Assignment One program will be the update server and the other will be the update client....

    Assignment One program will be the update server and the other will be the update client. Here is how the two programs should interact with each other: Server 1. the server starts up and reads the version number in the data.bin file and stores it in memory. 2. The server binds to a port and awaits connections. Client 1. The client starts up and it will first read the version number found within it's own data.bin file. 2. The client...

  • I need help with this assignment, please; Programming Assignment 3: UDP Pinger Lab In this lab,...

    I need help with this assignment, please; Programming Assignment 3: UDP Pinger Lab In this lab, you will study a simple Internet ping server written in the Java language, and implement a corresponding client. The functionality provided by these programs is similar to the standard ping programs available in modern operating systems, except that they use UDP rather than Internet Control Message Protocol (ICMP) to communicate with each other. (Java does not provide a straightforward means to interact with ICMP.)...

  • In Python, make changes in the client code, so that the client allows the user to...

    In Python, make changes in the client code, so that the client allows the user to continue to send multiple requests until the user types in “Quit”. This means that the client process should not exit after the user sends one request and receives one response. Instead, the client process should be able to receive subsequent inputs from the user. You need to have a loop in the client code, so that it can accept the user request until the...

  • Project Description In this project, you will be developing a multithreaded Web server and a simple...

    Project Description In this project, you will be developing a multithreaded Web server and a simple web client. The Web server and Web client communicate using a text-based protocol called HTTP (Hypertext Transfer Protocol). Requirements for the Web server The server is able to handle multiple requests concurrently. This means the implementation is multithreaded. In the main thread, the server listens to a specified port, e.g., 8080. Upon receiving an HTTP request, the server sets up a TCP connection to...

  • Write two programs Client and Server

    Given two integer matrices A and B, you are requested to compose a program to perform matrix addition (A + B). Both matrices have N rows and M columns; N > 1, M > 1; You need to divide both (A and B) into four equal (or close to equal) size of submatrices (A0,0, A0,1, A1,0, A1,1 and B0,0, B0,1, B1.0, B1.1)andeachsubmatrixhasdimensioncloseto(N/2)x(M/2). YouneedtocreatefourJavathreads each thread performs a subset of addition on one pair of the submatrices. Example, thread 0 performs addition...

  • The Diffie-Hellman public-key encryption algorithm is an alternative key exchange algorithm that is used by protocols...

    The Diffie-Hellman public-key encryption algorithm is an alternative key exchange algorithm that is used by protocols such as IPSec for communicating parties to agree on a shared key. The DH algorithm makes use of a large prime number p and another large number, g that is less than p. Both p and g are made public (so that an attacker would know them). In DH, Alice and Bob each independently choose secret keys, ?? and ??, respectively. Alice then computes...

  • ) Using Linux or Unix command line interpreter, compile and run the programs in Figure 3.8,...

    ) Using Linux or Unix command line interpreter, compile and run the programs in Figure 3.8, Figure 3.30. DO NOT compile and ron these programs on Windows Write the 3.16, Figare 317 and Figure 3 programs in Notepadt+, for example, then compile and run them at the command pr apt. Provide screenshots of your programs compilation, execution, and the results. 144 6 7 8 9 ry-maps a shared-memory object of the ws writing to the object. The flag shared-memory object...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT