lkml.org 
[lkml]   [2002]   [Mar]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] Futexes IV (Fast Lightweight Userspace Semaphores)

>
> And on top of them:
> futex_down(struct futex *);
> futex_up(struct futex *);
>
Why not keep the simple one-sys-call interface for the fuxtexes. The
code is so small that it is
not worth to delete it.

>
>
>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/

\
 
 \ /
  Last update: 2005-03-22 13:25    [W:0.648 / U:0.064 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site