Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program in Linux using C to simulate selling the tickets for a flight from Chicago to Los Angeles. Operate three ticket agents in

Write a program in Linux using C to simulate selling the tickets for a flight from Chicago to Los Angeles. Operate three ticket agents in parallel (use fork or threads as needed) who would sell main cabin seats (153), extra legroom seats (18) and first class (16) seats. Do not replicate agent code three times. Declare agent as a function and call it passing agent number as a parameter. A customer request would be generated randomly (with proper seeding of random function) for the three options for each agent. Each agent should reduce the number of appropriate seats by 1 after a random delay simulating interactions with the customer. Each agent should keep track of the number of tickets sold. Once the tickets are sold out, each agent should report total seats sold in each class. The total number of seats must add up to 187.

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

Introduction To Constraint Databases

Authors: Peter Revesz

1st Edition

1441931554, 978-1441931559

More Books

Students also viewed these Databases questions