Write a C / C ++ Pthread program for a dental clinic queue system that declares an array of integers of size N, where N is the maximum number of queues per day. Pthread uses two threads.
Whenever a new appointment for dentistry appears, the first thread (creator) places the queue numbers in the array one after another. the second thread (deletion) deletes the queue numbers from the array whenever the dentist saw the patient. This is done in FIFO (First In First Out) mode. The creator's algorithm is as follows:
β’ If the array is not filled, then enter a new number in it (numbers start at 1 and each time increase by one, so the creator creates queues 1, 2, 3, etc.)
β’ sleep for 1-10 seconds, randomly
β’ repeat
The deletion algorithm is as follows:
β’ If the array is not empty, delete the least number of queues.
β’ sleep for 1-10 seconds, randomly
β’ repeat
, . , (: " 13 ", " 7 " ..). .
.
.