[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: POSIX semaphore for GNU/Hurd
From: |
Michal 'hramrach' Suchanek |
Subject: |
Re: POSIX semaphore for GNU/Hurd |
Date: |
Tue, 19 Nov 2002 18:25:09 +0100 |
User-agent: |
Mutt/1.4i |
Sending what I have so far. Hopefully I'll be able to read any comments next
wek.
On Thu, Nov 07, 2002 at 10:22:09AM -0500, Neal H. Walfield wrote:
> > > not conform to the GNU coding standards; this will have to be fixed.
It probably still does not, I'll have to read the GCS carefully when
I have time.
> > > You did not implement most of my suggestions in my previous emails on
> > > this subject.
> > It was intended as an improvemenet of the previos code, not complete
> > rewrite :)
>
> It will not be going in to the main line until it is rewritten.
>
> > - it can be used anywhere (modulo cancellation modes) not only on
> > the Hurd :)
>
> The cancelation code conforms to POSIX. What is this suppose to mean?
Setting cancellation options is part of the same option as threads, it should
really work everywhere. I have no idea if it is async-signal safe.
>
> > I do not understand what is exported about the mutex_t.
>
> What do you mean? Can you give more details.
----neal@cs.uml.edu said on 02 Nov 2002 19:34:42 -0500:
I would rather have part of the sem_t structure exported (? la
pthread_mutex_t). The structure should contain an id and a union: the
former so that we can distinguish between semaphores created with
sem_init and those with sem_open; and the latter so that sem_open and
sem_close can store the file descriptor and other relevant
information.
----
>
> > --- libpthread.org/include/bits/semaphore.h 1970-01-01 01:00:00.000000000
> > +0100
> > +++ libpthread/include/bits/semaphore.h 2002-11-07
> > 14:02:01.000000000 +0100
>
> > +#define SEM_VALUE_MAX (UINT_MAX - 1)
>
> This is defined by limits.h, not here. POSIX says the value may be
> indeterminate and thus the macro not defined. As such, we will not
> define it.
>
> > +#define SEM_VALUE_INVALID UINT_MAX
> I could not find a reference to this macro in POSIX. Could please you
> point me to the location where it is specified.
It should prabably have some underscore(s). But I removed it entirely.
>
> > +
> > +struct __sem_t
> > +{
> > + unsigned int count;
> > + pthread_mutex_t count_lock;
> > + pthread_cond_t count_cond;
> > + char * ID; /* may be used in future to store semaphore name */
>
> Why do you think this is useful?
I thought it was suggested in one of the emails. Anyway, the union is
more flexible.
>
> Did you actually test this? You cannot specify NULL for the oldtype
> argument.
I did not, and now I can not as the tests can no longer be linked. I may
try downgrading my Hurd tree.
>
> SEM_VALUE_MAX may not be defined. Conditionally compile this code in.
I expected my implementation defines it when it is used. But some value with
more underscores could be used instead.
>
> > +/* Destroys the semaphore */
> > +int
> > +sem_destroy (sem_t *sem)
> > +{
> > + int res = 0;
> > + pthread_mutex_lock (&sem->count_lock);
>
> Why are you bother to lock this?
I'd probably like that if I used the semaphore :)
--
Michal Suchanek
hramrach@centrum.cz
semaphore-2.diff
Description: Text document