Re: [PATCH] kern: simple futex for gnumach (version 4)

2013-12-24 Thread Richard Braun
On Sun, Dec 22, 2013 at 03:58:55PM +0100, Marin Ramesa wrote: +simpleroutine futex_rpc( + thread : thread_t; + address : pointer_t; + value : int; + operation : int); + +simpleroutine futex_wait_rpc( +

Re: [PATCH] kern: simple futex for gnumach (version 4)

2013-12-24 Thread Marin Ramesa
On 12/24/2013 11:41:40 AM, Richard Braun wrote: Obviously, you rushed your work without trying to understand what you were doing, and this is becoming frustrating. Don't blindly and mindlessly copy the first thing you see around... 1/ A simpleroutine is a one-way RPC, without a return value

[bug report] segmentation fault in task_create()

2013-12-24 Thread Marin Ramesa
I noticed this while testing the futex call. I don't know how to fix this. The code to reproduce this is the following: extern int task_create(); struct task; typedef struct task *task_t; extern task_t kernel_task; int main(void) { task_t new_task; task_create(kernel_task, 0,

Re: [bug report] segmentation fault in task_create()

2013-12-24 Thread Samuel Thibault
Marin Ramesa, le Tue 24 Dec 2013 13:26:35 +0100, a écrit : extern task_t kernel_task; Where is this supposed to come from? int main(void) { task_t new_task; task_create(kernel_task, 0, new_task); If kernel_task is not properly initialized, it is not really surprising that you

Re: [PATCH] kern: simple futex for gnumach (version 4)

2013-12-24 Thread Richard Braun
On Tue, Dec 24, 2013 at 12:52:23PM +0100, Marin Ramesa wrote: I need to start somewhere. I really want to learn how kernels are programmed. This task was listed in the small hacks entry, I really thought it would be a small hack. That's probably a mistake on our part. There is a one call

Re: [PATCH] kern: simple futex for gnumach (version 4)

2013-12-24 Thread Marin Ramesa
On 12/24/2013 03:25:15 PM, Richard Braun wrote: There is a one call to vm_map lookup to retrive the offset and the object. Simple How do you implement cross address space synchronization ? I use a recursive futex_wake(). It first scans all the futexes if they are on the same offset and if

Re: [PATCH] kern: simple futex for gnumach (version 4)

2013-12-24 Thread Richard Braun
On Tue, Dec 24, 2013 at 04:55:47PM +0100, Marin Ramesa wrote: I use a recursive futex_wake(). It first scans all the futexes if they are on the same offset and if they share the same vm_object. If they do, recursion is used to wake a number of threads in those futexes. The number of threads

Re: [PATCH] kern: simple futex for gnumach (version 4)

2013-12-24 Thread Marin Ramesa
On 12/24/2013 05:20:41 PM, Richard Braun wrote: On Tue, Dec 24, 2013 at 04:55:47PM +0100, Marin Ramesa wrote: I use a recursive futex_wake(). It first scans all the futexes if they are on the same offset and if they share the same vm_object. If they do, recursion is used to wake a number of

Re: [PATCH] kern: simple futex for gnumach (version 4)

2013-12-24 Thread Richard Braun
On Tue, Dec 24, 2013 at 05:38:59PM +0100, Marin Ramesa wrote: I have read in Futexes are tricky that futex() is used with INT_MAX argument. I want to keep that usage. So, if a number of threads to wake is greater than number of threads in a futex I wake all. And it also says everything else