>
>
>int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
>{
> int ret, saved_errno;
>
> uwaitq_add(cond);
> futex_up(&mutex);
> while ((ret = uwaitq_wait(NULL)) == 0 || errno == EINTR);
> saved_errno = errno;
> uwaitq_remove(cond);
> futex_down(&mutex);
>
You should loop here in order catch signals:
while ( futex_down(&mutex) < 0 && errno == EINTR)
>
> if (ret < 0 && errno == EINTR)
> goto again;
>
This assumes that you are allowed to do a double uwaitq_add.
>
> saved_errno = errno;
> uwaitq_remove(cond);
> futex_down(&mutex);
>
Also loop here
>
> errno = saved_errno;
>
> return ret;
>}
>
Now whats interesting is the kernel part. I must admit that I haven't
fully understood all
effects of the double use of the cookie in your first implementation.
But if you use a memory
location as identifier you have to keep a separate flag within
uwaitq_head that is zeroed
before you add to the waitqueue and set by the signal functions. Then
uwaitq_wait has to check for it.
This is necessary in order not to loose a wakeup while you are on the
queue but not sleeping.
uwaitq_remove also takes an argument, are you heading for waiting on
multiple events?
Since you need to pin down the page between uwaitq_add and uwaitq_remove
you will have to limit
the number of simultaneous add calls. Should this be configurable?
Cheers,
Martin
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/