demikernel icon indicating copy to clipboard operation
demikernel copied to clipboard

[pdpix] API is Currently Missing a Way to Pass Through a User Context

Open BrianZill opened this issue 2 years ago • 0 comments

Current Situation

In the current API, demi_wait_any() closely resembles the "select" API from BSD Sockets, which was designed before multi-threading (or async) was common. It allows you wait on a set of queue descriptors (file descriptors) and lets you know which one had some I/O complete on it. But applications which have some state associated with that queue/file descriptor are left to their own devices when it comes to mapping that queue/file descriptor back to that state.

More recent APIs, such as Window's I/O Completion Ports, or Linux's similar io_uring, allow the user to associate a pointer-sized (user-defined) value with the descriptor or I/O request, and return that value along with the descriptor on I/O request completion. This allows applications to avoid an extra (hash table or similar) lookup to get the associated state on every I/O call. It would be nice if our API had similar functionality.

Proposed Solution

Add a way to associate an opaque (to the system) value (large enough to hold a pointer) with a queue descriptor or even a specific I/O request. And include that value in the queue result that is returned by demi_wait_any().

BrianZill avatar Nov 28 '22 20:11 BrianZill