Producer-Consumer processes
$20-25 USD
Dibayar semasa penghantaran
This program should create two concurrent processes that will communicate between themselves with the help of shared memory and semaphores. The processes will be a producer and a consumer. The producer will produce items (e.g. integer numbers) and place them on a buffer (a queue perhaps?), which will exist on the shared memory. The consumer will remove items from the buffer and "consume" them. The queue will have a maximum capacity of 10 items. Fork should be used to create the two processes. (parent process: producer, child process: consumer) The shared memory should be created with shmget and will be deleted with shmdt. Also for the shared memory part, the following commands should be used: shmop, shmat, shmctl, ipcrm, ipcs) Semaphores will be used for the synchronization of the two processes (the commands sema_init, sema_destroy, sema_wait, sema_trywait and sema_post should be used). In the attached .zip file there is a .pdf that might help with some of the commands that should be used and a sample code file that roughly shows how the code should look like.
## Deliverables
Complete and fully-functional working program(s) in executable form as well as complete source code of all work done. Complete copyrights to all work purchased.
## Platform
It should compile on gcc and run in linux
## Deadline information
Ofcourse when the buffer is full, the procducer should suspend itself and thus give time to the consumer in order to consume the items on the buffer. If the buffer is empty, the consumer should suspend itself and give time to the producer to produce more items. In order to work on this project one must be familiar with the term "critical section" and its significance in a process. Therefore the following rules should be kept in order for the program to function properly: [url removed, login to view] two processes must never be in critical sections at the same time. 2.A process that is not in a critical section will not be allowed to suspend the other process. [url removed, login to view] maximum time that a process has to wait before entering a critical section must be defined.
ID Projek: #2855197