How to wait for more than one resource ? (solved)
# help
k
If a task wants to have mutually exclusive access to a single resource a semaphore can be used. But what if ** multiple resources **have to be allocated? Is there a construct to wait the task at one point for the fulfillment of a multiple resource condition?
k
Depending on the situation, you can use a counting semaphore for this. If you need to acquire 5 resources, you'll need to 'down' the semaphore 5 times. If we're talking multiple different kinds of resources (so a single count isn't enough), there are other approaches. Can you share more details on the scenario you have in mind?
k
I am playing around with task synchronisation and implement the 5 philosopher problem. Each phil has a left and right fork and if hungry has to wait until both are available. - Each fork has a semaphore lock. - (It already works). In current impl the phil takes the semaphores in predefined sequence. (Has influence to the simulation) So my question is can the phil wait for both forks on one point.
f
You might need to do a bit more work by yourself. You can always use a
Signal
to inform users that something has changed and react this way. Each task then runs separately, so no need to worry at that point.
k
https://github.com/kaxori/Prj_5_Philosophers runs on ESP32, but crashes on ESP32C3
f
Could you provide the error message? My guess is it is related to the pixel strip. @erikcorry
e
Looking into it. I get a hang on the C3, not a crash, but there's something wrong there.
I think the hang is unrelated to your crash, and I suspect a power issue in your crash.
k
Do not agree, there is no load (led strip) connected. It crashes with first
ledPixels.output r g b
@erikcorry: Solved with jaguar v1.11.2 Thank you 👍🏻