Simple question about pingpong roottask

"Gabriel Gonzalez" <[email protected]>
Newsgroups gmane.comp.micro-kernel.l4.l4ka.general
Message-ID <[email protected]>
Hi,

  I have modified the pingpong root task, which come along the
Pistachio distribution, making it as simple as posible (file pasted at
the end). I have just kept creating a thread and starting it but there
is a point which I don't get at all.
  Why should the memory be touch by the root task before starting the
thread? I mean, why should any page fault been thrown when the new
thread is started?

  Thank you very much for your time.

Cheers,

  Gabriel Gonzalez.

<++>
#include <config.h>
#include <l4/kip.h>
#include <l4/ipc.h>
#include <l4/schedule.h>
#include <l4/kdebug.h>
#include <l4io.h>


L4_Word_t stack[2048] __attribute__ ((aligned (16)));

void pager (void)
{
  printf("PUMLALALAL");
}

int main (void)
{
    L4_Word_t control;
    L4_ThreadId_t master_tid, pager_tid;
    L4_Fpage_t kip_area, utcb_area;
    L4_Word_t utcb_size;
    L4_Time_t timeout;
    char c;

    L4_KernelInterfacePage_t * kip =
        (L4_KernelInterfacePage_t *) L4_KernelInterface ();
#ifdef TOUCH_MEM
    extern L4_Word_t _end, _start;
    for (L4_Word_t * x = (&_start); x < &_end; x++)
    {
        L4_Word_t q;
        q = *(volatile L4_Word_t*) x;
    }
#endif

    // Size for one UTCB
    utcb_size = L4_UtcbSize (kip);

    // Create pager
    master_tid = L4_Myself ();
    pager_tid = L4_GlobalId (L4_ThreadNo (master_tid) + 1, 2);

    // VU: calculate UTCB address -- this has to be revised
    L4_Word_t pager_utcb = L4_MyLocalId().raw;
    pager_utcb = (pager_utcb & ~(utcb_size - 1)) + utcb_size;
    printf("local id = %lx, pager UTCB = %lx\n", pager_tid,
           pager_utcb);

    printf("thread_control: %d\n",
           L4_ThreadControl (pager_tid, L4_Myself (), L4_Myself (),
                             L4_Myself(), (void*)pager_utcb));
    L4_Start (pager_tid, (L4_Word_t) stack + sizeof(stack) - 32,
(L4_Word_t)pager);

    printf("Stack %p\n", stack + sizeof(stack) - 32);
    printf("pager IP %p\n", pager);

    c = getc();
    L4_LoadMR (0, 0);
    L4_Send (pager_tid);

    for (;;)
        L4_KDB_Enter ("EOW");
}
<-->
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.