AW: L4_ThreadSwitch behaviour

"Christian, Martin, OPEE45" <[email protected]>
Newsgroups gmane.comp.micro-kernel.l4.l4ka.general
Message-ID <[email protected]>
I attached the source code - it's based on the pinpong example but stripped from all none-PowerPC parts.

> listspaces
c002b000: (idle)
c0031000: (sigma0)
c0038000: roottask 00090002
c004a000: 00094002

These are the states of roottask, pager and ping_thread after Yield but BEFORE ThreadSwitch:

Root Task:
=== roottask == TCB: e0011800 == ID: 0008c001 == UTCB: bf000040/c003c000 == PRIO: 0xff ===
UIP: 003016b4   queues: Rswl      wait : NIL_THRD:NIL_THRD   space: c0038000
USP: 00306340   tstate: RUNNING   ready: roottask:roottask   pdir : 00c00380
KSP: e0011e40   sndhd : NIL_THRD  send : NIL_THRD:NIL_THRD   pager: sigma0
total quant:    0x0 us, ts length  :       0x2710 us, curr ts: 0x2710 us
resources: 00000000 []
scheduler: roottask  send redirector: ANY_THRD  recv redirector: ANY_THRD
  partner: NIL_THRD    saved partner: NIL_THRD      saved state: ABORTED

Pager:
=== <noname> == TCB: e0012000 == ID: 00090002 == UTCB: bf000140/c003c100 == PRIO: 0x64 ===
UIP: 003009f0   queues: Rswl      wait : NIL_THRD:NIL_THRD   space: c0038000
USP: 0030c450   tstate: RUNNING   ready: 00094002:00094002   pdir : 00c00380
KSP: e0012790   sndhd : NIL_THRD  send : NIL_THRD:NIL_THRD   pager: roottask
total quant:    0x0 us, ts length  :       0x2710 us, curr ts: 0x2710 us
resources: 00000000 []
scheduler: roottask  send redirector: ANY_THRD  recv redirector: ANY_THRD
  partner: roottask    saved partner: NIL_THRD      saved state: RUNNING

Ping Thread:
=== <noname> == TCB: e0012800 == ID: 00094002 == UTCB: 80000040/c004f000 == PRIO: 0x64 ===
UIP: 00300974   queues: Rswl      wait : NIL_THRD:NIL_THRD   space: c004a000
USP: 00308450   tstate: RUNNING   ready: 00090002:00090002   pdir : 00c004a0
KSP: e0012f90   sndhd : NIL_THRD  send : NIL_THRD:NIL_THRD   pager: 00090002
total quant:    0x0 us, ts length  :       0x2710 us, curr ts: 0x2710 us
resources: 00000000 []
scheduler: roottask  send redirector: ANY_THRD  recv redirector: ANY_THRD
  partner: 00090002    saved partner: NIL_THRD      saved state: RUNNING


Terminal Output if you just let it run:
Testing Syscalls:
Switching to testing_thread...>> KD# YIELD
IP: 0x003016b4, MSR: 0x0002d032
> go
done.
>> KD# THREADSWITCH
IP: 0x003016f0, MSR: 0x0002d032
> go

It should at least print parts of the string "testing_thread started\n". If roottask donates its timeslice, the ping thread should at least run for one time slice until it's ousted by roottask again during scheduling.

While writing this I came up with the idea why it might not work: 
-> After time slice donation the processor wants to execute the first instruction of the ping thread.
-> This creates a page fault, because the page with the code is not yet in the threads address space.
-> For some reason the pager doesn't answer. Why?
-> The scheduler replaces ping thread with roottask again.

Well, there are still some gaps in my knowledge, but maybe someone could fill them?!

Thanks,

Martin.


-----Ursprüngliche Nachricht-----
Von: Ben Leslie [mailto:[email protected]] 
Gesendet: Donnerstag, 15. Februar 2007 21:53
An: Christian, Martin, OPEE45
Cc: [email protected]; [email protected]
Betreff: Re: L4_ThreadSwitch behaviour

On Thu Feb 15, 2007 at 17:27:41 +0100, Christian, Martin, OPEE45 wrote:
>My question is related to both L4Ka::Pistachio and
>NICTA::Pistachio-embedded, thus I'm mailing to both lists.
>
>Consider the following test cases:
>
>Case A
>======
>1. The root thread creates a new thread in a new address space (AS):
>   L4_ThreadControl( ping_tid, ping_tid, master_tid, L4_nilthread,
>                     L4_anythread, L4_anythread, NOUTCB )
>   L4_SpaceControl( ping_tid, 0, kip_area, utcb_area, &control )
>   L4_ThreadControl( ping_tid, ping_tid, master_tid, pager_tid,
>                     L4_anythread, L4_anythread, UTCB(0) )
>   L4_Start( ping_tid, (L4_Word_t)ping_stack + sizeof(ping_stack) - 32,
>             START_ADDR(testing_thread) )
>
>2. The root thread "refills" it's time slice (maybe that's bogus, but it
>is meant to ensure a full time slice is donated): L4_Yield();
>
>3. The root thread donates the rest of it's time slice to the new
>thread:
>   L4_ThreadSwitch( ping_tid );
>
>Case B
>======
>1. The root thread creates a new thread in a new AS
>2. The root thread waits for a startup IPC from the new thread (of
>course, the new thread has to be altered to send such an IPC)
>3. The root thread "refills" it's time slice
>4. The root thread donates the rest of it's time slice to the new thread
>
>Problem:
>Case A won't work, but Case B does. For Case A the new thread won't run,
>even though it's active and in the ready queue. The only difference is
>that in Case B the pages which hold the code are already mapped in the
>new threads AS.
>
>I think this is a generic issue, however I'm working with a "homemade"
>PowerPC Version of NICTA::Pistachio-embedded based on the Karlsruhe
>version.
>
>Questions:
>1.) Why does Case A fail (or at least don't do anything)?
>2.) Is there are difference between the semantics used in
>L4Ka::Pistachio and NICTA::Pistachio-embedded (or between X2 and N1)?
>
>Any opinions, experiences, fairy tales would be appreciated! :-)

OK, some guesses:

1/ What are the relative priorities of the thread in both cases?

2/ What is the pager doing in case A?

3/ What is the exact state of ping thread in case A (e.g: break into kdb
and dump thread state)

Cheers,

Benno
pingpong.cc (application/octet-stream, 11.6 KB) - not displayed
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.