- Timestamp:
- Oct 30, 2020, 12:35:59 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- f7e4f8e8
- Parents:
- 223a633
- Location:
- doc/theses/thierry_delisle_PhD/thesis
- Files:
-
- 2 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/thierry_delisle_PhD/thesis/Makefile
r223a633 rb9537e6 15 15 front \ 16 16 intro \ 17 existing \ 17 18 runtime \ 18 19 core \ … … 27 28 base \ 28 29 empty \ 30 system \ 29 31 } 30 32 … … 37 39 ## Define the documents that need to be made. 38 40 all: thesis.pdf 39 thesis.pdf: ${TEXTS} ${FIGURES} ${PICTURES} glossary.tex 41 thesis.pdf: ${TEXTS} ${FIGURES} ${PICTURES} glossary.tex local.bib 40 42 41 43 DOCUMENT = thesis.pdf -
doc/theses/thierry_delisle_PhD/thesis/fig/system.fig
r223a633 rb9537e6 1 #FIG 3.2 Produced by xfig version 3.2. 5c1 #FIG 3.2 Produced by xfig version 3.2.7b 2 2 Landscape 3 3 Center … … 36 36 1 3 0 1 -1 -1 0 0 20 0.000 1 0.0000 4500 3600 15 15 4500 3600 4515 3615 37 37 -6 38 6 3225 4125 4650 442539 6 4350 4200 4650 435040 1 3 0 1 -1 -1 0 0 20 0.000 1 0.0000 4425 4275 15 15 4425 4275 4440 429041 1 3 0 1 -1 -1 0 0 20 0.000 1 0.0000 4500 4275 15 15 4500 4275 4515 429042 1 3 0 1 -1 -1 0 0 20 0.000 1 0.0000 4575 4275 15 15 4575 4275 4590 429043 -644 1 1 0 1 -1 -1 0 0 -1 0.000 1 0.0000 3450 4275 225 150 3450 4275 3675 442545 1 1 0 1 -1 -1 0 0 -1 0.000 1 0.0000 4050 4275 225 150 4050 4275 4275 442546 -647 6 6675 4125 7500 442548 6 7200 4200 7500 435049 1 3 0 1 -1 -1 0 0 20 0.000 1 0.0000 7275 4275 15 15 7275 4275 7290 429050 1 3 0 1 -1 -1 0 0 20 0.000 1 0.0000 7350 4275 15 15 7350 4275 7365 429051 1 3 0 1 -1 -1 0 0 20 0.000 1 0.0000 7425 4275 15 15 7425 4275 7440 429052 -653 1 1 0 1 -1 -1 0 0 -1 0.000 1 0.0000 6900 4275 225 150 6900 4275 7125 442554 -655 38 6 6675 3525 8025 3975 56 39 2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2 … … 79 62 1 3 0 1 -1 -1 0 0 -1 0.000 1 0.0000 3975 2850 150 150 3975 2850 4125 2850 80 63 1 3 0 1 -1 -1 0 0 -1 0.000 1 0.0000 7200 2775 150 150 7200 2775 7350 2775 81 1 3 0 1 0 0 0 0 0 0.000 1 0.0000 2250 4830 30 30 2250 4830 2280 48 6064 1 3 0 1 0 0 0 0 0 0.000 1 0.0000 2250 4830 30 30 2250 4830 2280 4830 82 65 1 3 0 1 0 0 0 0 0 0.000 1 0.0000 7200 2775 30 30 7200 2775 7230 2805 83 66 1 3 0 1 -1 -1 0 0 -1 0.000 1 0.0000 3525 3600 150 150 3525 3600 3675 3600 84 1 3 0 1 -1 -1 0 0 -1 0.000 1 0.0000 3875 4800 100 100 3875 4800 3975 4800 85 1 1 0 1 -1 -1 0 0 -1 0.000 1 0.0000 4650 4800 150 75 4650 4800 4800 4875 67 1 3 0 1 -1 -1 0 0 -1 0.000 1 0.0000 4625 4838 100 100 4625 4838 4725 4838 86 68 2 2 0 1 -1 -1 0 0 -1 0.000 0 0 0 0 0 5 87 69 2400 4200 2400 3750 1950 3750 1950 4200 2400 4200 … … 153 135 1 1 1.00 45.00 90.00 154 136 7875 3750 7875 2325 7200 2325 7200 2550 137 2 2 1 1 -1 -1 0 0 -1 3.000 0 0 0 0 0 5 138 6975 4950 6750 4950 6750 4725 6975 4725 6975 4950 155 139 2 2 0 1 -1 -1 0 0 -1 0.000 0 0 0 0 0 5 156 140 5850 4950 5850 4725 5625 4725 5625 4950 5850 4950 157 2 2 1 1 -1 -1 0 0 -1 3.000 0 0 0 0 0 5 158 6975 4950 6750 4950 6750 4725 6975 4725 6975 4950 159 4 1 -1 0 0 0 10 0.0000 2 105 720 5550 4425 Processors\001 160 4 1 -1 0 0 0 10 0.0000 2 120 1005 4200 3225 Blocked Tasks\001 161 4 1 -1 0 0 0 10 0.0000 2 150 870 4200 3975 Ready Tasks\001 162 4 1 -1 0 0 0 10 0.0000 2 135 1095 7350 1725 Other Cluster(s)\001 163 4 1 -1 0 0 0 10 0.0000 2 105 840 4650 1725 User Cluster\001 164 4 1 -1 0 0 0 10 0.0000 2 150 615 2175 3675 Manager\001 165 4 1 -1 0 0 0 10 0.0000 2 105 990 2175 3525 Discrete-event\001 166 4 1 -1 0 0 0 10 0.0000 2 135 795 2175 4350 preemption\001 167 4 0 -1 0 0 0 10 0.0000 2 150 1290 2325 4875 generator/coroutine\001 168 4 0 -1 0 0 0 10 0.0000 2 120 270 4050 4875 task\001 169 4 0 -1 0 0 0 10 0.0000 2 105 450 7050 4875 cluster\001 170 4 0 -1 0 0 0 10 0.0000 2 105 660 5925 4875 processor\001 171 4 0 -1 0 0 0 10 0.0000 2 105 555 4875 4875 monitor\001 141 4 1 -1 0 0 0 10 0.0000 2 135 900 5550 4425 Processors\001 142 4 1 -1 0 0 0 10 0.0000 2 165 1170 4200 3975 Ready Threads\001 143 4 1 -1 0 0 0 10 0.0000 2 165 1440 7350 1725 Other Cluster(s)\001 144 4 1 -1 0 0 0 10 0.0000 2 135 1080 4650 1725 User Cluster\001 145 4 1 -1 0 0 0 10 0.0000 2 165 630 2175 3675 Manager\001 146 4 1 -1 0 0 0 10 0.0000 2 135 1260 2175 3525 Discrete-event\001 147 4 1 -1 0 0 0 10 0.0000 2 150 900 2175 4350 preemption\001 148 4 0 -1 0 0 0 10 0.0000 2 135 630 7050 4875 cluster\001 149 4 1 -1 0 0 0 10 0.0000 2 135 1350 4200 3225 Blocked Threads\001 150 4 0 -1 0 0 0 10 0.0000 2 135 540 4800 4875 thread\001 151 4 0 -1 0 0 0 10 0.0000 2 120 810 5925 4875 processor\001 152 4 0 -1 0 0 0 10 0.0000 2 165 1710 2325 4875 generator/coroutine\001 -
doc/theses/thierry_delisle_PhD/thesis/glossary.tex
r223a633 rb9537e6 1 1 \makeglossaries 2 3 % ---------------------------------- 4 % Acronyms 5 \newacronym{api}{API}{Application Programming Interface} 6 \newacronym{fifo}{FIFO}{First-In, First-Out} 7 \newacronym{io}{I/O}{Input and Output} 8 \newacronym{numa}{NUMA}{Non-Uniform Memory Access} 9 \newacronym{raii}{RAII}{Resource Acquisition Is Initialization} 10 \newacronym{tls}{TLS}{Thread Local Storage} 11 12 % ---------------------------------- 13 % Definitions 14 15 \longnewglossaryentry{thrd} 16 {name={thread}} 17 { 18 Threads created and managed inside user-space. Each thread has its own stack and its own thread of execution. User-level threads are invisible to the underlying operating system. 19 20 \textit{Synonyms : User threads, Lightweight threads, Green threads, Virtual threads, Tasks.} 21 } 22 23 \longnewglossaryentry{proc} 24 {name={processor}} 25 { 26 27 } 28 29 \longnewglossaryentry{rQ} 30 {name={ready-queue}} 31 { 32 33 } 34 35 \longnewglossaryentry{uthrding} 36 {name={user-level threading}} 37 { 38 39 40 \textit{Synonyms : User threads, Lightweight threads, Green threads, Virtual threads, Tasks.} 41 } 42 43 % ---------------------------------- 2 44 3 45 \longnewglossaryentry{hthrd} 4 46 {name={hardware thread}} 5 47 { 6 Threads representing the underlying hardware directly .48 Threads representing the underlying hardware directly, \eg the CPU core, or hyper-thread if the hardware supports multiple threads of execution per core. The number of hardware threads is considered to be always fixed to a specific number determined by the hardware. 7 49 8 \textit{Synonyms : User threads, Lightweight threads, Green threads, Virtual threads, Tasks.} 9 } 10 11 \longnewglossaryentry{thrd} 12 {name={threads}} 13 { 14 Threads created and managed inside user-space. Each thread has its own stack and its own thread of execution. User-level threads are invisible to the underlying operating system. 15 16 \textit{Synonyms : User threads, Lightweight threads, Green threads, Virtual threads, Tasks.} 50 \textit{Synonyms : } 17 51 } 18 52 … … 57 91 } 58 92 59 \longnewglossaryentry{proc}60 {name={virtual processor}}61 {62 93 63 }64 65 \longnewglossaryentry{Q}66 {name={work-queue}}67 {68 69 }70 94 71 95 \longnewglossaryentry{at} … … 131 155 } 132 156 133 134 \newacronym{tls}{TLS}{Thread Local Storage}135 \newacronym{api}{API}{Application Program Interface}136 \newacronym{raii}{RAII}{Resource Acquisition Is Initialization}137 \newacronym{numa}{NUMA}{Non-Uniform Memory Access} -
doc/theses/thierry_delisle_PhD/thesis/text/core.tex
r223a633 rb9537e6 1 1 \chapter{Scheduling Core}\label{core} 2 2 3 This chapter addresses the need of scheduling on a somewhat ideal scenario 3 Before discussing scheduling in general, where it is important to address systems that are changing states, this document discusses scheduling in a somewhat ideal scenerio, where the system has reached a steady state. For this purpose, a steady state is loosely defined as a state where there are always \glspl{thrd} ready to run and but the system has the ressources necessary to accomplish the work. In short, the system is neither overloaded or underloaded. 4 4 5 \section{Existing Schedulers} 6 \subsection{Feedback Scheduling} 5 I believe it is important to discuss the steady state first because it is the easiest case to handle and, relatedly, the case in which the best performance is to be expected. As such, when the system is either overloaded or underloaded, a common approach is to try to adapt the system to the new load and return to the steady state. Flaws in the scheduling in the steady state tend therefore to be pervasive in all states. 7 6 8 \subsection{Priority Scheduling}\label{priority} 7 \section{Design Goals} 8 As with most of the design decisions behind \CFA, the main goal is to match the expectation of the programmer, according to their probable mental model. To match these expectations, the design must offer the programmers sufficient guarantees so that, as long as the programmer respects the mental model, the system will also respect this model. 9 9 10 \subsection{Work Stealing} 10 For threading, a simple and common mental model is the ``Ideal multi-tasking CPU'' : 11 12 \begin{displayquote}[Linux CFS\cit{https://www.kernel.org/doc/Documentation/scheduler/sched-design-CFS.txt}] 13 {[The]} ``Ideal multi-tasking CPU'' is a (non-existent :-)) CPU that has 100\% physical power and which can run each task at precise equal speed, in parallel, each at [an equal fraction of the] speed. For example: if there are 2 tasks running, then it runs each at 50\% physical power --- i.e., actually in parallel. 14 \end{displayquote} 15 16 Applied to threads, this model states that every ready \gls{thrd} immediately runs in parallel with all other ready \glspl{thrd}. While a strict implementation of this model is not feasible, programmers still have expectations about scheduling that come from this model. 17 18 In general, the expectation at the center of this model is that ready \glspl{thrd} do not interfere with eachother but simply share the hardware. This makes it easier to reason about threading because ready \glspl{thrd} can be taken in isolation and the effect of the scheduler can be virtually ignored. This expectation of \gls{thrd} independence means the scheduler is expected to offer 2 guarantees: 19 \begin{enumerate} 20 \item A fairness guarantee: a \gls{thrd} that is ready to run will not be prevented to do so by another thread. 21 \item A performance guarantee: a \gls{thrd} that wants to start or stop running will not be slowed down by other threads wanting to do the same. 22 \end{enumerate} 23 24 It is important to note that these guarantees are expected only up to a point. \Glspl{thrd} that are ready to run should not be prevented to do so, but they still need to share a limited amount of hardware. Therefore, the guarantee is considered respected if a \gls{thrd} gets access to a \emph{fair share} of the hardware, even if that share is very small. 25 26 Similarly the performance guarantee, the lack of interferance between threads is only relevant op to a point. Ideally the cost of running and blocking would be constant regardless of contention, but the guarantee is considered satisfied if the cost is not \emph{too high} with or without contention. How much is an acceptable cost is obviously highly variable. For this document the performance experimentation will attempt to show that the cost of scheduling is not a major factor in application performance. This demonstration can be made by comparing application built in \CFA to applications built with other languages or other models. If the performance of an application built in \CFA is not meaningfully different than one built with a different runtime, then the scheduler has a negigeable impact on performance, \ie its impact can be ignored. Recall from a few paragraphs ago that the expectation of programmers is that the impact of the scheduler can be ignored. Therefore, if the cost of scheduling is not a significant portion of the runtime of several different application, I will consider the guarantee achieved. 27 28 \todo{This paragraph should be moved later} 29 % The next step is then to decide what is considered a \emph{fair share}, \ie what metric is used to measure fairness. Since \CFA is intended to allow numerous short lived threads, I decided to avoid total CPU time as the measure of fairness. Total CPU time inherently favors new \glspl{thrd} over older ones which isn't necessarily a good thing. Instead, fairness is measured in terms of opportunities to run. This metric is more appropriate for a mix of short and long lived \glspl{thrd}. 11 30 12 31 \section{Design} 13 While avoiding the pitfalls of Feedback Scheduling is fairly easy, scheduling does not innately require feedback, avoiding prioritization of \glspl{thrd} is more difficult because of implicitly priorities, see Subsection~\ref{priority}. 32 While avoiding the pitfalls of Feedback Scheduling is fairly easy, scheduling does not innately require feedback, avoiding prioritization of \glspl{thrd} is more difficult because of implicitly priorities, see Subsection~\ref{priority}. A strictly \glsxtrshort{fifo} rea 14 33 15 34 \subsection{Sharding} … … 19 38 \input{base.pstex_t} 20 39 \end{center} 21 \caption{Relaxed FIFO list at the base of the scheduler: an array of strictly FIFO lists. 22 The timestamp is in all nodes and cell arrays.} 40 \caption{Relaxed FIFO list} 23 41 \label{fig:base} 42 List at the base of the scheduler: an array of strictly FIFO lists. 43 The timestamp is in all nodes and cell arrays. 24 44 \end{figure} 25 45 … … 28 48 Indeed, if the number of \glspl{thrd} does not far exceed the number of queues, it is probable that several of these queues are empty. 29 49 Figure~\ref{fig:empty} shows an example with 2 \glspl{thrd} running on 8 queues, where the chances of getting an empty queue is 75\% per pick, meaning two random picks yield a \gls{thrd} only half the time. 30 This can lead to performance problems since picks that do not yield a \gls{thrd} are not useful and do not necessarily help make more informed guesses.31 32 Solutions to this problem can take many forms, but they ultimately all have to encode where the threads are in some form. My results show that the density and locality of this encoding is generally the dominating factor in these scheme.33 34 \paragraph{Dense Information}35 36 37 38 50 39 51 … … 42 54 \input{empty.pstex_t} 43 55 \end{center} 44 \caption{``More empty'' state of the queue: the array contains many empty cells.}56 \caption{``More empty'' Relaxed FIFO list} 45 57 \label{fig:empty} 58 Emptier state of the queue: the array contains many empty cells, that is strictly FIFO lists containing no elements. 46 59 \end{figure} 60 61 This can lead to performance problems since picks that do not yield a \gls{thrd} are not useful and do not necessarily help make more informed guesses. 62 63 Solutions to this problem can take many forms, but they ultimately all have to encode where the threads are in some form. My results show that the density and locality of this encoding is generally the dominating factor in these scheme. 64 65 \paragraph{Dense Information} -
doc/theses/thierry_delisle_PhD/thesis/text/front.tex
r223a633 rb9537e6 184 184 \phantomsection % allows hyperref to link to the correct page 185 185 186 % TODOs and missing citations 187 % ----------------------------- 186 188 \listofcits 187 189 \listoftodos 190 \cleardoublepage 191 \phantomsection % allows hyperref to link to the correct page 188 192 189 193 -
doc/theses/thierry_delisle_PhD/thesis/text/intro.tex
r223a633 rb9537e6 1 \chapter{Introduction} 1 \chapter*{Introduction}\label{intro} 2 \todo{A proper intro} 3 4 The C programming language\cit{C} 5 6 The \CFA programming language\cite{cfa:frontpage,cfa:typesystem} which extends the C programming language to add modern safety and productiviy features while maintaining backwards compatibility. Among it's productiviy features, \CFA introduces support for threading\cit{CFA Concurrency}, to allow programmers to write modern concurrent and parallel programming. 7 While previous work on the concurrent package of \CFA focused on features and interfaces, this thesis focuses on performance, introducing \glsxtrshort{api} changes only when required by performance considerations. More specifically, this thesis concentrates on scheduling and \glsxtrshort{io}. Prior to this work, the \CFA runtime used a strictly \glsxtrshort{fifo} \gls{rQ}. 8 9 This work exclusively concentrates on Linux as it's operating system since the existing \CFA runtime and compiler does not already support other operating systems. Furthermore, as \CFA is yet to be released, supporting version of Linux older that the latest version is not a goal of this work. -
doc/theses/thierry_delisle_PhD/thesis/text/io.tex
r223a633 rb9537e6 1 \chapter{I/O} 1 \chapter{User Level \glsxtrshort{io}} 2 As mentionned in Section~\ref{prev:io}, User-Level \glsxtrshort{io} requires multiplexing the \glsxtrshort{io} operations of many \glspl{thrd} onto fewer \glspl{proc} using asynchronous \glsxtrshort{io} operations. Various operating systems offer various forms of asynchronous operations and as mentioned in Chapter~\ref{intro}, this work is exclusively focuesd on Linux. 2 3 3 4 \section{Existing options} 5 Since \glsxtrshort{io} operations are generally handled by the 4 6 5 7 \subsection{\texttt{epoll}, \texttt{poll} and \texttt{select}} … … 7 9 \subsection{Linux's AIO} 8 10 11 12 13 \begin{displayquote} 14 AIO is a horrible ad-hoc design, with the main excuse being "other, 15 less gifted people, made that design, and we are implementing it for 16 compatibility because database people - who seldom have any shred of 17 taste - actually use it". 18 19 But AIO was always really really ugly. 20 21 \begin{flushright} 22 -- Linus Torvalds\cit{https://lwn.net/Articles/671657/} 23 \end{flushright} 24 \end{displayquote} 25 26 Interestingly, in this e-mail answer, Linus goes on to describe 27 ``a true \textit{asynchronous system call} interface'' 28 that does 29 ``[an] arbitrary system call X with arguments A, B, C, D asynchronously using a kernel thread'' 30 in 31 ``some kind of arbitrary \textit{queue up asynchronous system call} model''. 32 This description is actually quite close to the interface of the interface described in the next section. 33 9 34 \subsection{\texttt{io\_uring}} 35 A very recent addition to Linux, \texttt{io\_uring}\cit{io\_uring} is a framework that aims to solve many of the problems listed with the above mentioned solutions. 10 36 11 \subsection{Extra Kernel Threads} 37 \subsection{Extra Kernel Threads}\label{io:morethreads} 38 Finally, if the operating system does not offer any satisfying forms of asynchronous \glsxtrshort{io} operations, a solution is to fake it by creating a pool of \glspl{kthrd} and delegating operations to them in order to avoid blocking \glspl{proc}. 12 39 13 40 \subsection{Discussion} -
doc/theses/thierry_delisle_PhD/thesis/text/practice.tex
r223a633 rb9537e6 2 2 The scheduling algorithm discribed in Chapter~\ref{core} addresses scheduling in a stable state. 3 3 However, it does not address problems that occur when the system changes state. 4 Indeed the \CFA runtime, supports expanding and shrinking 5 6 the number of KTHREAD\_place 7 8 , both manually and, to some extent automatically. 4 Indeed the \CFA runtime, supports expanding and shrinking the number of KTHREAD\_place \todo{add kthrd to glossary}, both manually and, to some extent automatically. 9 5 This entails that the scheduling algorithm must support these transitions. 10 6 -
doc/theses/thierry_delisle_PhD/thesis/text/runtime.tex
r223a633 rb9537e6 1 1 \chapter{\CFA Runtime} 2 This chapter offers an overview of the capabilities of the \CFA runtime prior to this work. 2 3 3 \section{M:N Threading} 4 Threading in \CFA offers is based on \Gls{uthrding}, where \glspl{thrd} are the representation of a unit of work. As such, \CFA programmers should expect these units to be fairly inexpensive, that is: programmers should be able to create a large number of \glspl{thrd} and switch between \glspl{thrd} liberally without many concerns for performance. 5 6 \section{M:N Threading}\label{prev:model} 7 8 C traditionnally uses a 1:1 threading model. This model uses \glspl{kthrd} to achive parallelism and concurrency. In this model, every thread of computation maps to an object in the kernel. The kernel then has the responsibility of managing these threads, \eg creating, scheduling, blocking. This also entails that the kernel has a perfect view of every thread executing in the system\footnote{This is not completly true due to primitives like \texttt{futex}es, which have a significant portion of their logic in user space.}. 9 10 By contrast \CFA uses an M:N threading models, where concurrency is achieved using many user-level threads mapped onto fewer \glspl{kthrd}. The user-level threads have the same semantic meaning as a \glspl{kthrd} in the 1:1 model, they represent an independant thread of execution with it's on stack. The difference is that user-level threads do not have a corresponding object in the kernel, they are handled by the runtime in user space and scheduled onto \glspl{kthrd}, referred to as \glspl{proc} in this document. \Glspl{proc} run a \gls{thrd} until it context switches out, it then choses a different \gls{thrd} to run. 4 11 5 12 \section{Clusters} 13 \begin{figure} 14 \begin{center} 15 \input{system.pstex_t} 16 \end{center} 17 \caption{Overview of the \CFA runtime} 18 \label{fig:system} 19 \Glspl{thrd} are scheduled inside a particular cluster, where it only runs on the \glspl{proc} which belong to the cluster. The discrete-event manager, which handles preemption and timeout, is a \gls{kthrd} which lives outside any cluster and does not run \glspl{thrd}. 20 \end{figure} 21 \CFA allows the option to group user-level threading, in the form of clusters. Both \glspl{thrd} and \glspl{proc} belong to a specific cluster. \Glspl{thrd} will only be scheduled onto \glspl{proc} in the same cluster and scheduling is done independantly of other clusters. Figure~\ref{fig:system} shows an overview if this system. This allows programmers to control more tightly parallelism. It also opens the door to handling effects like NUMA, by pining clusters to specific NUMA node\footnote{This is not currently implemented in \CFA, but the only hurdle left is creating a generic interface for cpu masks.}. 22 23 \section{Scheduling} 24 The \CFA runtime was previously using a strictly \glsxtrshort{fifo} ready queue with a single lock. This setup offers perfect fairness in terms of opportunities to run/ However, it offers poor scalability, since the performance of the ready queue can never be improved by adding more \glspl{hthrd}, but the contention can cause significant performance degradation. 25 26 \section{\glsxtrshort{io}}\label{prev:io} 27 Prior to this work, the \CFA runtime did not add any particular support for \glsxtrshort{io} operations. \CFA being built on C, this means that, while all the operations available in C are available in \CFA, \glsxtrshort{io} operations are designed for the POSIX threading model\cit{pthreads}. Using these operations in a M:N threading model, when they are built for 1:1 threading, means that operations block \glspl{proc} instead of \glspl{thrd}. While this can work in certain cases, it limits the number of concurrent operations to the number of \glspl{proc} rather than \glspl{thrd}. This also means that deadlocks can occur because all \glspl{proc} are blocked even if at least one \gls{thrd} is ready to run. A simple example of this type of deadlock would be as follows: 28 29 Given a simple network program with 2 \glspl{thrd} and a single \gls{proc}, one \gls{thrd} sends network requests to a server and the other \gls{thrd} waits for response from the server. If the second \gls{thrd} races ahead, it may wait for responses to requests that have not been sent yet. In theory, this should not be a problem, even if the second \gls{thrd} waits, the first \gls{thrd} is still ready to run and should just be able to get CPU time and send the request. In practice with M:N threading, while the first \gls{thrd} is ready, the lone \gls{proc} in this example will \emph{not} try to run the first \gls{thrd} if it is blocked in the \glsxtrshort{io} operation of the second \gls{thrd}. If this happen, the system is effectively deadlocked\footnote{In this example, the deadlocked could be resolved if the server sends unprompted messages to the client. However, this solution is not general and may not be appropriate even in this simple case.}. 30 31 One of the objective of this work, is to introduce \emph{User-Level \glsxtrshort{io}} which, as a parallel to \glslink{uthrding}{User-Level \emph{Threading}}, blocks \glspl{thrd} rather than \glspl{proc} when doing \glsxtrshort{io} operations. This entails multiplexing the \glsxtrshort{io} operations of many \glspl{thrd} onto fewer \glspl{proc}. This multiplexing requires that a single \gls{proc} be able to execute multiple operations in parallel. This cannot be done with operations that block \glspl{proc}, \ie \glspl{kthrd}, since the first operation would prevent starting new operations for its duration. Executing operations in parallel requires \emph{asynchronous} \glsxtrshort{io}, sometimes referred to as \emph{non-blocking}, since the \gls{kthrd} is not blocked. 6 32 7 33 \section{Interoperating with \texttt{C}} 34 While \glsxtrshort{io} operations are the classical example of operations that block \glspl{kthrd}, the challenges mentioned in the previous section do not require \glsxtrshort{io} to be involved. These challenges are a product of blocking system calls rather than \glsxtrshort{io}. C offers no tools to identify whether or not a librairy function will lead to a blocking system call. This fact means interoperatability with C becomes a challenge in a M:N threading model. 35 36 Languages like Go and Java, which have strict interoperatability with C\cit{JNI, GoLang with C}, can control operations in C by ``sandboxing'' them. They can, for example, delegate C operations to \glspl{kthrd} that are not \glspl{proc}. Sandboxing may help towards guaranteeing that the deadlocks mentioned in the previous section do not occur. 37 38 As mentioned in Section~\cit{\CFA intro}, \CFA is binary compatible with C and, as such, trivially supports calls to and from C librairies. Furthermore, interoperatability can happen within a single library, through inline code or simply C and \CFA translation units archived together. The fine-grained interoperatability between C and \CFA has two consequences: 39 \begin{enumerate} 40 \item Precisely identifying C calls that could block is difficult. 41 \item Introducing code where interoperatability occurs could have a significant impact on general performance. 42 \end{enumerate} 43 44 Because of these consequences, this work does not attempt to ``sandbox'' calls to C. It is possible that conflicting calls to C could lead to deadlocks on \CFA's M:N threading model where they would not in the traditionnal 1:1 threading model. However, I judge that solving this problem in general, in a way that is composable and flexible, is too complex in itself and would add too much work to this thesis. Therefore it is outside the scope of this thesis. -
doc/theses/thierry_delisle_PhD/thesis/thesis.tex
r223a633 rb9537e6 121 121 % installation instructions there. 122 122 123 \usepackage{csquotes} 124 \usepackage{indentfirst} % as any self-respecting frenchman would 125 123 126 % Setting up the page margins... 124 127 % uWaterloo thesis requirements specify a minimum of 1 inch (72pt) margin at the … … 218 221 % separate documents, they would each start with the \chapter command, i.e, 219 222 % do not contain \documentclass or \begin{document} and \end{document} commands. 223 \part{Introduction} 220 224 \input{text/intro.tex} 225 \input{text/existing.tex} 221 226 \input{text/runtime.tex} 227 \part{Design} 222 228 \input{text/core.tex} 223 229 \input{text/practice.tex} 224 230 \input{text/io.tex} 231 \part{Evaluation} 232 \chapter{Theoretical and Existance Proofs} 233 \chapter{Micro-Benchmarks} 234 \chapter{Larger-Scale applications} 235 \part{Conclusion \& Annexes} 225 236 226 237 %---------------------------------------------------------------------- … … 245 256 \addcontentsline{toc}{chapter}{\textbf{References}} 246 257 247 \bibliography{ uw-ethesis}258 \bibliography{local} 248 259 % Tip 5: You can create multiple .bib files to organize your references. 249 260 % Just list them all in the \bibliogaphy command, separated by commas (no spaces). 250 261 251 % The following statement causes the specified references to be added to the bibliography% even if they were not252 % cited in the text. The asterisk is a wildcard that causes all entries in the bibliographic database to be included (optional).253 \nocite{*}262 % % The following statement causes the specified references to be added to the bibliography% even if they were not 263 % % cited in the text. The asterisk is a wildcard that causes all entries in the bibliographic database to be included (optional). 264 % \nocite{*} 254 265 255 266 % The \appendix statement indicates the beginning of the appendices.
Note: See TracChangeset
for help on using the changeset viewer.