[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC] kern: simple futex for gnumach (version 8)
From: |
Marin Ramesa |
Subject: |
Re: [RFC] kern: simple futex for gnumach (version 8) |
Date: |
Tue, 31 Dec 2013 18:40:34 +0100 |
On 12/31/2013 04:26:01 PM, Richard Braun wrote:
On Sun, Dec 29, 2013 at 09:44:51PM +0100, Marin Ramesa wrote:
> Futex waiters are now in a list and some bugs were fixed.
>
> I think this is now ready for test. I have tested this with
> malloc() and free() instead of kalloc() and kfree(), but
> without vm_map_lookup() and assert_wait() since these functions
> segfault on my machine with GDB.
Until you can actually call it from a Hurd userspace program, don't
consider it ready for test.
I added the RPCs, and am compiling gnumach and glibc on Hurd. I hope
I will be able to do this soon.
Are you initializing the hash table slots *every* time a futex is
initialized ??
Yes. I'll fix that. Thanks for noticing.
Also, where is futex_max_hash_val initialized
(I mean, to a value different from 0) ?
In the hash function.
> +int futex_wait(int *address, int value)
> +{
> + struct futex *futex;
> + struct futex_waiter waiter;
> +
> + lookup:
> +
> + futex = futex_hash_table_lookup_address(address);
> +
> + if (futex != NULL) {
> +
> + simple_lock(&futex->futex_wait_lock);
> +
> + /* If the value is still the same. */
> + if (*address == value) {
> +
> + waiter.thread = current_thread();
> +
> + kern_return_t kr;
> + kr = vm_map_lookup(¤t_map(),
(vm_offset_t)futex->address, VM_PROT_READ, NULL, NULL,
> + &waiter.offset, NULL,
NULL);
What's the point of this lookup ?
It calculates the offset from the (address, map) value pair.
If you were asking about the hash table lookup. It retreives the
new futex and I use it to check for futex_wait() called with
same address, but different value.
Also, how do you intend to handle timed waits ?
I haven't thought about this. My first task is to get a working
mutex or a synchronization event out of this. I'll then think
about the timed waits.
Last, but not least, when are futex objects released ?
When a futex with zero waiters is deleted.
Thanks!