l4_thread_ex_regs and suspending thread

Adam Lackorzynski adam at os.inf.tu-dresden.de
Mon Jul 18 00:46:55 CEST 2016


Hi,

On Sat Jul 16, 2016 at 11:37:20 +0300, Valery V. Sedletski wrote:
> I am now using l4v2 API with L4/Fiasco. I know that on L4 v.2 API, the
> thread is created if set eip/esp/pager/preempter to real values. And it
> seems that likewise, thread can be suspended if setting these values to
> invalid ones. But as I tried it, setting the running thread eip/esp to -1
> causes double page fault in that thread. Setting them to 0 does not change
> these values (though, in headers' comments, documented value is ~0). Setting
> pager/preempter to L4_INVALID_ID also causes double page fault. This is
> strange, as docs/comments state the converse.

So I'm looking at the late v2 version of Fiasco and I'm reading the code
such that ~0 means "don't change this value". The current/old value is
delivered back in any case. Regarding the L4_INVALID_ID, I'm reading the
code such that the pager will not be set when the target ID does not
exist, which includes L4_INVALID_ID, i.e. the thread's pager should not
be changed.
 
> So, is it possible anyhow to suspend/resume the running thread from another
> thread? I know, that the thread can be suspended if entering unconditional
> l4_ipc_wait(), but this is from the inside that thread. How could it be done
> from an outside thread?

One way is to set the thread on such a loop via ex_regs (and paying
attention to the register contents which basically means there's some
assembly code involved). Another way is to do
ex_regs(id, ~0, ~0, L4_THREAD_EX_REGS_RAISE_EXCEPTION) which will
trigger an artificial exception in the thread and have it send an
exception IPC to its pager. The pager should then just not reply to have
the thread suspended, and then reply when you want to have the thread go
on later. What makes this a bit tricky is when L4 IPC is involves which
you will cancel with ex_regs, or not, if you use the
L4_THREAD_EX_REGS_NO_CANCEL flag.




Adam
-- 
Adam                 adam at os.inf.tu-dresden.de
  Lackorzynski         http://os.inf.tu-dresden.de/~adam/



More information about the l4-hackers mailing list