Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

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

Q1 the market for apples is perfectly competitive say a

Q1. The market for apples is perfectly competitive. Say a typical firm has a marginal cost function of MC(q) = 2q. (1) The optimal quantity of apples to produce is 10 for the typical firm. How much revenue does the firm ...

Question suppose that we have a programming language with

Question : Suppose that we have a programming language with only 3 token kinds, UNSIGNED INTEGER, FLOAT and IDENTIFIER. Describe how to build a lexical analyzer for this language (lexical rules, FA, a program to simulate ...

Question sql uses relational and logical operators in the

Question SQL uses relational and logical operators in the WHERE clause to restrict the rows returned in a query. What are these operators and what datatypes can they work with?

There are sorted sequences l1 and l2 with 5 and 4 elements

There are sorted sequences L1 and L2, with 5 and 4 elements respectively. a) How many comparisons will it take to merge L1 and L2 in the best case? How many for worst case? Explain your answers. b)Let [54, 26, 93, 17, 77 ...

Analyze the time complexity of the following ternary search

Analyze the time complexity of the following ternary search algorithm: identify two points that subdivide a sorted array into three parts. If the given number is equal to one of these two points, we are done. Otherwise, ...

Introduction to software developmentmenu-driven

Introduction to Software Development Menu-Driven Programs TASKS: Language translator. Design a program that display the following menu: Select a language and I will say Good Morning English Italian Spanish German End the ...

For this assignment you are required to work on different

For this assignment, you are required to work on different aspects of the project described below for the next five weeks. Imagine you have to work on a project for building a corporate website for a company named Offex ...

We live in kapurkua a small island in the mediterranean

We live in Kapurkua, a small island in the mediterranean between Greece and Spain (no, it doesn't really exist so don't look it up in the map). In the island we produce and consume canoes, latreks (a garment that is comf ...

Suppose that you want an operation for the adt list that

Suppose that you want an operation for the ADT list that adds an array of items to the end of the list. The header of the method could be as follows. public void addAll(T[] items) Write an implementation of this method f ...

In thenbspworkspaceproject-lognbspdirectory create file

In the ~/workspace/project-log directory, create file named  changelog.txt  with the following content and format: Changelog Version: 1.0 Redirect the output of the ls command to a file named  file-list.txt  in the ~/wor ...

  • 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