Your task is to implement a scheduling algorithm for a bar.
A bar has 4 bar tables, and each table has 8 stools next to each other. For example, stools 0-7 belong to table 1; stools 8-15 belong to table 2; stools 16-23 belong to table 3; and stools 24-31 belong to table 4. Stool 7 is adjacent to stool 8; stool 15 is next to stool 16; stool 23 is next to stool 24; however, stool 31 is not next to stool 0.
Customer parties arrive in intervals based on their randomly chosen class year (enum) in groups of up to 8 (integer). Freshmen drink one (non-alcoholic) drink, taking 5 seconds to drink. Sophomores drink two (non-alcoholic) drinks, taking 10 seconds to drink. Juniors drink three drinks, taking 15 seconds to drink. Seniors drink four drinks, taking 20 seconds to drink. Professors (and Graduate Students) drink five drinks, taking 25 seconds to drink.
After a table spot is used, it becomes dirty. A customer cannot sit in a dirty chair. One table (i.e., seats 0-7) can be cleaned at a time. It takes 10 seconds to clean a table.
Customers who cannot immediately be served will be loaded into a waiting queue in FIFO order. The bar can hold a maximum of 32 customers (with the grouping constraint). Once a customer is sat at a table, they can only be removed by finishing their drinks. Customers will wait in line indefinitely.
Here are some examples of structures that can be used to implement the project (these are not complete and are just to give you an idea):
Struct bar:
list queue;
table tables[4];
Struct table:
seats seat[8];
Struct seat:
bool status;
customer student;
Struct customer:
time_t time_entered;
int group_id; // Group_id could be a random number between INT_MIX and INT_MAX to keep track of the groups.
int type;
Step 1: Kernel Module with a Bar
Develop a representation of a bar. In this project, you will be required to support having a maximum of 32 customers in the bar itself and n number of customers waiting (this can never be exceeded by the bar). The waiter must wait for 2.0 seconds when moving between tables, and it must wait for 1.0 second while adding and removing customers. The bar must be able to support an arbitrary number of customers.
When the waiter visits each table, it should do the following:
1. Remove customers who are done drinking. You do this by checking the time.
2. If possible, add customers (if there is clean and empty space).
3. If possible, clean the table (if there is no one left).