Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You are invited to implement using system callsfork() and pipe() a client-server program that will simulate the operation of an electronic ticket reservation system for

You are invited to implement using system callsfork() and pipe() a client-server program that will simulate the operation of an electronic ticket reservation system for one cinema.
 

The ticket reservation system (server) will maintain a list of available screenings of works for which there will be a limited number of seats available. For each available project the information that will be maintained will be a unique code for each project (a serial number), the start time, the end time, the number of seats available and the cost of the ticket.

Clients will submit a request to book one or more tickets for one or more projects, and if there are seats available for the requested projects, then the system will inform the client of the successful booking as well as the cost of the ticket and reserves a position in the requested project. Otherwise, it will inform the customer about the unsuccessful completion of the reservation. The system will have a specific booking processing time (even 0.5 seconds). During this time, it will not accept any more requests until it finishes serving.
 
Once all ticket reservation requests have been served, the reservation system will generate a summary report detailing for each project the following information:
1) Projects (start time, end time)
2) Number of reservation requests
3) Number of requests for which the reservation was successful
4) Number of requests for which booking was unsuccessful
At the end of the report a summary message will be printed which will contain:
1) The total number of ticket reservation requests
2) The total number of successful bookings
3) The total profits of the cinema
Implementation Instructions:
You will implement the list of available projects through a table (eg movies) which will exist in the parent process (server). The table will have a size of e.g. 10 different projects. Each project will be a structure (struct) which will contain the following fields: movie_id, start, end, available_seats, price.
 
For each project set the variable available_seats to a random value from 1 to 5. The parent process should initialize the movies array and also create the necessary pipes to communicate with clients with the pipe() command.
Through pipelines, it will be able to accept ticket reservation requests from clients (for a reservation request, clients will write to the pipeline, and the server will read from the pipeline).

In order to inform the clients about the progress of the reservation, you should create another pipeline for each client, in which the server will write (write) and from which the client will read (read) the message that will describe the result of the reservation (ie whether the reservation was successful and what the cost of the project is). In total, you will need 2 pipelines for each client.
For clients, your program should create (via the fork() system call) a number of child processes that will have the role of clients. Clients will communicate with the ticket booking system via anonymous pipes (pipe system call).

To test the program, you will create 10 different clients through successive fork() calls in a loop. For each reservation request, the rand() function will be executed, generating a random number between 1 and 3 (to determine the number of tickets), as well as a random number between 0 and 9 (10 available projects) for the defining the project for which the client requests the ticket reservation.

For example, a client may request the reservation of 2 tickets for a specific project, or the reservation of 2 tickets for two different projects. As soon as each client chooses the project or projects they wish to reserve, they will write to the pipeline the number of requested tickets as well as the unique code (id) of the project or projects they wish to reserve and will await the result of his request.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

PostgreSQL 10 High Performance Expert Techniques For Query Optimization High Availability And Efficient Database Maintenance

Authors: Ibrar Ahmed ,Gregory Smith ,Enrico Pirozzi

3rd Edition

1788474481, 978-1788474481

More Books

Students also viewed these Databases questions

Question

Name is needed for identifying organisms ?

Answered: 1 week ago

Question

Q.1. Taxonomic classification of peafowl, Tiger and cow ?

Answered: 1 week ago