Ask Computer Engineering Expert

Passenger_can:Make reservations for themselves;cancel reservations for themselves;view the(reserved/bought) ticket;buy tickets only for themselves.
Agents_can: Make Reservations for any passenger;Cancel reservation for any passenger; View all the seats;Buy tickets for any passenger

The important point is to preserve the consistency in passenger accounts during concurrent access to the seats via operations using suitable synchronization primitives.

implement such a plane ticket agency simulation performed during a period, using Pthreads library primitives. Each passenger and agent of the system should be implemented as a separate thread. At the end of the simulation, the initial thread prints out the summary of the simulation as described in the Details section.

DETAILS
o You should implement each passenger and agent as a separate thread. The initial main thread is responsible for creating passenger/agent threads, managing them, and displaying the final results as soon as the simulation completes.

o Note that, shared resources among multiple passengers/agents (i.e. threads) are plane seats, and preserving consistency and preventing deadlocks are major issues.

o We suggest you to pick the number of operations and operation types to be performed by each passenger/agent in random manner in your simulation.

o The total simulation time is D days. All the transactions within that period will be logged in a file.

o There are P passengers, A agents, and N planes with unique IDs used by the ticket system. Seats in a single plane also have unique IDs 1 to M.

o Number of simulation days, passengers, agents, and planes would be taken from the input file. Input file format is described below.

o Assume that, in your implementation 20 seconds correspond to one simulation day. o All agents know the IDs of all the passengers. These agents can perform any operation for any passengers.

o A passenger can perform an operation only for himself.

o The plane service has a limitation for the tickets that can be bought during a day for each passenger. In total, a passenger cannot buy more than the given limit for her/him during a day. However, there is no such limit for reservation.

o If a reserved ticket is not bought within 2 days, reservation is cancelled automatically. o Each passenger can have at most 10 tickets bought (reserved ones are not counted) for
each plane throughout the simulation.

o In your implementation of buy/reserve (multiple) tickets operations, make sure that a solution for deadlock prevention is taken into account. Note that you should not use a semaphore/lock for the whole plane just to reserve/buy/cancel a ticket for a single/multiple passenger. You should use synchronization primitives such that "independent operations" are performed concurrently.

o Multiple simultaneous view operations (i.e. reads) on an account should be allowed in your synchronization solution. However the other operations, buy, reserve, cancel (i.e. updates) should be performed in a mutually exclusive way.

o When the simulation is finished for the given number of days, the following should be available in a log file:

o For each transaction, there should be a line of information in the log file in the following format:

P_ID N_ID S_ID O_ID Operation Simulation_Day

o Number of transactions performed by each passenger and agent at each day o Total number of transactions of each passenger and agent. 

o Number of empty seats at each plane.

ex Input File Format:

Below first line: 

first digit(4) :Number of passengers 
second digit(6): Number of agents
third digit(6): Number of simulation days 
fourth digit (2):Number of Planes
fifth, last digit(30): Number of seats in a plane
---------------------------------------
4,6,6,2,30 

1* 5**
2 4 
3 4 
4 3 
5 6

*First digit(1) is P_ID 
**Second digit(5) is DayLimit

P_ID : Passenger ID
N_ID : Plane ID
S_ID : Seat ID
O_ID : ID of the person that performed the operation

DayLimit: Maximum number of tickets that can be bought for a single plane during a day. If DayLimit of a customer is not specified for a passenger, default value is 4.

any help will be appreciated, just telling me the logic behind it, the logic flow, how to prevent deadlock, if two agents wanna reserve the same place at the same time? 

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M993256

Have any Question?


Related Questions in Computer Engineering

Does bmw have a guided missile corporate culture and

Does BMW have a guided missile corporate culture, and incubator corporate culture, a family corporate culture, or an Eiffel tower corporate culture?

Rebecca borrows 10000 at 18 compounded annually she pays

Rebecca borrows $10,000 at 18% compounded annually. She pays off the loan over a 5-year period with annual payments, starting at year 1. Each successive payment is $700 greater than the previous payment. (a) How much was ...

Jeff decides to start saving some money from this upcoming

Jeff decides to start saving some money from this upcoming month onwards. He decides to save only $500 at first, but each month he will increase the amount invested by $100. He will do it for 60 months (including the fir ...

Suppose you make 30 annual investments in a fund that pays

Suppose you make 30 annual investments in a fund that pays 6% compounded annually. If your first deposit is $7,500 and each successive deposit is 6% greater than the preceding deposit, how much will be in the fund immedi ...

Question -under what circumstances is it ethical if ever to

Question :- Under what circumstances is it ethical, if ever, to use consumer information in marketing research? Explain why you consider it ethical or unethical.

What are the differences between four types of economics

What are the differences between four types of economics evaluations and their differences with other two (budget impact analysis (BIA) and cost of illness (COI) studies)?

What type of economic system does norway have explain some

What type of economic system does Norway have? Explain some of the benefits of this system to the country and some of the drawbacks,

Among the who imf and wto which of these governmental

Among the WHO, IMF, and WTO, which of these governmental institutions do you feel has most profoundly shaped healthcare outcomes in low-income countries and why? Please support your reasons with examples and research/doc ...

A real estate developer will build two different types of

A real estate developer will build two different types of apartments in a residential area: one- bedroom apartments and two-bedroom apartments. In addition, the developer will build either a swimming pool or a tennis cou ...

Question what some of the reasons that evolutionary models

Question : What some of the reasons that evolutionary models are considered by many to be the best approach to software development. The response must be typed, single spaced, must be in times new roman font (size 12) an ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As