-
Notifications
You must be signed in to change notification settings - Fork 109
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
libtock_platform
static
asynchronous Read-Only Allow API Design
#334
Comments
Do we have to have fn lease_ro_buffer<'a>(buffer: &'a [u8]) -> ReadOnlyLease<'a> {
// allow with kernel and create Lease object
}
impl Drop on ReadOnlyLease<'_> {
fn drop(&self) {
// unallow from kernel
}
} |
I don't see how we can avoid requiring a fn main() {
initialize_things();
start_things();
loop {
Syscalls::yield_wait();
}
} After each |
There are multiple ways to solve this problem. We could build the API on Until now, I haven't run into any such tradeoffs for supporting highly-asynchronous apps in However, there has yet to be a highly-asynchronous app built on top of What that means is that I don't have the data I need to design this API correctly. I certainly don't want to put a lot of work into a highly-asynchronous API if it will never be used. At this point, I think I will focus on APIs that look synchronous but support some mild asynchrony (to cover the "wait for an event with some form of cancellation" use case). For now, I will leave the |
libtock_platform
asynchronous Read-Only Allow API Designlibtock_platform
static
asynchronous Read-Only Allow API Design
Closing this based on my explanation at #334 (comment). We'll look at supporting a higher degree of asynchrony if a use case appears that needs it. The APIs I designed at #341 and have merged into |
353: Remove `libtock_platform`'s asynchronous API traits. r=jrvanwhy a=jrvanwhy These traits were designed to support a style of code I was calling "`'static` asynchrony", where upcalls are not tied to lifetimes and execution can potentially jump between unexpected modules. However [we never implemented `'static` asynchrony](#334), and I'm not sure it will ever be implemented. Because I don't expect these traits to ever be used, I think they should be removed from `libtock_platform`. Co-authored-by: Johnathan Van Why <[email protected]>
I'm having some trouble designing a sound asynchronous API for the Read-Only Allow system call, and could use some help.
Here are what I believe to be the requirements for the API:
'static
buffers).The obvious API is (omitting driver number and buffer number for simplicity):
However, this fails either requirement 1 or requirement 5. There is no way to write a
RefCell
-like type that provides access to a buffer with'static
lifetime that provides a safe, sound API. You can write something likeTakeCell
with the following API:except this has two problems:
&'static [u8]
and callreturn_ref
on one copy while holding the other (leading to UB whenreturn_mut
is called).return_ref
would need to fail if the reference doesn't match the entire buffer.Problem 1 can be solved in an awkward manner by introducing a new type that wraps a
&'static [u8]
but is not copyable, but I'm having trouble solving problem 2.The best API I've thought of so far (and I need to think about it more to be sure it is sound) is:
Note that this API does not return the previous buffer! Instead, code should call
unallow
before re-using a mutable buffer. The biggest drawback, though, is the ergonomics of using[Cell<u8>]
, which I've been trying to avoid since Tock 2.0 started...Does anyone have a better idea?
The text was updated successfully, but these errors were encountered: