-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 17.09.2014 14:30, Valentin Hauner wrote:
Hi,
On 09/17/2014 10:23 AM, Björn Döbel wrote:
An fpage() wants an address and a size. Your malloc() call yields an address (note: this is probably unaligned, maybe prefer to use posix_memalign()), the size is what you pass to malloc(). What would be the problem?
Still the same problem, I'm getting page faults at the head of the thread function with the following new code:
// Out of function l4_umword_t *thread_stacks[THREAD_MAX_NUM]; // ... void foo() { // ... unsigned stack_size = THREAD_STACK_SIZE * sizeof(l4_umword_t); if (posix_memalign((void**)&thread_stacks[count], (size_t)L4_LOG2_PAGESIZE, (size_t)stack_size) != 0) return -1; // ... l4_touch_rw(thread_stacks[count], stack_size); l4_task_map(task_cap, L4RE_THIS_TASK_CAP, l4_fpage((unsigned long)thread_stacks[count],
stack_size, L4_FPAGE_RWX),
l4_map_control((l4_umword_t)thread_stacks[count], 0, L4_MAP_ITEM_MAP));
// ... }
For starting a single thread:
* What is thread_stacks[thread.id]? * What is the stack pointer you are setting at thread startup? * Is any of these addresses related to the page fault address you are seeing?
That is, if you execute the thread code within the parent?
Yes, I simply bind the new threads to the current task (L4RE_THIS_TASK_CAP) in this case.
Sure, because then memory is managed by L4Re instead of your own pager and the thread is running in the same address space as its creator.
You probably already mentioned it, but this thread has grown quite long: Why do you actually have to launch threads in a different AS and implement your own pager?
Bjoern