Does anyone know about "Tobacco producer problem" in Operating Systems?

Thread Starter

Xavier Pacheco Paulino

Joined Oct 21, 2015
728
Hello,

I do not find anywhere information about "The tobacco producer problem" in computer science. Do you know a book or reference where I can find information about it? It's for homework purposes.
 

spinnaker

Joined Oct 29, 2009
7,830
And the only tobacco problem with computers was cigarette tar coating floppy drive heads and other vital components in the PC.
 

spinnaker

Joined Oct 29, 2009
7,830
Is this what you're referring to? Wikipedia seems to explain it pretty well.

Easy for you to say. ;) I am struggling to figure out what the heck it is saying. ;) But not exactly sure why this is a computer problem. It is more of a word puzzle. Sort of like the fox, grain and chicken puzzle.

I don't ever recall having this problem in any of my comp sci classes.
 

Papabravo

Joined Feb 24, 2006
21,157
It is a classic problem in managing resources in an operating system. Deadlock occurs among processes when they are blocked, waiting for a resource that another process has. The other process cannot run to completion to release the needed resource. I've never heard it described as the "tobacco producer problem" but the underlying problem is sure a bear to find with rudimentary debugging tools. Much better if the design prevents this from happening in the first place.

For future reference the "deadlock" will get you to the information you need.
https://en.wikipedia.org/wiki/Deadlock
https://www.geeksforgeeks.org/operating-system-process-management-deadlock-introduction/
 
Last edited:

Thread Starter

Xavier Pacheco Paulino

Joined Oct 21, 2015
728
I've been reading about this topic, but everything is in terms of "Tobacco, Matches and Paper". I'm also studying FreeRTOS on STM32. That's why I want to find a practical example where I can encounter this problem. Any suggestions of a situation where this problem may occur?
 

WBahn

Joined Mar 31, 2012
29,976
I've been reading about this topic, but everything is in terms of "Tobacco, Matches and Paper". I'm also studying FreeRTOS on STM32. That's why I want to find a practical example where I can encounter this problem. Any suggestions of a situation where this problem may occur?
Tobacco, matches, and paper are just names for three shared resources needed by a process to accomplish a goal. You can replace them with whatever resources are applicable, such as external memory, a network connection, and an A/D converter.

The purpose of phrasing the problem in terms of smokers and things needed to smoke is that it is easier for people to visualize what is happening -- both what can happen and what can go wrong, as well as why it went wrong and how the solution works to fix it.

You might also look at the Dining Philosophers Problem.
 

Thread Starter

Xavier Pacheco Paulino

Joined Oct 21, 2015
728
Tobacco, matches, and paper are just names for three shared resources needed by a process to accomplish a goal. You can replace them with whatever resources are applicable, such as external memory, a network connection, and an A/D converter.

The purpose of phrasing the problem in terms of smokers and things needed to smoke is that it is easier for people to visualize what is happening -- both what can happen and what can go wrong, as well as why it went wrong and how the solution works to fix it.

You might also look at the Dining Philosophers Problem.
Yeah, I'm looking for something like that. But still confused. For example, I need to replace Tobacco, matches, and paper, with any 3 processes. Does it need to be exactly 3 processes? In my case, the agent would be the FreeRTOS in the STM32, and the threads may be, for example, AD Converter, UART, any other task.

How can I combine them to make this problem occur?
 

MrChips

Joined Oct 2, 2009
30,701
I have never heard of the "tobacco producer problem" but in my CS course we studied resource lockout and "deadly embrace". I am in communication with one of the researchers cited in the Wikipedia article. If you have a specific question I can pass it on to him.
 

nsaspook

Joined Aug 27, 2009
13,079

In the figure to the right, suppose A and B are making simultaneous transfers between two accounts in our bank.

A transfer between accounts needs to lock both accounts, so that money can’t disappear from the system. A and B each acquire the lock on their respective “from” account: A acquires the lock on account 1, and B acquires the lock on account 2. Now, each must acquire the lock on their “to” account: so A is waiting for B to release the account 2 lock, and B is waiting for A to release the account 1 lock. Stalemate! A and B are frozen in a “deadly embrace,” and accounts are locked up.
http://web.mit.edu/6.005/www/fa15/classes/23-locks/
Deadlock occurs when concurrent modules are stuck waiting for each other to do something. A deadlock may involve more than two modules: the signal feature of deadlock is a cycle of dependencies, e.g. A is waiting for B which is waiting for C which is waiting for A. None of them can make progress.

You can also have deadlock without using any locks. For example, a message-passing system can experience deadlock when message buffers fill up. If a client fills up the server’s buffer with requests, and then blocks waiting to add another request, the server may then fill up the client’s buffer with results and then block itself. So the client is waiting for the server, and the server waiting for the client, and neither can make progress until the other one does. Again, deadlock ensues.
 

WBahn

Joined Mar 31, 2012
29,976
Yeah, I'm looking for something like that. But still confused. For example, I need to replace Tobacco, matches, and paper, with any 3 processes. Does it need to be exactly 3 processes? In my case, the agent would be the FreeRTOS in the STM32, and the threads may be, for example, AD Converter, UART, any other task.

How can I combine them to make this problem occur?
Tobacco, matches, and paper are three resources, not three processes.

No, it does not have to be exactly three of them. The idea is for you to generalize the concept that when multiple processes need to share resources, you have the potential for processes to be preventing other processes from getting the resources they need to finish a task while, at the same time, being unable to finish their own task and release the resources they are holding because other processes, that need those resources, are holding the ones they need.
 
Top