Solution
If we remove the second of Patil's constraints, the cigarette smokers problem becomes solvable using binary semaphores, or mutexes. Let us define an array of binary semaphores A, one for each smoker; and a binary semaphore for the table, T. Initialize the smokers' semaphores to zero and the table's semaphore to 1. Then the arbiter's code is
and the code for smoker i is
while true: time.sleep(A) # make a cigarette signal(T) # smoke the cigaretteRead more about this topic: Cigarette Smokers Problem
Famous quotes containing the word solution:
“All the followers of science are fully persuaded that the processes of investigation, if only pushed far enough, will give one certain solution to each question to which they can be applied.... This great law is embodied in the conception of truth and reality. The opinion which is fated to be ultimately agreed to by all who investigate is what we mean by the truth, and the object represented in this opinion is the real.”
—Charles Sanders Peirce (18391914)
“Any solution to a problem changes the problem.”
—R.W. (Richard William)
“I cant quite define my aversion to asking questions of strangers. From snatches of family battles which I have heard drifting up from railway stations and street corners, I gather that there are a great many men who share my dislike for it, as well as an equal number of women who ... believe it to be the solution to most of this worlds problems.”
—Robert Benchley (18891945)