Skip to content
clarus edited this page Oct 27, 2014 · 23 revisions

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.

Simple API

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.

Output messages

  • Log.Write message
  • File.Read file_name
  • TCPClientSocket.Write id message
  • TCPClientSocket.Close id
  • TCPServerSocket.Bind port
  • TCPServerSocket.Close id

Input messages

  • File.Read file_name content
  • TCPClientSocket.Accepted id
  • TCPClientSocket.Read id counter content
  • TCPClientSocket.Written id
  • TCPServerSocket.Bound id

Request / answer API

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

References

Clone this wiki locally