Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

delay during PD initialization and execution #39

Open
podhrmic opened this issue Aug 17, 2023 · 6 comments
Open

delay during PD initialization and execution #39

podhrmic opened this issue Aug 17, 2023 · 6 comments

Comments

@podhrmic
Copy link

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:

  1. refactor the code so it fits the event driven paradigm of sel4cp (effectively a state machine) - not practical, the state machine size could get out of hand rather quickly
  2. use pp_call to a timer to get current system time, and busy wait until the desired time elapses - rather inefficient
  3. something else?

@Ivan-Velickovic @nspin

@Ivan-Velickovic
Copy link
Collaborator

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.

@nspin
Copy link
Member

nspin commented Aug 18, 2023

@podhrmic
Copy link
Author

@nspin very cool! I will give it a try!

@podhrmic
Copy link
Author

@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
Copy link
Member

nspin commented Aug 23, 2023

@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?

I've just finished doing exactly that:

https://github.com/coliasgroup/rust-seL4/tree/d9777945ff261a40dbe35d8902377c073ad76e18/crates/examples/sel4cp/http-server

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.

@nspin
Copy link
Member

nspin commented Aug 25, 2023

I've just finished doing exactly that:

https://github.com/coliasgroup/rust-seL4/tree/d9777945ff261a40dbe35d8902377c073ad76e18/crates/examples/sel4cp/http-server

I've cleaned this up and created a new repo:

https://github.com/coliasgroup/rust-seL4-sel4cp-http-server-demo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants