# Unique Algorithm

It is a walk-in-interview setup having an interview room with
one chair and a waiting room with a number of chairs. The interviewer interviews
candidates in the interview room. When the interviewer finishes interviewing a candidate,
he dismisses the candidate and goes to the waiting room to see if there are other
candidates waiting. If there are, he brings one of them to his room and interviews him. If
there are no candidates waiting, he returns to his chair in the interview room and
continues reading his last unfinished magazine. If there are no unfinished magazines, he
starts reading a new magazine. After he finishes reading one full magazine, he goes to
sleep.
Each candidate, when he arrives, looks to see what the interviewer is doing. If the
interviewer is reading a magazine, the candidate waits for the interviewer to finish
reading the current page of the magazine. Then the candidate enters the interview room
and asks the interviewer to interview him. If the interviewer is sleeping, the candidate
wakes him up and then asks the interviewer to interview him. If the interviewer is
interviewing another candidate, the candidate goes to the waiting room. If there is a free
3 chair in the waiting room, the candidate sits in it and waits his turn. If there is no free
chair, then the candidate leaves.
Based on a naive analysis, the above description should ensure that the walk-ininterview
functions correctly, with the interviewer interviewing any candidate who arrives
until there are no more candidates, and then reading magazines and/or sleeping until the
next candidate arrives. In practice, there are a number of problems that can occur that
are illustrative of general scheduling problems. Please discuss those problems and
provide an algorithm to solve those problems.
Note: There are two doors between the interview room and the waiting room.
Tip: Read literature on the Dining Philosophers problem