Assignment 8: Process Synchronization with Semaphores


What you will learn:

1. The Semaphore system call family: semget, semop, semctl
2. Implementing P() and V() using semaphore system call
3. Implementation of process synchronization using semaphores

Assignment

   Write a solution to the benchmark synchronization problem of producers and consumers
    as described below.
 
    Shared memory: 1 bounded buffer data structure implemented as shared memory
 
    Startup process:  creates bounded buffer
                                      creates needed semaphores
                                      and exits
 
    Producer process: do 5 times: produce, sleep for 1 second enddo
 
    Consumer process: do 5 times: consume, sleep for 1 second enddo

                any number of producer and consumer processes can be started after the startup process.

     Cleanup process:  deletes semaphores
                                         deletes shared memory
 
 
 What to submit

      your 4 programs+makefile+readme for identifying any special contributions:
                                                startup.c cleanup.c producer.c consumer.c  makefile readme
 

 Donot submit your binaries, executables. Your marks will be reduced if you do so.

Some Pointers

You can use ipcs, ipcrm to see ipc info
 Use semget, semop, semctl for implementing semaphore operations
 Use man to see man pages of the above syscalls

Submission

Assignment no=8.
Submit your file using ~oslab/submit script as in: ~oslab/submit 8 a.c b.c c.d d.c ....
submit script accepts assignment no. in its first argument. Any number of files may be submitted through subsequent arguments.
You may submit any number of times before 5:00pm. Old files are overwritten in resubmission.

Deadline: 5:00pm

Enjoy.