Pthread Queue System

I am working on my task on pthreads. I am a newbie and have never touched pthreads before. Are there any code samples or resources that any of you have that can help me in my assignment?

Here are my appointment details. The pthread queue system program:

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 " ..). .

. .

+3
2

, pthreads, , , , ( ). pthreads . , API Linux, , . fooobar.com/questions/89474/... .

, Linux Threading Synchronization.

, . , , , .

+4

-.

, , , , , , , . , , .

, , , , , , .

, ; , . , , , .

0

Source: https://habr.com/ru/post/1746797/


All Articles