lunatik icon indicating copy to clipboard operation
lunatik copied to clipboard

example usage and documentation of `mailbox` module

Open sav opened this issue 1 year ago • 5 comments

provide an example and documentation of the mailbox module (lib/mailbox.lua).

sav avatar Sep 03 '24 11:09 sav

I think we can adapt echod example to use it

lneto avatar Sep 04 '24 23:09 lneto

actually, I think it's a good opportunity to apply mailbox to systrack example and change luaprobe to .sleep = false, splitting systrack in two separate runtimes (one for the probes and another to the chardev).. perhaps this could fix its termination.. (it's hanging.. by bet is a deadlock between driver and probe)..

lneto avatar Sep 05 '24 11:09 lneto

@glk0 btw, are you still interested to tackle this? https://github.com/luainkernel/lunatik/issues/96#issuecomment-1993009894 If so, I can help you on using mailbox to implement this separation..

lneto avatar Sep 05 '24 11:09 lneto

basically, we would need to move the driver code to something like systrack/driver.lua and the probes to systrack/probe.lua, than we should create a mailbox and return its queue in a function returned by probe.lua, e.g.,

-- probe.lua
...
local mbox = mailbox.outbox(size)

local function attacher()
  return mbox.queue
end

return mbox

then, we can create a runtime for probes in the driver and resume it to receive its mailbox, e.g.,

-- driver.lua
...
local probe = lunatik.runtime("systrack/probe", false)
local mbox = mailbox.inbox(probe:resume())

then, we can poll the mbox in the driver.. similarly to https://github.com/ring0networks/dome/blob/master/daemon.lua#L41

lneto avatar Sep 05 '24 12:09 lneto

@glk0 btw, are you still interested to tackle this? https://github.com/luainkernel/lunatik/issues/96#issuecomment-1993009894 If so, I can help you on using mailbox to implement this separation..

Yeah. I'll get back to you in a few days about it.

glk0 avatar Sep 05 '24 15:09 glk0