guild icon
Toit
#How to wait for more than one resource ? (solved)
Thread channel in help
kaxori
kaxori 08/22/2023 03:37 PM
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?
bitphlipphar
bitphlipphar 08/22/2023 07:34 PM
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?
kaxori
kaxori 08/22/2023 07:50 PM
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.
floitsch
floitsch 08/23/2023 09:53 AM
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.
kaxori
kaxori 08/23/2023 11:36 AM
https://github.com/kaxori/Prj_5_Philosophers

runs on ESP32, but crashes on ESP32C3
Toit example for task synchronisation and RGB-Led-Ring control - GitHub - kaxori/Prj_5_Philosophers: Toit example for task synchronisation and RGB-Led-Ring control
floitsch
floitsch 08/23/2023 11:38 AM
Could you provide the error message?
My guess is it is related to the pixel strip.
@erikcorry
kaxori
kaxori 08/23/2023 11:39 AM
Decoding by jag, device has version <2.0.0-alpha.90> EXCEPTION error. Connection closed 0: tcperror /net/modules/tcp.toit:208:3 1: TcpSocket_.ensurestate /net/modules/tcp.toit:75:14 2: Tc...
๐Ÿ‘1
erikcorry
erikcorry 08/23/2023 03:24 PM
Looking into it. I get a hang on the C3, not a crash, but there's something wrong there.
erikcorry
erikcorry 08/24/2023 01:58 PM
I think the hang is unrelated to your crash, and I suspect a power issue in your crash.
kaxori
kaxori 08/24/2023 07:47 PM
Do not agree, there is no load (led strip) connected.
It crashes with first ledPixels.output r g b
kaxori
kaxori 09/06/2023 10:01 PM
@erikcorry: Solved with jaguar v1.11.2
Thank you :๐Ÿ‘๐Ÿป:
12 messages in total