How to create a thread ?

BERTRAND Joel <[email protected]> Sun, 17 Oct 2010 18:45:56 +0200
Newsgroups gmane.comp.micro-kernel.l4.l4ka.general
Message-ID <[email protected]>
	Hello,

	I'm trying to create a thread in the same AS than root task. 
L4_ThreadControl() and L4_Start() do not return error but child thread 
is not started and I don't understand my mistake. I don't know if child 
thread is created.

	Here is my code :

- root_tid = L4_Myself()
- notice is a macro that call libl4 printf and another function that 
puts characters on screen
- PANIC(a) stops root task if a is true
- pager_stack is declared as static array

     pager_utcb = L4_MyLocalId().raw;
     pager_utcb = (pager_utcb & (~(utcb_size - 1))) + utcb_size;
     pager_tid = L4_GlobalId(L4_ThreadNo(root_tid) + 1, 1);

     L4_ThreadControl(pager_tid, root_tid, root_tid, root_tid,
             (void *) pager_utcb);
     notice("error=%s\n", L4_ErrorCode_String(L4_ErrorCode()));
     PANIC(L4_ErrorCode());
     L4_Start(pager_tid,
             (L4_Word_t) (pager_stack + sizeof(pager_stack) - 32),
             (L4_Word_t) vms$pager);
     notice("error=%s\n", L4_ErrorCode_String(L4_ErrorCode()));
     PANIC(L4_ErrorCode());
     notice(RUN_S_PROC_ID "identification of created process is %08X\n",
             (unsigned int) L4_ThreadNo(pager_tid));

On console, I obtain :

error=l4_error_ok
error=l4_error_ok
%RUN-S-PROC_ID, identification of created process is 0000003B

	vms$pager is a function that begin with :

void
vms$pager()
{
     L4_ThreadId_t       tid;

     notice("VMS$PAGER lauched\n");
     ...
}

	I don't understand my mistake. I have check my code and try to 
understand how pingpong launchs its threads without any result.

	Any help is welcome.

	Regards,

	JKB