In any PRODUCER-CONSUMER problem this 4 criteria must satisfy
(1)When a reader is reading, no writer must be allowed.
(2)Multiple readers should be allowed.
(3)When a writer is writing, no reader must be allowed.
(4)Multiple writers(more than 1) should not be allowed.
here 2 counting semaphores are used to keep track how much the buffer if empty or full they are b_full=0 ( means initially nothing in the buffer) & b_empty=100 (means initially empty cells in buffer is 100 or buffer is all empty)
now for K - Producer produced an item & he wants to insert into buffer but reader should not read meanwhile producer adding item to buffer for that (P(mutex)) now it downs the semaphore P(b_empty) means now buffer_empty=99 or there is 1 item inserted.
L - after inserting, it ups the semaphore V(b_full) means Buffer_full=1 or there is 1 item present in buffer.
now for M - it downs the "P(b_full)" semaphore means it has taken out 1 item from buffer and consumes item and
N - up the "V(b_empty)" to state that one more cell of buffer is empty now.