-
Notifications
You must be signed in to change notification settings - Fork 3
System API
It seems hard and even impossible to have fully asynchronous system API on widespread operating systems such as Linux. Asynchronous calls can be emulated using one thread per call, but threads are expensive.
Waiting for this problem to be properly solved, we will design an asynchronous and OS independent API, interacting with the OS through a proxy. The proxy communicates with the application using a pipe, and tries to be as less blocking as possible.
We describe here a simple API which will be used to start with. There is no error handling, and read/write operations are of unbounded size.
Log.Write message
File.Read file_name
TCPClientSocket.Write id message
TCPClientSocket.Close id
TCPServerSocket.Bind port
TCPServerSocket.Close id
File.Read file_name content
TCPClientSocket.Accepted id
TCPClientSocket.Read id counter content
TCPClientSocket.Written id
TCPServerSocket.Bound id
It is often necessary to know if a command finished, made an error or is just pending. For example, when you want to close a socket, you want to be sure all operations are terminated. For that, we need to add for each system call a systematic answer, upon termination or error. To associate answer to requests, an integer has to be attached to each request and is given back with the corresponding answer.
Message name | Output type | Input type | Expected inputs |
---|---|---|---|
Log | string | bool | 1 |
FileRead | string | option string | 1 |
ServerSocketBind | N | option ClientSocketId.t | any |
ClientSocketRead | ClientSocketId.t | option string | 1 |
ClientSocketWrite | ClientSocketId.t * string | bool | 1 |
ClientSocketClose | ClientSocketId.t | bool | 1 |
Time | unit | N | 1 |
- Scalable Event Multiplexing: epoll vs. kqueue: blog post comparing APIs to process events in Unix.
- Kernel Asynchronous I/O (AIO) Support for Linux : Asynchronous file handling on Linux.
- MegaPipe: A New Programming Interface for Scalable Network I/O
- Lwt: a Cooperative Thread Library
- Implémentations efficaces de la concurrence sous Windows