Assignment 2
: Casino Royale Gambling
Problem
Given on: 23rd Feb, 2007
Due Date: 10th March, 2007
Assignment can be done in pair of two
Introduction
In this assignment, you will use UNIX pthreads (“POSIX threads”) in
an implementation of the synchronization problem.
Visitors (who need fun) go to MGM Grand in Las Vegas, may have to wait before they get a
chance to gamble. Inside the casino there are ‘n’ XYZ machines meant for
individual gambling. If all the machines are occupied the visitors have to wait
in the waiting lounge. The waiting lounge has a restaurant along with poker
tables where people can be entertained before they turn to big time gambling.
When the visitor are finished with their gambling they go to the token counter
to collect/pay money in exchange for tokens, following which they leave the
casino immediately.
The Casino Royale Gambling problem is a classical IPC (inter process
communication) problem that models waiting queues (e.g., a telephone service
call center).
Details
In this assignment, you will instrument and experiment with the
performance of a working implementation of the Casino Royale Gambling
problem. The implementation is to be written in C and uses pthreads to implement the visitor, gambling and restaurant
processes.
Following are specific instructions on what to do.
- If
the machines are available then the visitors need not go to the waiting
lounge.
- If
all the machines are occupied they are given a ‘customer number’ which can be
used to call them the moment the machines become available (ensuring a FCFS
order).
- Inside
the waiting lounge there are ‘m’
poker tables and the restaurant has a capacity of ‘L’. There is a finite probability ‘p’ of a visitor choosing poker over
restaurant. For simplicity assume that a visitor may choose only either poker
or the restaurant.
- If
all the poker tables are occupied and the restaurant is also full then the
visitors will leave the casino.
- If
the visitor chose to play poker, but all the poker tables are occupied and the
restaurant is not full, then he will go to the restaurant and wait for the
poker table to have a vacancy. For this purpose, there will be a queue for
playing poker as well which will be served in FCFS basis.
- On
one poker table 4 players are needed for commencement of the game. A player
upon being called will leave the table. If there are less than 4 players at
any point of time, then the game goes to waiting state.
- Among
the waiting state table, the one with the maximum number of members is chosen
first by the visitor. Incase of tie, the visitor randomly chooses one table.
Parameters
·
The arrival rate in the casino is a poison
process with mean arrival rate = 1 person per minute.
·
The time to make a move on a poker table is an
exponential process with mean of 20 seconds.
·
The playing time of visitors on ‘XYZ’ machines is
assumed to be exponentially distributed with mean playing time equals 15
minutes.
·
The time spent on the token counter is a
deterministic process and it takes 2 minute per person for the token exchange.
For security purposes the personnel at the counter changes their shift after
every 90 minutes. The changing time is 5 minutes.
·
‘m’ =
8
·
‘L’ =
100
·
‘n’ =
25
·
The probability of playing poker i.e. ‘p’ = .21
Analysis
Prove the
correctness of your algorithm with respect to the following-:
1)
Mutual Exclusion
2)
Progress
3)
Deadlocks
4)
Bounded Waiting
Analyze the
variation of the following quantities with time -:
1)
Number of visitors who had left the system after
gambling
2)
Number of visitors who left the system without
gambling
3)
Number of players in poker queue
4)
Number of visitors playing poker
5)
Number of poker moves
6)
Number of Customers served in the restaurant
7)
Turn Around Time
8)
Wait time
Notes-:
- The
programming language to be used is C.
- Proper
directory structure has to be maintained and coding standards have to be
followed.
- Function
and variable names should be intuitive.
- Use
of Makefile is a must (no scripting allowed).
- Include
a Readme file, explaining the basic structure of the
code.
- The
code should be modular, self-explanatory and well commented.