[oggonachip] Re: pthread_cancel()
Aaron J. Grier
aaron at frye.com
Thu Apr 18 01:23:38 UTC 2002
On Wed, Apr 17, 2002 at 12:29:34AM +0200, Pattara Kiatisevi wrote:
> On Thu, 14 Mar 2002, Aaron J. Grier wrote:
>
> > On Thu, Mar 14, 2002 at 11:14:05AM +0100, Pattara Kiatisevi wrote:
> >
> > > Is there concept of rendezvous in classsic API? E.g. how would you
> > > implement this scenario? (It is not certain that task1 will connect to
> > > task2.meet() before or after task2 is waiting at task2.meet())
> > >
> > > Task 1: Task2:
> > >
> > > <run whatever> <run whatever>
> > >
> > > Connect task2.meet() ----------> Wait task2.meet()
> > > <meeting point code, run while task1
> > > blocks>
> > >
> > > <run whatever> <run whatever>
> >
> > use a simple binary semaphore.
>
> Hmm, but in case that task2 is faster than task1, then it released
> while noone was waiting (for obtaining). And then task1 blocks later,
> waiting for task2 to release whenever later. So it does not really
> correspond to the above rendezvous scheme?
you only show one task blocking in the above diagram. :)
> (whoever who is faster will wait for another one and go together). Do
> I miss sth?
I think you can do it with two binary semaphores:
task1: task2:
release(task1) release(task2)
acquire(task2) acquire(task1)
I think this does what you want. it doesn't matter which task runs
first -- it will always wait for a release() from the other before it
continues running.
someone please correct me if I'm on the wrong track -- it's been too
long since my last OS class. :)
--
Aaron J. Grier | Frye Electronics, Tigard, OR | aaron at frye.com
More information about the users
mailing list