Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoiding deadlocks #2

Open
pcapriotti opened this issue Apr 11, 2012 · 1 comment
Open

Avoiding deadlocks #2

pcapriotti opened this issue Apr 11, 2012 · 1 comment

Comments

@pcapriotti
Copy link

Is process-conduit completely deadlock-safe?

I tried implementing the same concept on top of pipes-core, and I haven't been to address the case where an upstream pipe is blocked on a monadic action, while some process downstream has data available. The problem is that until a pipe yields (i.e. goes into the HaveOutput state in conduit-speak), there's no way to awake any downstream pipe.

I believe the same holds for conduits, so I'm wondering how process-conduit addresses this issue, if at all.

As a concrete example, assume you have something like:

socketSource $= [cmd| slow filter|] $$ fileSink

and you get a single chunk out of the source. After that, assuming the filter hasn't had a chance to process it immediately, the pipeline will be blocked on the monadic action in socketSource. How can you unblock it as soon as "slow filter" is ready?

@tanakh
Copy link
Owner

tanakh commented Apr 12, 2012

I have recognized this problem.
Both upstream and downstream have possibilities to deadlock.
Upstream data do not depend on process-pipe, so ideally,
Check downstream first, then if no data available, wait upstream data with blocking.
(But buffering do bad things... it still may be deadlock.)

To solve this problem easily, fork two threads for reading upstream and downstream.
But I was no idea to fork thread in Pipe monads.
Are there a good idea to do this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants