Open podhrmic opened 10 months ago
Ideally it would be the first option. From our experience at TS, we have been able to design and implement drivers without any use of blocking. I haven't looked closely at that FreeRTOS ethernet driver, but given that we've been able to go without any use of sleep()
or equivalent functionality, I'm guessing that the vTaskDelay()
is not necessary.
However, while network drivers can fit into the event driven model, I understand that there will exist systems where it is genuinely not possible. Internally at TS we have started to run into these cases, and are looking at making a small co-routine library for seL4CP. I will keep you updated on this and hopefully we have something to show soon.
Nick has been using Rust's support for async operations, so may want to comment on that, assuming you're writing the driver in Rust.
I am indeed having success using Rust's async features for this kind of thing. Here is an implementation of sleep()
:
Here is an impl sel4cp::Handler
that runs futures:
@nspin very cool! I will give it a try!
@nspin how do you think the reactor would change if you had to break out the individual components to separate PDs?
Looks like now_with_timer_driver()
would become a pp_call
to a timer component, smoltcp/server
would be the main component (so basically no change), and the virtio driver would have to be factored out (similar to what we were trying to do here). Does that match your expectation?
If so, I would be happy to refactor your example in such a way, but I could not get the server to build outside of nix - do you have a CI job or an example for that?
@nspin how do you think the reactor would change if you had to break out the individual components to separate PDs? Looks like
now_with_timer_driver()
would become app_call
to a timer component,smoltcp/server
would be the main component (so basically no change), and the virtio driver would have to be factored out (similar to what we were trying to do here). Does that match your expectation?
I've just finished doing exactly that:
Note that the virtio-net-driver component does more copying than it needs to, because the virtio-drivers
crate I'm using does not have a sufficiently low-level interface. When I move to a physical device on which we can benchmark, I'll of course strive for a performant implementation of the network driver PD, but, for now, I've just left it clunky and slow in order to be able to leverage that third party crate instead of writing my own virtio-net driver code.
If so, I would be happy to refactor your example in such a way, but I could not get the server to build outside of nix - do you have a CI job or an example for that?
I will work on a standalone demo for this code like https://github.com/GaloisInc/rust-seL4-sel4cp-demo.
I've just finished doing exactly that:
I've cleaned this up and created a new repo:
https://github.com/coliasgroup/rust-seL4-sel4cp-http-server-demo
Hello!
I am porting an existing network driver code to sel4cp, and the driver has a couple of
vTaskDelay()
calls (it is for FreeRTOS).Is there a recommended way of handling such case - e.g. I need my PD to suspend for a short time before continuing in execution?
I can think of the following options:
pp_call
to a timer to get current system time, and busy wait until the desired time elapses - rather inefficient@Ivan-Velickovic @nspin