- Timestamp:
- Sep 7, 2022, 4:12:00 PM (23 months ago)
- Branches:
- ADT, ast-experimental, master, pthread-emulation
- Children:
- e4855f6
- Parents:
- 7a0f798b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/thierry_delisle_PhD/thesis/text/runtime.tex
r7a0f798b ra44514e 13 13 \section{M:N Threading}\label{prev:model} 14 14 15 Threading in \CFA 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, \ie programmers should be able to create a large number of \glspl{thrd} and switch among \glspl{thrd}liberally without many concerns for performance.15 Threading in \CFA is based on \Gls{uthrding}, where \ats are the representation of a unit of work. As such, \CFA programmers should expect these units to be fairly inexpensive, \ie programmers should be able to create a large number of \ats and switch among \ats liberally without many concerns for performance. 16 16 17 17 The \CFA M:N threading models is implemented using many user-level threads mapped onto fewer \glspl{kthrd}. 18 18 The user-level threads have the same semantic meaning as a \glspl{kthrd} in the 1:1 model: they represent an independent thread of execution with its own stack. 19 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 chooses a different \gls{thrd}to run.19 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 \at until it context switches out, it then chooses a different \at to run. 20 20 21 21 \section{Clusters} 22 22 \CFA allows the option to group user-level threading, in the form of clusters. 23 Both \ glspl{thrd}and \glspl{proc} belong to a specific cluster.24 \Glspl{ thrd} are only scheduled onto \glspl{proc} in the same cluster and scheduling is done independently of other clusters.23 Both \ats and \glspl{proc} belong to a specific cluster. 24 \Glspl{at} are only scheduled onto \glspl{proc} in the same cluster and scheduling is done independently of other clusters. 25 25 Figure~\ref{fig:system} shows an overview of the \CFA runtime, which allows programmers to tightly control parallelism. 26 26 It also opens the door to handling effects like NUMA, by pinning clusters to a specific NUMA node\footnote{This capability is not currently implemented in \CFA, but the only hurdle left is creating a generic interface for CPU masks.}. … … 30 30 \input{system.pstex_t} 31 31 \end{center} 32 \caption[Overview of the \CFA runtime]{Overview of the \CFA runtime \newline \Glspl{ thrd} are scheduled inside a particular cluster and run on the \glspl{proc} that belong to the cluster. The discrete-event manager, which handles preemption and timeout, is a \gls{proc} that lives outside any cluster and does not run \glspl{thrd}.}32 \caption[Overview of the \CFA runtime]{Overview of the \CFA runtime \newline \Glspl{at} are scheduled inside a particular cluster and run on the \glspl{proc} that belong to the cluster. The discrete-event manager, which handles preemption and timeout, is a \gls{proc} that lives outside any cluster and does not run \ats.} 33 33 \label{fig:system} 34 34 \end{figure} … … 38 38 39 39 \section{\glsxtrshort{io}}\label{prev:io} 40 Prior to this work, the \CFA runtime did not add any particular support for \glsxtrshort{io} operations. While all \glsxtrshort{io} operations available in C are available in \CFA, \glsxtrshort{io} operations are designed for the POSIX threading model~\cite{pthreads}. Using these 1:1 threading operations in an M:N threading model means \glsxtrshort{io} 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}. It also means deadlock 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:40 Prior to this work, the \CFA runtime did not add any particular support for \glsxtrshort{io} operations. While all \glsxtrshort{io} operations available in C are available in \CFA, \glsxtrshort{io} operations are designed for the POSIX threading model~\cite{pthreads}. Using these 1:1 threading operations in an M:N threading model means \glsxtrshort{io} operations block \glspl{proc} instead of \ats. While this can work in certain cases, it limits the number of concurrent operations to the number of \glspl{proc} rather than \ats. It also means deadlock can occur because all \glspl{proc} are blocked even if at least one \at is ready to run. A simple example of this type of deadlock would be as follows: 41 41 42 42 \begin{quote} 43 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 a response from the server.44 If the second \ gls{thrd}races ahead, it may wait for responses to requests that have not been sent yet.45 In theory, this should not be a problem, even if the second \ gls{thrd} waits, because the first \gls{thrd}is still ready to run and should be able to get CPU time to send the request.46 With M:N threading, while the first \ gls{thrd} is ready, the lone \gls{proc} \emph{cannot} run the first \gls{thrd} if it is blocked in the \glsxtrshort{io} operation of the second \gls{thrd}.43 Given a simple network program with 2 \ats and a single \gls{proc}, one \at sends network requests to a server and the other \at waits for a response from the server. 44 If the second \at races ahead, it may wait for responses to requests that have not been sent yet. 45 In theory, this should not be a problem, even if the second \at waits, because the first \at is still ready to run and should be able to get CPU time to send the request. 46 With M:N threading, while the first \at is ready, the lone \gls{proc} \emph{cannot} run the first \at if it is blocked in the \glsxtrshort{io} operation of the second \at. 47 47 If this happen, the system is in a synchronization deadlock\footnote{In this example, the deadlock could be resolved if the server sends unprompted messages to the client. 48 48 However, this solution is neither general nor appropriate even in this simple case.}. 49 49 \end{quote} 50 50 51 Therefore, one of the objective of this work is to introduce \emph{User-Level \glsxtrshort{io}}, which like \glslink{uthrding}{User-Level \emph{Threading}}, blocks \ glspl{thrd} rather than \glspl{proc} when doing \glsxtrshort{io} operations.52 This feature entails multiplexing the \glsxtrshort{io} operations of many \ glspl{thrd}onto fewer \glspl{proc}.51 Therefore, one of the objective of this work is to introduce \emph{User-Level \glsxtrshort{io}}, which like \glslink{uthrding}{User-Level \emph{Threading}}, blocks \ats rather than \glspl{proc} when doing \glsxtrshort{io} operations. 52 This feature entails multiplexing the \glsxtrshort{io} operations of many \ats onto fewer \glspl{proc}. 53 53 The multiplexing requires a single \gls{proc} to execute multiple \glsxtrshort{io} operations in parallel. 54 54 This requirement cannot be done with operations that block \glspl{proc}, \ie \glspl{kthrd}, since the first operation would prevent starting new operations for its blocking duration.
Note: See TracChangeset
for help on using the changeset viewer.