Changeset 9921573
- Timestamp:
- Apr 11, 2023, 10:47:15 AM (20 months ago)
- Branches:
- ADT, ast-experimental, master
- Children:
- 6611177
- Parents:
- e59a9fa
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/colby_parsons_MMAth/text/channels.tex
re59a9fa r9921573 5 5 % ====================================================================== 6 6 7 Channels were first introduced by Hoare in his paper Communicating Sequentual Processes~\cite{Hoare78}, where he proposes a concurrent language that communicates across processes using input/output channels to send data. 8 Channels are a concurrent language feature used to perform message passing concurrency, a model of concurrency where threads communicate by sending data as messages, and synchronizing via the message passing mechanism. 9 This is an alternative to shared memory concurrency, where threads can communicate directly by changing shared memory state. 10 Most modern concurrent programming languages do not subscribe to just one style of communication between threads, and provide features that support both. 7 Channels are a concurrent-language feature used to perform \Newterm{message-passing concurrency}: a model of concurrency where threads communicate by sending (mostly nonblocking) data as messages and synchronizing by receiving (blocking) sent data. 8 This model is an alternative to shared-memory concurrency, where threads can communicate directly by changing shared state. 9 Most modern concurrent programming languages do not subscribe to just one style of communication among threads and provide features that support multiple approaches. 10 11 Channels were first introduced by Kahn~\cite{Kahn74} and extended by Hoare~\cite{Hoare78} (CSP). 12 Both papers present a pseudo (unimplemented) concurrent language where processes communicate using input/output channels to send data. 13 Both languages are highly restrictive. 14 Kahn's language restricts a reading process to only wait for data on a single channel at a time and different writing processes cannot send data on the same channel. 15 Hoare's language restricts ... 11 16 Channels as a programming language feature has been popularized in recent years due to the language Go, which encourages the use of channels as its fundamental concurrent feature. 17 Go's restrictions are ... 18 \CFA channels do not have these restrictions. 12 19 13 20 \section{Producer-Consumer Problem} … … 40 47 41 48 \begin{itemize} 42 \item Toggle-able statistic collection on channel beh vaiour that counts channel operations, and the number of the operations that block.49 \item Toggle-able statistic collection on channel behaviour that counts channel operations, and the number of the operations that block. 43 50 Tracking blocking operations helps users tune their channel size or channel usage when the channel is used for buffering, where the aim is to have as few blocking operations as possible. 44 51 \item Deadlock detection on deallocation of the channel. … … 46 53 \item A \code{flush} routine that delivers copies of an element to all waiting consumers, flushing the buffer. 47 54 Programmers can use this to easily to broadcast data to multiple consumers. 48 Additionally, the \code{flush} routine is more performant then looping around the \code{insert} operation since it can deliver the elements without having to rea quire mutual exclusion for each element sent.55 Additionally, the \code{flush} routine is more performant then looping around the \code{insert} operation since it can deliver the elements without having to reacquire mutual exclusion for each element sent. 49 56 \end{itemize} 50 57 … … 107 114 To highlight the differences between \CFA's and Go's close semantics, an example program is presented. 108 115 The program is a barrier implemented using two channels shown in Listings~\ref{l:cfa_chan_bar} and \ref{l:go_chan_bar}. 109 Both of these exa ples are implmented using \CFA syntax so that they can be easily compared.116 Both of these examples are implemented using \CFA syntax so that they can be easily compared. 110 117 Listing~\ref{l:go_chan_bar} uses go-style channel close semantics and Listing~\ref{l:cfa_chan_bar} uses \CFA close semantics. 111 118 In this problem it is infeasible to use the Go \code{close} call since all tasks are both potentially producers and consumers, causing panics on close to be unavoidable. … … 118 125 Also note that in the Go version~\ref{l:go_chan_bar}, the size of the barrier channels has to be larger than in the \CFA version to ensure that the main thread does not block when attempting to clear the barrier. 119 126 120 \begin{cfa}[ tabsize=3,caption={\CFA channel barrier termination},label={l:cfa_chan_bar}]127 \begin{cfa}[caption={\CFA channel barrier termination},label={l:cfa_chan_bar}] 121 128 struct barrier { 122 129 channel( int ) barWait; … … 173 180 \end{cfa} 174 181 175 \begin{cfa}[ tabsize=3,caption={Go channel barrier termination},label={l:go_chan_bar}]182 \begin{cfa}[caption={Go channel barrier termination},label={l:go_chan_bar}] 176 183 177 184 struct barrier { … … 244 251 If the same program was implemented in Go it would require explicit synchronization with both producers and consumers by some mechanism outside the channel to ensure that all elements were removed before task termination. 245 252 246 \begin{cfa}[ tabsize=3,caption={\CFA channel resumption usage},label={l:cfa_resume}]253 \begin{cfa}[caption={\CFA channel resumption usage},label={l:cfa_resume}] 247 254 channel( int ) chan{ 128 }; 248 255 … … 287 294 One microbenchmark is conducted to compare Go and \CFA. 288 295 The benchmark is a ten second experiment where producers and consumers operate on a channel in parallel and throughput is measured. 289 The number of cores is varied to measure how through tput scales.296 The number of cores is varied to measure how throughput scales. 290 297 The cores are divided equally between producers and consumers, with one producer or consumer owning each core. 291 298 The results of the benchmark are shown in Figure~\ref{f:chanPerf}.
Note: See TracChangeset
for help on using the changeset viewer.