Sweta Tiwari posted an Question
July 14, 2021 • 10:31 am 30 points
  • UGC NET
  • Computer Science & Applications

Producer consumer problem using semaphore

If writers writes in database, readers/wTiters are not allowed in database. Ques. Oes. Consider the procedure below for producer consumer problem which uses semaphore n = 0 S 1 Void producer () Void consumer () produce O sem wait (S) sem wait (s) sem wait (n) add to buffer () remove from buffer ) sem signal (s) sem signal (s) sem signal (n) consume () Which one of the following is true? (A) Producer will be able to add item to the buffer but consumer will never be able to consume it. (B) Consumer will not remove more than one item from the buffer. (C) Deadlock occurs if the consumer succeeds in acquiring semaphore, when buffer is empty. (D) The starting value for the semaphore S, n must be 1 & not 0 for deadlock free operation. Ans. (C) Consumer executes wait(s) than wait(n) & goes to sleep. After consumer sleep, producer goes to sleep wait(s).

1 Answer(s) Answer Now
  • 0 Likes
  • 1 Comments
  • 0 Shares
whatsapp-btn

Do You Want Better RANK in Your Exam?

Start Your Preparations with Eduncle’s FREE Study Material

  • Updated Syllabus, Paper Pattern & Full Exam Details
  • Sample Theory of Most Important Topic
  • Model Test Paper with Detailed Solutions
  • Last 5 Years Question Papers & Answers