lightning
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Lightning] Code patching, context switching


From: Sandro Magi
Subject: [Lightning] Code patching, context switching
Date: Wed, 20 Feb 2008 00:26:12 -0500

I want to use Lightning for user-level context switching, similar to
GNU Pth. I would expect it to be much faster since it's in assembly,
and signals aren't handled specially. This raises two questions
though:

 1. There is currently no Lightning equivalent to the x86's 'pusha'
instruction [1], correct?
 2. I assume then that I would have to save all registers by iterating
over JIT_R/V/FPR manually while generating this code. Are there any
registers or other state that aren't accessible via Lightning that
might impact context switching?

I'm also curious what it would take to save "machine contexts" in
Lightning. Some architectures provide special instructions for saving
the register file which I assume is more efficient than saving them
one by one in the above way.

Finally, since this function must be linked with some other code I
have at compile time, so I need some sort of stub to act as a
placeholder with sufficient room to patch the code later. For
instance:

/* from and to are buffers sufficiently large to hold the register file */
static void ctxt_switch(char *from, char *to) {
  from = from;
  to = to;
  from = from;
  to = to;
  ...
}

I can then take the address of ctxt_switch and pass it to Lightning as
the code buffer and patch the contents of ctxt_switch to perform an
actual context switch. The other alternative is to simply patch in a
direct jump at &ctxt_switch into my code generated elsewhere. Any
other thoughts or recommendations?

Sandro

[1] http://docs.sun.com/app/docs/doc/817-5477/6mkuavhri?a=view




reply via email to

[Prev in Thread] Current Thread [Next in Thread]