Already have an account? Get multiple benefits of using own account!
Login in your account..!
Remember me
Don't have an account? Create your account in less than a minutes,
Forgot password? how can I recover my password now!
Enter right registered email to receive password!
Now let's implement bounded producer-consumer with semaphores, a Coke machine which is initially empty:
semaphore sem_mutex = 1 // binary semaphore for mutual exclusion, 1==unlocked
semaphore slots_left = Nsemaphore cokes_left = 0producer()down(slots_left)down(sem_mutex)insert Coke into machineup(cokes_left)up(sem_mutex)consumer()down(cokes_left)down(sem_mutex)buy Cokeup(slots_left)up(sem_mutex)
Note that the down(slots left) needs to go before the down(sem mutex), and similarly for down(cokes left) and down(sem mutex), because otherwise the system can end up waiting forever. For example, imagine an empty machine with the consumer arriving ?rst, and calling down(sem mutex) before down(cokes left).
In some sense, the consumer calling down(cokes left) is a reservation to get a Coke in the future. Even if there are no Cokes currently in the machine, the consumer is reserving a claim for a future Cokewith this action. Similarly, the producer calling down(slots left) is a reservation to insert a new Coke in the future.
What is contiguous allocation? Allocation of a group of consecutive sectors for a one file.
Q. What is the use of system programs? Answer: System programs are able to be thought of as bundles of useful system calls. They provide fundamental functionality to users so
File allocation using I nodes. This method is used to decrease the size of the table in the above method. Every file will have an I-node list. Allow a file have 15 pointers a
Problem 1: (a) The grouping of organisational activities (usually into ‘departments' or larger ‘divisions') can be done in different ways. Outline 7 criteria which can be used
Write a short note about context switch. Switching the CPU to another process needs saving the state of the old process and loading the saved state for the new process. This ta
Lexical substitution during macro expansion Lexical substitution is employed to produce an assembly statement from a model statement. A model statement contains 3 types of stri
Q. What are two differences among user-level threads and kernel-level threads? Under what situations is one type better than the other? Answer: (1) User-level threads are un
We have stressed the need for an operating system to make efficient use of the computing hardware. When is it appropriate for the operating system to forsake this principle and to
Question: a. The following questions refer to a generic Windows file system: i) Describe what happens when you high-level format a floppy disk? ii) What is the maximum size
Q. Which of the subsequent programming techniques and structures are good for a demand-paged environment? Which aren't good? Describe your answers. a. Stack b. Hashed symbol
Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!
whatsapp: +91-977-207-8620
Phone: +91-977-207-8620
Email: [email protected]
All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd