The following question is on Process Synchronization. Please do not provide a solution in code.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

 

The following question is on Process Synchronization. Please do not provide a solution in code. 

 

There is a high voltage match between Manchester City and Tottenham Hotspurs on December 2. Fans of both teams are very excited about the match and they are keen to watch the match live in the stadium. Tickets for the match have almost been sold out. There are only 10 tickets left. Fans have to maintain a queue according to the first come first serve manner while purchasing tickets. In order to maintain the rule a serial number has been assigned to each who is in the queue. Serials have been assigned in 1, 2 , 3, ……………, n according to the first come first serve order. The current scenario is, there are 10 tickets available and 12 persons in the queue. And there are 2 booths for purchasing tickets. Tickets gets sold in the following order, first two persons (1 and 2 in this case) gets called to two booths together but after the purchase gets completed of person 1 then person 2 starts the procedure of his purchase then after the completion of his purchase both of them left booths then next two persons from the queue gets called to booths for purchasing (3 and 4 in this case). If tickets get finished, booths get closed. Then nobody from the queue can purchase tickets anymore. That is how the entire ticket selling procedure works. According to the current scenario, there are 10 tickets left and 12 persons in the queue for purchasing tickets. Design a proper solution to the scenario that how the entire procedure of selling tickets can be synchronized based on the procedure described above. You have to design a solution and explain it briefly in order to provide the solution. Consider the number of remaining tickets as the shared variable and order of persons in the queue 1,2,3,..........,12. Consider 12 persons as 12 threads here.

The outcome of the solution should look like the following:

Person 1 is purchasing

Tickets left: 10

Person: 1, Purchase Done

Person 2 is purchasing

Tickets left: 9

Person: 2, Purchase Done

Person 3 is purchasing

Tickets left: 8

Person: 3, Purchase Done

Person 4 is purchasing

Tickets left: 7

Person: 4, Purchase Done

Person 5 is purchasing

Tickets left: 6

Person: 5, Purchase Done

Person 6 is purchasing

Tickets left: 5

Person: 6, Purchase Done

Person 7 is purchasing

Tickets left: 4

Person: 7, Purchase Done

Person 8 is purchasing

Tickets left: 3

Person: 8, Purchase Done

Person 9 is purchasing

Tickets left: 2

Person: 9, Purchase Done

Person 10 is purchasing

Tickets left: 1

Person: 10, Purchase Done

Person 11 can not purchase

Tickets left: 0

Person: 11, Purchase failed

Person 12 can not purchase

Tickets left: 0

Person: 12, Purchase failed

Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Fundamentals of Computer System
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education