[RFC] kern: simple futex for gnumach (version 5)

2013-12-26 Thread Marin Ramesa
Number of threads to wake is now a boolean, which means it's one or all. Call to assert_wait() has been added before thread_suspend(). The scan for vm_objects has been removed and recursion in futex_wake() has been removed and code rewriten. There are problems however, futex_wait() test on the

Re: [RFC] kern: simple futex for gnumach (version 5)

2013-12-26 Thread Richard Braun
On Thu, Dec 26, 2013 at 02:30:10PM +0100, Marin Ramesa wrote: + futex-address = address; + futex-num_futexed_threads = 0; + futex-next_futex = NULL; + futex-prev_futex = (table-futex_elements[prev_hash_val]); + futex-prev_futex-next_futex = futex; + *futex-map =

Re: [RFC] kern: simple futex for gnumach (version 5)

2013-12-26 Thread Richard Braun
On Thu, Dec 26, 2013 at 02:58:01PM +0100, Richard Braun wrote: I know this isn't the traditional way to do it in Mach, but please, extensively document the API in the header, e.g. as it's done for the slab allocator. I also suggest moving everything not public (such as Actually, kern/rbtree.h

Re: [RFC] kern: simple futex for gnumach (version 5)

2013-12-26 Thread Marin Ramesa
On 12/26/2013 02:58:01 PM, Richard Braun wrote: Why __builtin_malloc and __builtin_free ?? I get segfaults in kalloc(). I don't know what I'm doing wrong. + if (futex-num_futexed_threads == 128) + return FUTEX_RESOURCE_SHORTAGE; I assume this

Re: [RFC] kern: simple futex for gnumach (version 5)

2013-12-26 Thread Richard Braun
On Thu, Dec 26, 2013 at 03:15:24PM +0100, Marin Ramesa wrote: I get segfaults in kalloc(). I don't know what I'm doing wrong. Show us how you use it. -- Richard Braun

Re: [RFC] kern: simple futex for gnumach (version 5)

2013-12-26 Thread Marin Ramesa
On 12/26/2013 03:25:11 PM, Richard Braun wrote: On Thu, Dec 26, 2013 at 03:15:24PM +0100, Marin Ramesa wrote: I get segfaults in kalloc(). I don't know what I'm doing wrong. Show us how you use it. futex-futexed_threads = (thread_t)kalloc((futex-num_futexed_threads+1)*sizeof(struct

Re: [RFC] kern: simple futex for gnumach (version 5)

2013-12-26 Thread Richard Braun
On Thu, Dec 26, 2013 at 03:51:30PM +0100, Marin Ramesa wrote: futex-futexed_threads = (thread_t)kalloc((futex-num_futexed_threads+1)*sizeof(struct thread)); When futexed_threads is a pointer to struct thread. Why are you allocating a thread structure ?? I strongly suspect kalloc does what

[PATCH] Implement thread destruction

2013-12-26 Thread Richard Braun
This change makes libpthread release almost every resource allocated for a thread, including the kernel thread, its send right, its reply port and its stack. This improves resource usage after peaks of activity during which servers can create hundreds or even thousands of threads. To achieve it,

Re: [PATCH] Implement thread destruction

2013-12-26 Thread Samuel Thibault
Richard Braun, le Thu 26 Dec 2013 17:22:58 +0100, a écrit : + __pthread_thread_terminate). THREAD looses one reference and is loses, actually :) (and ditto further down) It looks alright to me, and less clumsy than the previous way. Samuel

Re: [PATCH] Implement thread destruction

2013-12-26 Thread Richard Braun
On Thu, Dec 26, 2013 at 05:44:56PM +0100, Samuel Thibault wrote: loses, actually :) (and ditto further down) Right, thanks. -- Richard Braun