Changeset 0809c4e for doc/theses/thierry_delisle_PhD/thesis/text/io.tex
- Timestamp:
- Jul 23, 2022, 5:33:57 PM (2 years ago)
- Branches:
- ADT, ast-experimental, master, pthread-emulation, qualifiedEnum
- Children:
- c4072d8e
- Parents:
- b9e2b87
- git-author:
- Peter A. Buhr <pabuhr@…> (07/23/22 17:32:58)
- git-committer:
- Peter A. Buhr <pabuhr@…> (07/23/22 17:33:57)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/thierry_delisle_PhD/thesis/text/io.tex
rb9e2b87 r0809c4e 455 455 The following sections discuss some useful options using @read@ as an example. 456 456 The standard Linux interface for C is : 457 \begin{ lstlisting}457 \begin{cfa} 458 458 ssize_t read(int fd, void *buf, size_t count); 459 \end{ lstlisting}459 \end{cfa} 460 460 461 461 \subsection{Replacement} … … 471 471 Another interface option is to offer an interface different in name only. 472 472 For example: 473 \begin{ lstlisting}473 \begin{cfa} 474 474 ssize_t cfa_read(int fd, void *buf, size_t count); 475 \end{ lstlisting}475 \end{cfa} 476 476 This approach is feasible and still familiar to C programmers. 477 477 It comes with the caveat that any code attempting to use it must be recompiled, which is a problem considering the amount of existing legacy C binaries. … … 481 481 \subsection{Asynchronous Extension} 482 482 A fairly traditional way of providing asynchronous interactions is using a future mechanism~\cite{multilisp}, \eg: 483 \begin{ lstlisting}483 \begin{cfa} 484 484 future(ssize_t) read(int fd, void *buf, size_t count); 485 \end{ lstlisting}485 \end{cfa} 486 486 where the generic @future@ is fulfilled when the read completes and it contains the number of bytes read, which may be less than the number of bytes requested. 487 487 The data read is placed in @buf@. … … 489 489 Hence, the buffer cannot be reused until the operation completes but the synchronization does not cover the buffer. 490 490 A classical asynchronous API is: 491 \begin{ lstlisting}491 \begin{cfa} 492 492 future([ssize_t, void *]) read(int fd, size_t count); 493 \end{ lstlisting}493 \end{cfa} 494 494 where the future tuple covers the components that require synchronization. 495 495 However, this interface immediately introduces memory lifetime challenges since the call must effectively allocate a buffer to be returned. … … 498 498 \subsection{Direct \lstinline{io_uring} Interface} 499 499 The last interface directly exposes the underlying @io_uring@ interface, \eg: 500 \begin{ lstlisting}500 \begin{cfa} 501 501 array(SQE, want) cfa_io_allocate(int want); 502 502 void cfa_io_submit( const array(SQE, have) & ); 503 \end{ lstlisting}503 \end{cfa} 504 504 where the generic @array@ contains an array of SQEs with a size that may be less than the request. 505 505 This offers more flexibility to users wanting to fully utilize all of the @io_uring@ features.
Note: See TracChangeset
for help on using the changeset viewer.