bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cthread2Pthread


From: Marcus Brinkmann
Subject: Re: Cthread2Pthread
Date: Sun, 1 Dec 2002 20:14:04 +0100
User-agent: Mutt/1.4i

On Sun, Dec 01, 2002 at 04:11:05AM +0100, Vicente Hernando Ara wrote:
> When changing cthread code to pthread i have found this problem:
> 
> In file hurd/libpipe/pipe.c appear the following functions:
> 
> condition_implies and condition_unimplies
> 
> What are the best way to change them to pthread?

We need pthread implementations (as GNU extensions) for them.

The semantic is that with condition_implies you can register a condition
that should be triggered by another condition.

So, if a condition is signalled, a condition is also signalled on all
implied conditions.  Likewise, if a condition is broadcasted, a condition is
broadcasted on all implied conditions.  Very useful in the implementation of
io_select, for example.

> struct __pthread_cond
>   {
>     __pthread_spinlock_t __lock;
>     struct __pthread *__queue;
>     struct __pthread_condattr *__attr;
>     struct __pthread_condimpl *__impl;
>     void *__data;
>   };
>
> struct condition and __pthread_cond look similar. Coding a
> condition_implies replacement with __pthread_condimpl instead cond_imp
> seems easy, but i dont find __pthread_condimpl definition anywhere.
> 
> Can anyone enlight me on that?

You just need something like this:

struct __pthread_condimpl
  {
    struct __pthread_condimpl *next;
    struct __pthread_cond *implicatand;
  };

It's important to adjust condition_signal and condition_broadcast to forward
the conditions to the implied conditions (see libthreads/cprocs.c).  I am
not sure what the semantics should be if conditions are destroyed.  I guess
we can leave it to the caller to make sure that implied conditions are 
unregistered
before being destroyed (and automatically unregistered by destroying the
implying condition of course).

Thanks,
Marcus


-- 
`Rhubarb is no Egyptian god.' GNU      http://www.gnu.org    marcus@gnu.org
Marcus Brinkmann              The Hurd http://www.gnu.org/software/hurd/
Marcus.Brinkmann@ruhr-uni-bochum.de
http://www.marcus-brinkmann.de/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]