Changeset fc96890 for doc/theses/thierry_delisle_PhD/thesis/text/io.tex
- Timestamp:
- Sep 13, 2022, 3:07:25 PM (20 months ago)
- Branches:
- ADT, ast-experimental, master, pthread-emulation
- Children:
- 3606fe4
- Parents:
- 1c334d1
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/thierry_delisle_PhD/thesis/text/io.tex
r1c334d1 rfc96890 53 53 Its interface lets programmers enqueue operations to be performed asynchronously by the kernel. 54 54 Completions of these operations can be communicated in various ways: either by spawning a new \gls{kthrd}, sending a Linux signal, or polling for completion of one or more operations. 55 For this work, spawning a new \gls{kthrd} is counter -productive but a related solution is discussed in Section~\ref{io:morethreads}.55 For this work, spawning a new \gls{kthrd} is counterproductive but a related solution is discussed in Section~\ref{io:morethreads}. 56 56 Using interrupt handlers can also lead to fairly complicated interactions between subsystems and has a non-trivial cost. 57 57 Leaving polling for completion, which is similar to the previous system calls. … … 100 100 101 101 \subsection{Extra Kernel Threads}\label{io:morethreads} 102 Finally, if the operating system does not offer a satisfactory form of asynchronous \io operations, an ad -hoc solution is to create a pool of \glspl{kthrd} and delegate operations to it to avoid blocking \glspl{proc}, which is a compromise for multiplexing.102 Finally, if the operating system does not offer a satisfactory form of asynchronous \io operations, an ad hoc solution is to create a pool of \glspl{kthrd} and delegate operations to it to avoid blocking \glspl{proc}, which is a compromise for multiplexing. 103 103 In the worst case, where all \ats are consistently blocking on \io, it devolves into 1-to-1 threading. 104 104 However, regardless of the frequency of \io operations, it achieves the fundamental goal of not blocking \glspl{proc} when \ats are ready to run. … … 290 290 291 291 Allocation failures need to be pushed to a routing algorithm: \ats attempting \io operations must not be directed to @io_uring@ instances without sufficient SQEs available. 292 Furthermore, the routing algorithm should block operations up -front,if none of the instances have available SQEs.292 Furthermore, the routing algorithm should block operations upfront if none of the instances have available SQEs. 293 293 294 294 Once an SQE is allocated, \ats insert the \io request information and keep track of the SQE index and the instance it belongs to. 295 295 296 Once an SQE is filled in, it is added to the submission ring buffer, an operation that is not thread -safe, and then the kernel must be notified using the @io_uring_enter@ system call.296 Once an SQE is filled in, it is added to the submission ring buffer, an operation that is not thread safe, and then the kernel must be notified using the @io_uring_enter@ system call. 297 297 The submission ring buffer is the same size as the pre-allocated SQE buffer, therefore pushing to the ring buffer cannot fail because it would mean an SQE multiple times in the ring buffer, which is undefined behaviour. 298 298 However, as mentioned, the system call itself can fail with the expectation that it can be retried once some submitted operations are complete. … … 307 307 Once the system call is done, the submitter must also free SQEs so that the allocator can reuse them. 308 308 309 Finally, the completion side is much simpler since the @io_uring@ system -call enforces a natural synchronization point.309 Finally, the completion side is much simpler since the @io_uring@ system call enforces a natural synchronization point. 310 310 Polling simply needs to regularly do the system call, go through the produced CQEs and communicate the result back to the originating \ats. 311 311 Since CQEs only own a signed 32-bit result, in addition to the copy of the @user_data@ field, all that is needed to communicate the result is a simple future~\cite{wiki:future}. … … 368 368 369 369 \paragraph{Pending Allocations} are handled by the arbiter when it has available instances and can directly hand over the instance and satisfy the request. 370 Otherwise, it must hold on to the list of threads until SQEs are made available again.370 Otherwise, it must hold on to the list of threads until SQEs are made available again. 371 371 This handling is more complex when an allocation requires multiple SQEs, since the arbiter must make a decision between satisfying requests in FIFO ordering or for fewer SQEs. 372 372 … … 383 383 The last important part of the \io subsystem is its interface. 384 384 Multiple approaches can be offered to programmers, each with advantages and disadvantages. 385 The new \io subsystem can replace the C runtime API or extend it, and in the lat er case, the interface can go from very similar to vastly different.385 The new \io subsystem can replace the C runtime API or extend it, and in the latter case, the interface can go from very similar to vastly different. 386 386 The following sections discuss some useful options using @read@ as an example. 387 The standard Linux interface for C is 387 The standard Linux interface for C is: 388 388 \begin{cfa} 389 389 ssize_t read(int fd, void *buf, size_t count); … … 394 394 The goal is to convince the compiler and linker to replace any calls to @read@ to direct them to the \CFA implementation instead of glibc's. 395 395 This rerouting has the advantage of working transparently and supporting existing binaries without needing recompilation. 396 It also offers a, presumably, well -known and familiar API that C programmers can simply continue to work with.396 It also offers a, presumably, well known and familiar API that C programmers can simply continue to work with. 397 397 However, this approach also entails a plethora of subtle technical challenges, which generally boils down to making a perfect replacement. 398 398 If the \CFA interface replaces only \emph{some} of the calls to glibc, then this can easily lead to esoteric concurrency bugs.
Note: See TracChangeset
for help on using the changeset viewer.