Passing data to a thread

Valentin Hauner valentinhauner at gmx.de
Tue Sep 2 16:31:33 CEST 2014


Hi,

I'm trying to pass some data to a newly created thread.
Since l4_thread_ex_regs only accepts an instruction pointer, but no data
pointer, it seems impossible to me to use a parameterized function such as:
> thread1_func(void *data) { /* Read the data ... */ }

So far, my efforts are:

1. I've tried filling the stack allocated to each newly created thread with
> thread_stack = malloc(8 << 10);
> thread_stack[0] = my_data;
but then I'm not able to pop the data from the stack in thread1_func.

2. I've tried using IPC: The main thread which is creating the new
threads sends the data to the destination thread. I'm using l4_ipc_send
in the main thread and l4_ipc_receive in thread1_func just like in your
utcb-ipc example. It works great, but unfortunately the call of
l4_ipc_send leads to an _immediate_ execution of thread1_func (timeouts:
L4_IPC_NEVER), so my scheduling policy is not respected.

So how can I pass data to a thread in a way that is equivalent to
passing arguments to functions?

Best regards,
Valentin




More information about the l4-hackers mailing list