Hi Frank,
to fire a signal at the receiver for one time. The unexpected outcome is that it looks as if the receiver gets the signal twice.
This is the implementation in /main()/: Signal_receiver s_rcvr; Signal_context ct; Receiver *ser_rx = new (env()->heap()) Receiver(s_rcvr, srv.transmit); Signal_context_capability send_cap = s_rcvr.manage(&ct); Signal_transmitter tx(send_cap); tx.submit();
I assume that you start executing the receiver thread by calling 'Thread_base::start()' in the receiver's constructor? If this is the case, you have a race condition. The receiver thread is executed right before you register the signal context at the signal receiver 's_rcvr'. You can fix this by starting the receiver thread after calling 's_rcvr.manage':
In the 'Receiver' class:
class Receiver : Thread<STACK_SIZE> { ... + using Thread_base::start; ... };
In your main function:
Receiver *ser_rx = new (env()->heap()) Receiver(s_rcvr, srv.transmit); Signal_context_capability send_cap = s_rcvr.manage(&ct); + ser_rx->start(); Signal_transmitter tx(send_cap);
BTW, if your code relies on the correct number of signals (that is, not just using signals as a wake-up mechanism), you need to take the value 'signal.num()' into account. If signals are batched, 'num' may be higher than one. In you current error case, the 'num' value returned by the first call of 'wait_for_signal' was indeed zero, indicating that is is no valid signal.
Signal signal = _receiver.wait_for_signal(); + /* evaluate signal.num() */ + ...
Regards Norman