For example I have a machinist(x) process, where x can represent various tools a machinist has. There are three types of machinists, one with the screwdriver, another with a hammer, another with a brush.
All three tools are needed to manufacture a product. The robot process takes one of the tools, and takes the two other tools from the machinists that have them to complete a product. This process iterates over and over again indefinitely (where the robot potentially takes a different starting tool every time).
I need to write a process manager using semaphores, REALLY confused :/
Basically I need pseudocode
I’m assuming you have multiple robots, each in its own thread building a product?
Maybe something like this: Each robot waits for and reserves the screwdriver, then does the same for the hammer etc. After building the product release all tools. One important consideration is reserve the tools in a consistent order; otherwise you risk deadlocks.