In this assignment, you need to face the second programming challenge: implementing a task scheduler. You will
learn how to use the three programming constructs provided by the posix pthread library:
3. condition variable (convar)
to do so. Your goal is to simulate an airline check-in system, called ACS.
The check-in system includes 2 queues and 5 clerks. One queue (Queue 0) for economy class and the other
(Queue 1) for business class. We assume that the customers in each queue are served FIFO, and the customers in
the business class have a higher priority than the customers in the economy class. In other words, when a clerk
is available, the clerk picks a customer in the business class, if any, to serve, and picks a customer in the economy
class to serve only if the business class queue is empty. When a clerk is available and there is no customer in any
queue, the clerk remains idle. We assume that the service time for a customer is known when the customer enters
You will use threads to simulate the customers arriving and waiting for service, and your program will schedule
these customers following the above rules.
We assume that initially all queues are empty, and all clerks are idle. We assume customers are given before hand
and their description is stored in a file (refer to Section 2.2).
2.1 Properties of Customers
Each customer, which will be simulated by a thread, has the following attributes:
1. Class Type:: It indicates whether the customer belongs to business class or economy class.
2. Arrival Time: It indicates when the customer will arrive.
3. Service Time: It indicates the time required to serve the customer (i.e., from the time when the customer is
picked up by a clerk to the time when the clerk finishes serving the customer).
All times are measured in 10ths of a second. The times will be simulated by having your threads, which represent
customers, to call usleep() for the required amount of time.
2.2 The Format of Input File
Your program (ACS) will accept one parameter on the command line:
where customers.txt is the name of the input file.
2.2.1 File Format
The input file is a text file and has a simple format. The first line contains the total number of customers that will
be simulated. After that, each line contains the information about a single customer, such that:
1. The first character specifies the unique ID of customers.
2. A colon(:) immediately follows the unique number of the customer.
3. Immediately following is an integer equal to either 1 (indicating the customer belongs to business class) or 0
(indicating the customer belongs to economy class).
4. A comma(,) immediately follows the previous number.
5. Immediately following is an integer that indicates the arrival time of the customer.
6. A comma(,) immediately follows the previous number.
7. Immediately following is an integer that indicates the service time of the customer.
8. A newline (\n) ends a line.
To not kill yourself by checking the false input file, you should build a correct input file for your own test. We
will not test your code with an input file that does not comply with the above format.
2.2.2 An Example
The following file specifies 8 customers
Note that all times are measured in 10ths of a second, and in the above example, the first customer arrives at 0.2s
and her service time is 6s.