source: doc/proposals/concurrency/concurrency.tex @ b0fedd4

aaron-thesisarm-ehcleanup-dtorsdeferred_resndemanglerjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerresolv-newwith_gc
Last change on this file since b0fedd4 was b0fedd4, checked in by Thierry Delisle <tdelisle@…>, 5 years ago

Some changes to concurrency proposal

  • Property mode set to 100644
File size: 73.1 KB
Line 
1% requires tex packages: texlive-base texlive-latex-base tex-common texlive-humanities texlive-latex-extra texlive-fonts-recommended
2
3% inline code ©...© (copyright symbol) emacs: C-q M-)
4% red highlighting ®...® (registered trademark symbol) emacs: C-q M-.
5% blue highlighting ß...ß (sharp s symbol) emacs: C-q M-_
6% green highlighting ¢...¢ (cent symbol) emacs: C-q M-"
7% LaTex escape §...§ (section symbol) emacs: C-q M-'
8% keyword escape ¶...¶ (pilcrow symbol) emacs: C-q M-^
9% math escape $...$ (dollar symbol)
10
11\documentclass[twoside,11pt]{article}
12
13%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
14
15% Latex packages used in the document.
16\usepackage[T1]{fontenc}                                        % allow Latin1 (extended ASCII) characters
17\usepackage{textcomp}
18\usepackage[latin1]{inputenc}
19\usepackage{fullpage,times,comment}
20\usepackage{epic,eepic}
21\usepackage{upquote}                                            % switch curled `'" to straight
22\usepackage{calc}
23\usepackage{xspace}
24\usepackage{graphicx}
25\usepackage{tabularx}
26\usepackage[acronym]{glossaries}
27\usepackage{varioref}                                           % extended references
28\usepackage{inconsolata}
29\usepackage{listings}                                           % format program code
30\usepackage[flushmargin]{footmisc}                              % support label/reference in footnote
31\usepackage{latexsym}                                           % \Box glyph
32\usepackage{mathptmx}                                           % better math font with "times"
33\usepackage[usenames]{color}
34\usepackage[pagewise]{lineno}
35\usepackage{fancyhdr}
36\renewcommand{\linenumberfont}{\scriptsize\sffamily}
37\input{style}                                                   % bespoke macros used in the document
38\usepackage[dvips,plainpages=false,pdfpagelabels,pdfpagemode=UseNone,colorlinks=true,pagebackref=true,linkcolor=blue,citecolor=blue,urlcolor=blue,pagebackref=true,breaklinks=true]{hyperref}
39\usepackage{breakurl}
40
41\usepackage{tikz}
42\def\checkmark{\tikz\fill[scale=0.4](0,.35) -- (.25,0) -- (1,.7) -- (.25,.15) -- cycle;}
43
44\renewcommand{\UrlFont}{\small\sf}
45
46\setlength{\topmargin}{-0.45in}                         % move running title into header
47\setlength{\headsep}{0.25in}
48
49%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
50
51% Names used in the document.
52
53\newcommand{\Version}{1.0.0}
54\newcommand{\CS}{C\raisebox{-0.9ex}{\large$^\sharp$}\xspace}
55
56\newcommand{\Textbf}[2][red]{{\color{#1}{\textbf{#2}}}}
57\newcommand{\Emph}[2][red]{{\color{#1}\textbf{\emph{#2}}}}
58\newcommand{\R}[1]{\Textbf{#1}}
59\newcommand{\B}[1]{{\Textbf[blue]{#1}}}
60\newcommand{\G}[1]{{\Textbf[OliveGreen]{#1}}}
61\newcommand{\uC}{$\mu$\CC}
62\newcommand{\cit}{\textsuperscript{[Citation Needed]}\xspace}
63\newcommand{\code}[1]{\lstinline[language=CFA]{#1}}
64\newcommand{\pseudo}[1]{\lstinline[language=Pseudo]{#1}}
65
66\input{glossary}
67
68\newsavebox{\LstBox}
69
70%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
71
72\setcounter{secnumdepth}{3}                             % number subsubsections
73\setcounter{tocdepth}{3}                                % subsubsections in table of contents
74% \linenumbers                                            % comment out to turn off line numbering
75\makeindex
76\pagestyle{fancy}
77\fancyhf{}
78\cfoot{\thepage}
79\rfoot{v\input{version}}
80
81%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
82
83\begin{document}
84% \linenumbers
85
86\title{Concurrency in \CFA}
87\author{Thierry Delisle \\
88School of Computer Science, University of Waterloo, \\ Waterloo, Ontario, Canada
89}
90
91\maketitle
92
93% ### #     # ####### ######  #######
94%  #  ##    #    #    #     # #     #
95%  #  # #   #    #    #     # #     #
96%  #  #  #  #    #    ######  #     #
97%  #  #   # #    #    #   #   #     #
98%  #  #    ##    #    #    #  #     #
99% ### #     #    #    #     # #######
100
101\section{Introduction}
102This proposal provides a minimal core concurrency API that is both simple, efficient and can be reused to build higher-level features. The simplest possible concurrency core is a thread and a lock but this low-level approach is hard to master. An easier approach for users is to support higher-level constructs as the basis of the concurrency in \CFA. Indeed, for highly productive parallel programming, high-level approaches are much more popular~\cite{HPP:Study}. Examples are task based, message passing and implicit threading.
103
104There are actually two problems that need to be solved in the design of the concurrency for a programming language: which concurrency tools are available to the users and which parallelism tools are available. While these two concepts are often seen together, they are in fact distinct concepts that require different sorts of tools~\cite{Buhr05a}. Concurrency tools need to handle mutual exclusion and synchronization, while parallelism tools are more about performance, cost and resource utilization.
105
106%  #####  ####### #     #  #####  #     # ######  ######  ####### #     #  #####  #     #
107% #     # #     # ##    # #     # #     # #     # #     # #       ##    # #     #  #   #
108% #       #     # # #   # #       #     # #     # #     # #       # #   # #         # #
109% #       #     # #  #  # #       #     # ######  ######  #####   #  #  # #          #
110% #       #     # #   # # #       #     # #   #   #   #   #       #   # # #          #
111% #     # #     # #    ## #     # #     # #    #  #    #  #       #    ## #     #    #
112%  #####  ####### #     #  #####   #####  #     # #     # ####### #     #  #####     #
113
114\section{Concurrency}
115Several tool can be used to solve concurrency challenges. Since these challenges always appear with the use of mutable shared-state, some languages and libraries simply disallow mutable shared-state (Erlang~\cite{Erlang}, Haskell~\cite{Haskell}, Akka (Scala)~\cite{Akka}). In these paradigms, interaction among concurrent objects relies on message passing~\cite{Thoth,Harmony,V-Kernel} or other paradigms that closely relate to networking concepts (channels\cit for example). However, in languages that use routine calls as their core abstraction mechanism, these approaches force a clear distinction between concurrent and non-concurrent paradigms (i.e., message passing versus routine call). Which in turn means that, in order to be effective, programmers need to learn two sets of designs patterns. This distinction can be hidden away in library code, but effective use of the librairy still has to take both paradigms into account. Approaches based on shared memory are more closely related to non-concurrent paradigms since they often rely on basic constructs like routine calls and objects. At a lower level these can be implemented as locks and atomic operations. Many such mechanisms have been proposed, including semaphores~\cite{Dijkstra68b} and path expressions~\cite{Campbell74}. However, for productivity reasons it is desireable to have a higher-level construct be the core concurrency paradigm~\cite{HPP:Study}. An approach that is worth mentionning because it is gaining in popularity is transactionnal memory~\cite{Dice10}[Check citation]. While this approach is even pursued by system languages like \CC\cit, the performance and feature set is currently too restrictive to add such a paradigm to a language like C or \CC\cit, which is why it was rejected as the core paradigm for concurrency in \CFA. One of the most natural, elegant, and efficient mechanisms for synchronization and communication, especially for shared memory systems, is the \emph{monitor}. Monitors were first proposed by Brinch Hansen~\cite{Hansen73} and later described and extended by C.A.R.~Hoare~\cite{Hoare74}. Many programming languages---e.g., Concurrent Pascal~\cite{ConcurrentPascal}, Mesa~\cite{Mesa}, Modula~\cite{Modula-2}, Turing~\cite{Turing:old}, Modula-3~\cite{Modula-3}, NeWS~\cite{NeWS}, Emerald~\cite{Emerald}, \uC~\cite{Buhr92a} and Java~\cite{Java}---provide monitors as explicit language constructs. In addition, operating-system kernels and device drivers have a monitor-like structure, although they often use lower-level primitives such as semaphores or locks to simulate monitors. For these reasons, this project proposes monitors as the core concurrency construct.
116
117% #     # ####### #     # ### ####### ####### ######   #####
118% ##   ## #     # ##    #  #     #    #     # #     # #     #
119% # # # # #     # # #   #  #     #    #     # #     # #
120% #  #  # #     # #  #  #  #     #    #     # ######   #####
121% #     # #     # #   # #  #     #    #     # #   #         #
122% #     # #     # #    ##  #     #    #     # #    #  #     #
123% #     # ####### #     # ###    #    ####### #     #  #####
124
125\subsection{Monitors}
126A monitor is a set of routines that ensure mutual exclusion when accessing shared state. This concept is generally associated with Object-Oriented Languages like Java~\cite{Java} or \uC~\cite{uC++book} but does not strictly require OOP semantics. The only requirements is the ability to declare a handle to a shared object and a set of routines that act on it :
127\begin{lstlisting}
128        typedef /*some monitor type*/ monitor;
129        int f(monitor & m);
130
131        int main() {
132                monitor m;
133                f(m);
134        }
135\end{lstlisting}
136
137%  #####     #    #       #
138% #     #   # #   #       #
139% #        #   #  #       #
140% #       #     # #       #
141% #       ####### #       #
142% #     # #     # #       #
143%  #####  #     # ####### #######
144
145\subsubsection{Call semantics} \label{call}
146The above monitor example displays some of the intrinsic characteristics. Indeed, it is necessary to use pass-by-reference over pass-by-value for monitor routines. This semantics is important because at their core, monitors are implicit mutual-exclusion objects (locks), and these objects cannot be copied. Therefore, monitors are implicitly non-copyable.
147
148Another aspect to consider is when a monitor acquires its mutual exclusion. For example, a monitor may need to be passed through multiple helper routines that do not acquire the monitor mutual-exclusion on entry. Pass through can be both generic helper routines (\code{swap}, \code{sort}, etc.) or specific helper routines like the following to implement an atomic counter :
149
150\begin{lstlisting}
151        mutex struct counter_t { /*...see section §\ref{data}§...*/ };
152
153        void ?{}(counter_t & nomutex this); //constructor
154        size_t ++?(counter_t & mutex this); //increment
155
156        //need for mutex is platform dependent here
157        void ?{}(size_t * this, counter_t & mutex cnt); //conversion
158\end{lstlisting}
159
160Here, the constructor(\code{?\{\}}) uses the \code{nomutex} keyword to signify that it does not acquire the monitor mutual exclusion when constructing. This semantics is because an object not yet constructed should never be shared and therefore does not require mutual exclusion. The prefix increment operator uses \code{mutex} to protect the incrementing process from race conditions. Finally, there is a conversion operator from \code{counter_t} to \code{size_t}. This conversion may or may not require the \code{mutex} key word depending on whether or not reading an \code{size_t} is an atomic operation or not.
161
162Having both \code{mutex} and \code{nomutex} keywords could be argued to be redundant based on the meaning of a routine having neither of these keywords. For example, given a routine without quualifiers \code{void foo(counter_t & this)} then one could argue that it should default to the safest option \code{mutex}. On the other hand, the option of having routine \code{void foo(counter_t & this)} mean \code{nomutex} is unsafe by default and may easily cause subtle errors. It can be argued that \code{nomutex} is the more "normal" behaviour, the \code{nomutex} keyword effectively stating explicitly that "this routine has nothing special". Another alternative is to make having exactly one of these keywords mandatory, which would provide the same semantics but without the ambiguity of supporting routine \code{void foo(counter_t & this)}. Mandatory keywords would also have the added benefice of being self-documented but at the cost of extra typing. In the end, which solution should be picked is still up for debate. For the reminder of this proposal, the explicit approach is used for clarity.
163
164The next semantic decision is to establish when mutex/nomutex may be used as a type qualifier. Consider the following declarations:
165\begin{lstlisting}
166        int f1(monitor & mutex m);
167        int f2(const monitor & mutex m);
168        int f3(monitor ** mutex m);
169        int f4(monitor *[] mutex m);
170        int f5(graph(monitor*) & mutex m);
171\end{lstlisting}
172The problem is to indentify which object(s) should be acquired. Furthermore, each object needs to be acquired only once. In the case of simple routines like \code{f1} and \code{f2} it is easy to identify an exhaustive list of objects to acquire on entry. Adding indirections (\code{f3}) still allows the compiler and programmer to indentify which object is acquired. However, adding in arrays (\code{f4}) makes it much harder. Array lengths are not necessarily known in C and even then making sure we only acquire objects once becomes also none trivial. This can be extended to absurd limits like \code{f5}, which uses a graph of monitors. To keep everyone as sane as possible~\cite{Chicken}, this projects imposes the requirement that a routine may only acquire one monitor per parameter and it must be the type of the parameter (ignoring potential qualifiers and indirections). Also note that while routine \code{f3} can be supported, meaning that monitor \code{**m} is be acquired, passing an array to this routine would be type safe and yet result in undefined behavior because only the first element of the array is acquired. However, this ambiguity is part of the C type system with respects to arrays. For this reason, it would also be reasonnable to disallow mutex in the context where arrays may be passed.
173
174% ######     #    #######    #
175% #     #   # #      #      # #
176% #     #  #   #     #     #   #
177% #     # #     #    #    #     #
178% #     # #######    #    #######
179% #     # #     #    #    #     #
180% ######  #     #    #    #     #
181
182\subsubsection{Data semantics} \label{data}
183Once the call semantics are established, the next step is to establish data semantics. Indeed, until now a monitor is used simply as a generic handle but in most cases monitors contian shared data. This data should be intrinsic to the monitor declaration to prevent any accidental use of data without its appropriate protection. For example, here is a complete version of the counter showed in section \ref{call}:
184\begin{lstlisting}
185        mutex struct counter_t {
186                int value;
187        };
188
189        void ?{}(counter_t & nomutex this) {
190                this.cnt = 0;
191        }
192
193        int ++?(counter_t & mutex this) {
194                return ++this.value;
195        }
196
197        //need for mutex is platform dependent here
198        void ?{}(int * this, counter_t & mutex cnt) {
199                *this = (int)cnt;
200        }
201\end{lstlisting}
202
203This simple counter is used as follows:
204\begin{center}
205\begin{tabular}{c @{\hskip 0.35in} c @{\hskip 0.35in} c}
206\begin{lstlisting}
207        //shared counter
208        counter_t cnt;
209
210        //multiple threads access counter
211        thread 1 : cnt++;
212        thread 2 : cnt++;
213        thread 3 : cnt++;
214          ...
215        thread N : cnt++;
216\end{lstlisting}
217\end{tabular}
218\end{center}
219
220Notice how the counter is used without any explicit synchronisation and yet supports thread-safe semantics for both reading and writting. Unlike object-oriented monitors, where calling a mutex member \emph{implicitly} acquires mutual-exclusion, \CFA uses an explicit mechanism to acquire mutual-exclusion. A consequence of this approach is that it extends to multi-monitor calls.
221\begin{lstlisting}
222        int f(MonitorA & mutex a, MonitorB & mutex b);
223
224        MonitorA a;
225        MonitorB b;
226        f(a,b);
227\end{lstlisting}
228This code acquires both locks before entering the critical section, called \emph{\gls{group-acquire}}. In practice, writing multi-locking routines that do not lead to deadlocks is tricky. Having language support for such a feature is therefore a significant asset for \CFA. In the case presented above, \CFA guarantees that the order of aquisition is consistent across calls to routines using the same monitors as arguments. However, since \CFA monitors use multi-acquisition locks, users can effectively force the acquiring order. For example, notice which routines use \code{mutex}/\code{nomutex} and how this affects aquiring order :
229\begin{lstlisting}
230        void foo(A & mutex a, B & mutex b) { //acquire a & b
231                //...
232        }
233
234        void bar(A & mutex a, B & nomutex b) { //acquire a
235                //...
236                foo(a, b); //acquire b
237                //...
238        }
239
240        void baz(A & nomutex a, B & mutex b) { //acquire b
241                //...
242                foo(a, b); //acquire a
243                //...
244        }
245\end{lstlisting}
246
247The multi-acquisition monitor lock allows a monitor lock to be acquired by both \code{bar} or \code{baz} and acquired again in \code{foo}. In the calls to \code{bar} and \code{baz} the monitors are acquired in opposite order. such use leads to nested monitor call problems~\cite{Lister77}, which is a specific implementation of the lock acquiring order problem. In the example above, the user uses implicit ordering in the case of function \code{foo} but explicit ordering in the case of \code{bar} and \code{baz}. This subtle mistake means that calling these routines concurrently may lead to deadlock and is therefore undefined behavior. As shown on several occasion\cit, solving this problem requires :
248\begin{enumerate}
249        \item Dynamically tracking of the monitor-call order.
250        \item Implement rollback semantics.
251\end{enumerate}
252
253While the first requirement is already a significant constraint on the system, implementing a general rollback semantics in a C-like language is prohibitively complex \cit. In \CFA, users simply need to be carefull when acquiring multiple monitors at the same time.
254
255% ######  ####### #######    #    ### #        #####
256% #     # #          #      # #    #  #       #     #
257% #     # #          #     #   #   #  #       #
258% #     # #####      #    #     #  #  #        #####
259% #     # #          #    #######  #  #             #
260% #     # #          #    #     #  #  #       #     #
261% ######  #######    #    #     # ### #######  #####
262%
263%             ######  ####### #       #     # #     # ####### ######  #     #
264%             #     # #     # #        #   #  ##   ## #     # #     # #     #
265%             #     # #     # #         # #   # # # # #     # #     # #     #
266%  #####    ######  #     # #          #    #  #  # #     # ######  #######
267%             #       #     # #          #    #     # #     # #   #   #     #
268%             #       #     # #          #    #     # #     # #    #  #     #
269%             #       ####### #######    #    #     # ####### #     # #     #
270
271\subsubsection{Implementation Details: Interaction with polymorphism}
272At first glance, interaction between monitors and \CFA's concept of polymorphism seems complex to support. However, it is shown that entry-point locking can solve most of the issues.
273
274Before looking into complex control flow, it is important to present the difference between the two acquiring options : \gls{callsite-locking} and \gls{entry-point-locking}, i.e. acquiring the monitors before making a mutex call or as the first instruction of the mutex call. For example:
275
276\begin{center}
277\begin{tabular}{|c|c|c|}
278Code & \gls{callsite-locking} & \gls{entry-point-locking} \\
279\CFA & pseudo-code & pseudo-code \\
280\hline
281\begin{lstlisting}
282void foo(monitor & mutex a) {
283
284
285
286        //Do Work
287        //...
288
289}
290
291void main() {
292        monitor a;
293
294
295
296        foo(a);
297
298}
299\end{lstlisting} &\begin{lstlisting}
300foo(& a) {
301
302
303
304        //Do Work
305        //...
306
307}
308
309main() {
310        monitor a;
311        //calling routine
312        //handles concurrency
313        acquire(a);
314        foo(a);
315        release(a);
316}
317\end{lstlisting} &\begin{lstlisting}
318foo(& a) {
319        //called routine
320        //handles concurrency
321        acquire(a);
322        //Do Work
323        //...
324        release(a);
325}
326
327main() {
328        monitor a;
329
330
331
332        foo(a);
333
334}
335\end{lstlisting}
336\end{tabular}
337\end{center}
338
339First of all, interaction between \code{otype} polymorphism and monitors is impossible since monitors do not support copying. Therefore, the main question is how to support \code{dtype} polymorphism. Since a monitor's main purpose is to ensure mutual exclusion when accessing shared data, this implies that mutual exclusion is only required for routines that do in fact access shared data. However, since \code{dtype} polymorphism always handles incomplete types (by definition), no \code{dtype} polymorphic routine can access shared data since the data requires knowledge about the type. Therefore, the only concern when combining \code{dtype} polymorphism and monitors is to protect access to routines. \Gls{callsite-locking} would require a significant amount of work, since any \code{dtype} routine may have to obtain some lock before calling a routine, depending on whether or not the type passed is a monitor. However, with \gls{entry-point-locking} calling a monitor routine becomes exactly the same as calling it from anywhere else.
340
341
342
343% ### #     # #######         #####   #####  #     # ####### ######
344%  #  ##    #    #           #     # #     # #     # #       #     #
345%  #  # #   #    #           #       #       #     # #       #     #
346%  #  #  #  #    #            #####  #       ####### #####   #     #
347%  #  #   # #    #    ###          # #       #     # #       #     #
348%  #  #    ##    #    ###    #     # #     # #     # #       #     #
349% ### #     #    #    ###     #####   #####  #     # ####### ######
350
351\subsection{Internal scheduling} \label{insched}
352
353\begin{center}
354\begin{tabular}{ c @{\hskip 0.65in} c }
355\begin{lstlisting}[language=Pseudo]
356acquire A
357        wait A
358release A
359\end{lstlisting}&\begin{lstlisting}[language=Pseudo]
360acquire A
361        signal A
362release A
363\end{lstlisting}
364\end{tabular}
365\end{center}
366
367Easy : like uC++
368
369\begin{center}
370\begin{tabular}{ c @{\hskip 0.65in} c }
371\begin{lstlisting}[language=Pseudo]
372acquire A
373        acquire B
374                wait B
375        release B
376release A
377\end{lstlisting}&\begin{lstlisting}[language=Pseudo]
378acquire A
379        acquire B
380                signal B
381        release B
382release A
383\end{lstlisting}
384\end{tabular}
385\end{center}
386
387Also easy : like uC++
388
389\begin{center}
390\begin{tabular}{ c @{\hskip 0.65in} c }
391\begin{lstlisting}[language=Pseudo]
392acquire A & B
393        wait A & B
394release A & B
395\end{lstlisting}&\begin{lstlisting}[language=Pseudo]
396acquire A & B
397        signal A & B
398release A & B
399\end{lstlisting}
400\end{tabular}
401\end{center}
402
403Simplest extension : can be made like uC++ by tying B to A
404
405\begin{center}
406\begin{tabular}{ c @{\hskip 0.65in} c }
407\begin{lstlisting}[language=Pseudo]
408acquire A
409        // Code Section 1
410        acquire B
411                // Code Section 2
412                wait A & B
413                // Code Section 3
414        release B
415        // Code Section 4
416release A
417\end{lstlisting}&\begin{lstlisting}[language=Pseudo]
418acquire A
419        // Code Section 5
420        acquire B
421                // Code Section 6
422                signal A & B
423                // Code Section 7
424        release B
425        // Code Section 8
426release A
427\end{lstlisting}
428\end{tabular}
429\end{center}
430
431Hard extension :
432
433Incorrect options for the signal :
434
435\begin{description}
436 \item[-] Release B and baton pass after Code Section 8 : Passing b without having it
437 \item[-] Keep B during Code Section 8 : Can lead to deadlocks since we secretly keep a lock longer than specified by the user
438 \item[-] Instead of release B transfer A and B to waiter then try to reacquire A before running Code Section 8 : This allows barging
439\end{description}
440
441Since we don't want barging we need to pass A \& B and somehow block and get A back.
442
443\begin{center}
444\begin{tabular}{ c @{\hskip 0.65in} c }
445\begin{lstlisting}[language=Pseudo]
446acquire A
447        acquire B
448                acquire C
449                        wait A & B & C
450                1: release C
451        2: release B
4523: release A
453\end{lstlisting}&\begin{lstlisting}[language=Pseudo]
454acquire A
455        acquire B
456                acquire C
457                        signal A & B & C
458                4: release C
459        5: release B
4606: release A
461\end{lstlisting}
462\end{tabular}
463\end{center}
464
465To prevent barging :
466
467\begin{description}
468 \item[-] When the signaller hits 4 : pass A, B, C to waiter
469 \item[-] When the waiter hits 2 : pass A, B to signaller
470 \item[-] When the signaller hits 5 : pass A to waiter
471\end{description}
472
473
474\begin{center}
475\begin{tabular}{ c @{\hskip 0.65in} c }
476\begin{lstlisting}[language=Pseudo]
477acquire A
478        acquire C
479                acquire B
480                        wait A & B & C
481                1: release B
482        2: release C
4833: release A
484\end{lstlisting}&\begin{lstlisting}[language=Pseudo]
485acquire B
486        acquire A
487                acquire C
488                        signal A & B & C
489                4: release C
490        5: release A
4916: release B
492\end{lstlisting}
493\end{tabular}
494\end{center}
495
496To prevent barging : When the signaller hits 4 : pass A, B, C to waiter. When the waiter hits 1 it must release B,
497
498\begin{description}
499 \item[-] 
500 \item[-] When the waiter hits 1 : pass A, B to signaller
501 \item[-] When the signaller hits 5 : pass A, B to waiter
502 \item[-] When the waiter hits 2 : pass A to signaller
503\end{description}
504
505% Monitors also need to schedule waiting threads internally as a mean of synchronization. Internal scheduling is one of the simple examples of such a feature. It allows users to declare condition variables and have threads wait and signaled from them. Here is a simple example of such a technique :
506
507% \begin{lstlisting}
508%       mutex struct A {
509%               condition e;
510%       }
511
512%       void foo(A & mutex a) {
513%               //...
514%               wait(a.e);
515%               //...
516%       }
517
518%       void bar(A & mutex a) {
519%               signal(a.e);
520%       }
521% \end{lstlisting}
522
523% Note that in \CFA, \code{condition} have no particular need to be stored inside a monitor, beyond any software engineering reasons. Here routine \code{foo} waits for the \code{signal} from \code{bar} before making further progress, effectively ensuring a basic ordering.
524
525% As for simple mutual exclusion, these semantics must also be extended to include \gls{group-acquire} :
526% \begin{center}
527% \begin{tabular}{ c @{\hskip 0.65in} c }
528% Thread 1 & Thread 2 \\
529% \begin{lstlisting}
530% void foo(A & mutex a,
531%            A & mutex b) {
532%       //...
533%       wait(a.e);
534%       //...
535% }
536
537% foo(a, b);
538% \end{lstlisting} &\begin{lstlisting}
539% void bar(A & mutex a,
540%            A & mutex b) {
541%       signal(a.e);
542% }
543
544
545
546% bar(a, b);
547% \end{lstlisting}
548% \end{tabular}
549% \end{center}
550
551% To define the semantics of internal scheduling, it is important to look at nesting and \gls{group-acquire}. Indeed, beyond concerns about lock ordering, without scheduling the two following pseudo codes are mostly equivalent. In fact, if we assume monitors are ordered alphabetically, these two pseudo codes would probably lead to exactly the same implementation :
552
553% \begin{table}[h!]
554% \centering
555% \begin{tabular}{c c}
556% \begin{lstlisting}[language=pseudo]
557% monitor A, B, C
558
559% acquire A
560%       acquire B & C
561
562%                       //Do stuff
563
564%       release B & C
565% release A
566% \end{lstlisting} &\begin{lstlisting}[language=pseudo]
567% monitor A, B, C
568
569% acquire A
570%       acquire B
571%               acquire C
572%                       //Do stuff
573%               release C
574%       release B
575% release A
576% \end{lstlisting}
577% \end{tabular}
578% \end{table}
579
580% Once internal scheduling is introduce however, semantics of \gls{group-acquire} become relevant. For example, let us look into the semantics of the following pseudo-code :
581
582% \begin{lstlisting}[language=Pseudo]
583% 1: monitor A, B, C
584% 2: condition c1
585% 3:
586% 4: acquire A
587% 5:            acquire A & B & C
588% 6:                            signal c1
589% 7:            release A & B & C
590% 8: release A
591% \end{lstlisting}
592
593% Without \gls{group-acquire} signal simply baton passes the monitor lock on the next release. In the case above, we therefore need to indentify the next release. If line 8 is picked at the release point, then the signal will attempt to pass A \& B \& C, without having ownership of B \& C. Since this violates mutual exclusion, we conclude that line 7 is the only valid location where signalling can occur. The traditionnal meaning of signalling is to transfer ownership of the monitor(s) and immediately schedule the longest waiting task. However, in the discussed case, the signalling thread expects to maintain ownership of monitor A. This can be expressed in two differents ways : 1) the thread transfers ownership of all locks and reacquires A when it gets schedulled again or 2) it transfers ownership of all three monitors and then expects the ownership of A to be transferred back.
594
595% However, the question is does these behavior motivate supporting acquireing non-disjoint set of monitors. Indeed, if the previous example was modified to only acquire B \& C at line 5 (an release the accordingly) then in respects to scheduling, we could add the simplifying constraint that all monitors in a bulk will behave the same way, simplifying the problem back to a single monitor problem which has already been solved. For this constraint to be acceptble however, we need to demonstrate that in does not prevent any meaningful possibilities. And, indeed, we can look at the two previous interpretation of the above pseudo-code and conclude that supporting the acquiring of non-disjoint set of monitors does not add any expressiveness to the language.
596
597% Option 1 reacquires the lock after the signal statement, this can be rewritten as follows without the need for non-disjoint sets :
598% \begin{lstlisting}[language=Pseudo]
599% monitor A, B, C
600% condition c1
601
602% acquire A & B & C
603%       signal c1
604% release A & B & C
605% acquire A
606
607% release A
608% \end{lstlisting}
609
610% This pseudo code has almost exaclty the same semantics as the code acquiring intersecting sets of monitors.
611
612% Option 2 uses two-way lock ownership transferring instead of reacquiring monitor A. Two-way monitor ownership transfer is normally done using signalBlock semantics, which immedietely transfers ownership of a monitor before getting the ownership back when the other thread no longer needs the monitor. While the example pseudo-code for Option 2 seems toe transfer ownership of A, B and C and only getting A back, this is not a requirement. Getting back all 3 monitors and releasing B and C differs only in performance. For this reason, the second option could arguably be rewritten as :
613
614% \begin{lstlisting}[language=Pseudo]
615% monitor A, B, C
616% condition c1
617
618% acquire A
619%       acquire B & C
620%               signalBlock c1
621%       release B & C
622% release A
623% \end{lstlisting}
624
625% Obviously, the difference between these two snippets of pseudo code is that the first one transfers ownership of A, B and C while the second one only transfers ownership of B and C. However, this limitation can be removed by allowing user to release extra monitors when using internal scheduling, referred to as extended internal scheduling (pattent pending) from this point on. Extended internal scheduling means the two following pseudo-codes are functionnaly equivalent :
626% \begin{table}[h!]
627% \centering
628% \begin{tabular}{c @{\hskip 0.65in} c}
629% \begin{lstlisting}[language=pseudo]
630% monitor A, B, C
631% condition c1
632
633% acquire A
634%       acquire B & C
635%               signalBlock c1 with A
636%       release B & C
637% release A
638% \end{lstlisting} &\begin{lstlisting}[language=pseudo]
639% monitor A, B, C
640% condition c1
641
642% acquire A
643%       acquire A & B & C
644%               signal c1
645%       release A & B & C
646% release A
647% \end{lstlisting}
648% \end{tabular}
649% \end{table}
650
651% It must be stated that the extended internal scheduling only makes sense when using wait and signalBlock, since they need to prevent barging, which cannot be done in the context of signal since the ownership transfer is strictly one-directionnal.
652
653% One critic that could arise is that extended internal schedulling is not composable since signalBlock must be explicitly aware of which context it is in. However, this argument is not relevant since acquire A, B and C in a context where a subset of them is already acquired cannot be achieved without spurriously releasing some locks or having an oracle aware of all monitors. Therefore, composability of internal scheduling is no more an issue than composability of monitors in general.
654
655% The main benefit of using extended internal scheduling is that it offers the same expressiveness as intersecting monitor set acquiring but greatly simplifies the selection of a leader (or representative) for a group of monitor. Indeed, when using intersecting sets, it is not obvious which set intersects with other sets which means finding a leader representing only the smallest scope is a hard problem. Where as when using disjoint sets, any monitor that would be intersecting must be specified in the extended set, the leader can be chosen as any monitor in the primary set.
656
657% We need to make sure the semantics for internally scheduling N monitors are a natural extension of the single monitor semantics. For this reason, we introduce the concept of \gls{mon-ctx}. In terms of context internal scheduling means "releasing a \gls{mon-ctx} and waiting for an other thread to acquire the same \gls{mon-ctx} and baton-pass it back to the initial thread". This definitions requires looking into what a \gls{mon-ctx} is and what the semantics of waiting and baton-passing are.
658
659% \subsubsection{Internal scheduling: Context} \label{insched-context}
660% Monitor scheduling operations are defined in terms of the context they are in. In languages that only supports operations on a single monitor at once, the context is completly defined by which most recently acquired monitors. Indeed, acquiring several monitors will form a stack of monitors which will be released in FILO order. In \CFA, a \gls{mon-ctx} cannot be simply defined by the last monitor that was acquired since \gls{group-acquire} means multiple monitors can be "the last monitor acquired". The \gls{mon-ctx} is therefore defined as the last set of monitors to have been acquired. This means taht when any new monitor is acquired, the group it belongs to is the new \gls{mon-ctx}. Correspondingly, if any monitor is released, the \gls{mon-ctx} reverts back to the context that was used prior to the monitor being acquired. In the most common case, \gls{group-acquire} means every monitor of a group will be acquired in released at the same time. However, since every monitor has its own recursion level, \gls{group-acquire} does not prevent users from reacquiring certain monitors while acquireing new monitors in the same operation. For example :
661
662% \begin{lstlisting}
663% //Forward declarations
664% monitor a, b, c
665% void foo( monitor & mutex a,
666%             monitor & mutex b);
667% void bar( monitor & mutex a,
668%             monitor & mutex b);
669% void baz( monitor & mutex a,
670%             monitor & mutex b,
671%             monitor & mutex c);
672
673% //Routines defined inline to illustrate context changed compared to the stack
674
675% //main thread
676% foo(a, b) {
677%       //thread calls foo
678%       //acquiring context a & b
679
680%       baz(a, b) {
681%               //thread calls baz
682%               //no context change
683
684%               bar(a, b, c) {
685%                       //thread calls bar
686%                       //acquiring context a & b & c
687
688%                       //Do stuff
689
690%                       return;             
691%                       //call to bar returns
692%               }
693%               //context back to a & b
694
695%               return;
696%               //call to baz returns
697%       }
698%       //no context change
699
700%       return;
701%       //call to foo returns
702% }
703% //context back to initial state
704
705% \end{lstlisting}
706
707% As illustrated by the previous example, context changes can be caused by only one of the monitors comming into context or going out of context.
708
709% \subsubsection{Internal scheduling: Waiting} \label{insched-wait}
710
711% \subsubsection{Internal scheduling: Baton Passing} \label{insched-signal}
712% Baton passing in internal scheduling is done in terms of \code{signal} and \code{signalBlock}\footnote{Arguably, \code{signal_now} is a more evocative name and \code{signal} could be changed appropriately. }. While \code{signalBlock} is the more straight forward way of baton passing, transferring ownership immediately, it must rely on \code{signal} which is why t is discussed first.
713% \code{signal} has for effect to transfer the current context to another thread when the context would otherwise be released. This means that instead of releasing the concerned monitors, the first thread on the condition ready-queue is scheduled to run. The monitors are not released and when the signalled thread runs, it assumes it regained ownership of all the monitors it had in its context.
714
715% \subsubsection{Internal scheduling: Implementation} \label{insched-impl}
716% Too implement internal scheduling, three things are need : a data structure for waiting tasks, a data structure for signalled task and a leaving procedure to run the signalled task. In the case of both data structures, it is desireable to have to use intrusive data structures in order to prevent the need for any dynamic allocation. However, in both cases being able to queue several items in the same position in a queue is non trivial, even more so in the presence of concurrency. However, within a given \gls{mon-ctx}, all monitors have exactly the same behavior in regards to scheduling. Therefore, the problem of queuing multiple monitors at once can be ignored by choosing one monitor to represent every monitor in a context. While this could prove difficult in other situations, \gls{group-acquire} requires that the monitors be sorted according to some stable predicate. Since monitors are sorted in all contexts, the representative can simply be the first in the list. Choosing a representative means a simple intrusive queue inside the condition is sufficient to implement the data structure for both waiting and signalled monitors.
717
718% Since \CFA monitors don't have a complete image of the \gls{mon-ctx}, choosing the representative and maintaning the current context information cannot easily be done by any single monitors. However, as discussed in section [Missing section here], monitor mutual exclusion is implemented using an raii object which is already in charge of sorting monitors. This object has a complete picture of the \gls{mon-ctx} which means it is well suited to choose the reprensentative and detect context changes.
719
720% \newpage
721% \begin{lstlisting}
722% void ctor( monitor ** _monitors, int _count ) {
723%       bool ctx_changed = false;
724%       for( mon in _monitors ) {
725%               ctx_changed = acquire( mon ) || ctx_changed;
726%       }
727
728%       if( ctx_changed ) {
729%               set_representative();
730%               set_context();
731%       }
732% }
733
734% void dtor( monitor ** _monitors, int _count ) {
735%       if( context_will_exit( _monitors, count ) ) {
736%               baton_pass();
737%               return;
738%       }
739
740%       for( mon in _monitors ) {
741%               release( mon );
742%       }
743% }
744
745% \end{lstlisting}
746
747
748
749% A direct extension of the single monitor semantics is to release all locks when waiting and transferring ownership of all locks when signalling. However, for the purpose of synchronization it may be usefull to only release some of the locks but keep others. It is possible to support internal scheduling and \gls{group-acquire} without any extra syntax by relying on order of acquisition. Here is an example of the different contexts in which internal scheduling can be used. (Note that here the use of helper routines is irrelevant, only routines acquire mutual exclusion have an impact on internal scheduling):
750
751% \begin{table}[h!]
752% \centering
753% \begin{tabular}{|c|c|c|}
754% Context 1 & Context 2 & Context 3 \\
755% \hline
756% \begin{lstlisting}
757% condition e;
758
759% //acquire a & b
760% void foo(monitor & mutex a,
761%            monitor & mutex b) {
762
763%       wait(e); //release a & b
764% }
765
766
767
768
769
770
771% foo(a,b);
772% \end{lstlisting} &\begin{lstlisting}
773% condition e;
774
775% //acquire a
776% void bar(monitor & mutex a,
777%            monitor & nomutex b) {
778%       foo(a,b);
779% }
780
781% //acquire a & b
782% void foo(monitor & mutex a,
783%            monitor & mutex b) {
784%       wait(e);  //release a & b
785% }
786
787% bar(a, b);
788% \end{lstlisting} &\begin{lstlisting}
789% condition e;
790
791% //acquire a
792% void bar(monitor & mutex a,
793%            monitor & nomutex b) {
794%       baz(a,b);
795% }
796
797% //acquire b
798% void baz(monitor & nomutex a,
799%            monitor & mutex b) {
800%       wait(e);  //release b
801% }
802
803% bar(a, b);
804% \end{lstlisting}
805% \end{tabular}
806% \end{table}
807
808% Context 1 is the simplest way of acquiring more than one monitor (\gls{group-acquire}), using a routine with multiple parameters having the \code{mutex} keyword. Context 2 also uses \gls{group-acquire} as well in routine \code{foo}. However, the routine is called by routine \code{bar}, which only acquires monitor \code{a}. Since monitors can be acquired multiple times this does not cause a deadlock by itself but it does force the acquiring order to \code{a} then \code{b}. Context 3 also forces the acquiring order to be \code{a} then \code{b} but does not use \gls{group-acquire}. The previous example tries to illustrate the semantics that must be established to support releasing monitors in a \code{wait} statement. In all cases, the behavior of the wait statment is to release all the locks that were acquired my the inner-most monitor call. That is \code{a & b} in context 1 and 2 and \code{b} only in context 3. Here are a few other examples of this behavior.
809
810
811% \begin{center}
812% \begin{tabular}{|c|c|c|}
813% \begin{lstlisting}
814% condition e;
815
816% //acquire b
817% void foo(monitor & nomutex a,
818%            monitor & mutex b) {
819%       bar(a,b);
820% }
821
822% //acquire a
823% void bar(monitor & mutex a,
824%            monitor & nomutex b) {
825
826%       wait(e); //release a
827%                 //keep b
828% }
829
830% foo(a, b);
831% \end{lstlisting} &\begin{lstlisting}
832% condition e;
833
834% //acquire a & b
835% void foo(monitor & mutex a,
836%            monitor & mutex b) {
837%       bar(a,b);
838% }
839
840% //acquire b
841% void bar(monitor & mutex a,
842%            monitor & nomutex b) {
843
844%       wait(e); //release b
845%                 //keep a
846% }
847
848% foo(a, b);
849% \end{lstlisting} &\begin{lstlisting}
850% condition e;
851
852% //acquire a & b
853% void foo(monitor & mutex a,
854%            monitor & mutex b) {
855%       bar(a,b);
856% }
857
858% //acquire none
859% void bar(monitor & nomutex a,
860%            monitor & nomutex b) {
861
862%       wait(e); //release a & b
863%                 //keep none
864% }
865
866% foo(a, b);
867% \end{lstlisting}
868% \end{tabular}
869% \end{center}
870% Note the right-most example is actually a trick pulled on the reader. Monitor state information is stored in thread local storage rather then in the routine context, which means that helper routines and other \code{nomutex} routines are invisible to the runtime system in regards to concurrency. This means that in the right-most example, the routine parameters are completly unnecessary. However, calling this routine from outside a valid monitor context is undefined.
871
872% These semantics imply that in order to release of subset of the monitors currently held, users must write (and name) a routine that only acquires the desired subset and simply calls wait. While users can use this method, \CFA offers the \code{wait_release}\footnote{Not sure if an overload of \code{wait} would work...} which will release only the specified monitors. In the center previous examples, the code in the center uses the \code{bar} routine to only release monitor \code{b}. Using the \code{wait_release} helper, this can be rewritten without having the name two routines :
873% \begin{center}
874% \begin{tabular}{ c c c }
875% \begin{lstlisting}
876%       condition e;
877
878%       //acquire a & b
879%       void foo(monitor & mutex a,
880%                  monitor & mutex b) {
881%               bar(a,b);
882%       }
883
884%       //acquire b
885%       void bar(monitor & mutex a,
886%                  monitor & nomutex b) {
887
888%               wait(e); //release b
889%                         //keep a
890%       }
891
892%       foo(a, b);
893% \end{lstlisting} &\begin{lstlisting}
894%       =>
895% \end{lstlisting} &\begin{lstlisting}
896%       condition e;
897
898%       //acquire a & b
899%       void foo(monitor & mutex a,
900%                  monitor & mutex b) {
901%               wait_release(e,b); //release b
902%                                        //keep a
903%       }
904
905%       foo(a, b);
906% \end{lstlisting}
907% \end{tabular}
908% \end{center}
909
910% Regardless of the context in which the \code{wait} statement is used, \code{signal} must be called holding the same set of monitors. In all cases, signal only needs a single parameter, the condition variable that needs to be signalled. But \code{signal} needs to be called from the same monitor(s) that call to \code{wait}. Otherwise, mutual exclusion cannot be properly transferred back to the waiting monitor.
911
912% Finally, an additional semantic which can be very usefull is the \code{signal_block} routine. This routine behaves like signal for all of the semantics discussed above, but with the subtelty that mutual exclusion is transferred to the waiting task immediately rather than wating for the end of the critical section.
913% \\
914
915% ####### #     # #######         #####   #####  #     # ####### ######
916% #        #   #     #           #     # #     # #     # #       #     #
917% #         # #      #           #       #       #     # #       #     #
918% #####      #       #            #####  #       ####### #####   #     #
919% #         # #      #    ###          # #       #     # #       #     #
920% #        #   #     #    ###    #     # #     # #     # #       #     #
921% ####### #     #    #    ###     #####   #####  #     # ####### ######
922\newpage
923\subsection{External scheduling} \label{extsched}
924An alternative to internal scheduling is to use external scheduling instead. This method is more constrained and explicit which may help users tone down the undeterministic nature of concurrency. Indeed, as the following examples demonstrates, external scheduling allows users to wait for events from other threads without the concern of unrelated events occuring. External scheduling can generally be done either in terms of control flow (ex: \uC) or in terms of data (ex: Go). Of course, both of these paradigms have their own strenghts and weaknesses but for this project control flow semantics where chosen to stay consistent with the rest of the languages semantics. Two challenges specific to \CFA arise when trying to add external scheduling with loose object definitions and multi-monitor routines. The following example shows a simple use \code{accept} versus \code{wait}/\code{signal} and its advantages.
925
926\begin{center}
927\begin{tabular}{|c|c|}
928Internal Scheduling & External Scheduling \\
929\hline
930\begin{lstlisting}
931        _Monitor blarg {
932                condition c;
933        public:
934                void f() { signal(c)}
935                void g() { wait(c); }
936        private:
937        }
938\end{lstlisting}&\begin{lstlisting}
939        _Monitor blarg {
940
941        public:
942                void f() { /*...*/ }
943                void g() { _Accept(f); }
944        private:
945        }
946\end{lstlisting}
947\end{tabular}
948\end{center}
949
950In the case of internal scheduling, the call to \code{wait} only guarantees that \code{g} is the last routine to access the monitor. This intails that the routine \code{f} may have acquired mutual exclusion several times while routine \code{h} was waiting. On the other hand, external scheduling guarantees that while routine \code{h} was waiting, no routine other than \code{g} could acquire the monitor.
951\\
952
953% #       ####### #######  #####  #######    ####### ######        #  #####
954% #       #     # #     # #     # #          #     # #     #       # #     #
955% #       #     # #     # #       #          #     # #     #       # #
956% #       #     # #     #  #####  #####      #     # ######        #  #####
957% #       #     # #     #       # #          #     # #     # #     #       #
958% #       #     # #     # #     # #          #     # #     # #     # #     #
959% ####### ####### #######  #####  #######    ####### ######   #####   #####
960
961\subsubsection{Loose object definitions}
962In \uC, monitor declarations include an exhaustive list of monitor operations. Since \CFA is not object oriented it becomes both more difficult to implement but also less clear for the user :
963
964\begin{lstlisting}
965        mutex struct A {};
966
967        void f(A & mutex a);
968        void g(A & mutex a) { accept(f); }
969\end{lstlisting}
970
971However, external scheduling is an example where implementation constraints become visible from the interface. Indeed, ince there is no hard limit to the number of threads trying to acquire a monitor concurrently, performance is a significant concern. Here is the pseudo code for the entering phase of a monitor :
972
973\begin{center}
974\begin{tabular}{l}
975\begin{lstlisting}[language=Pseudo]
976        if monitor is free :
977                enter
978        elif monitor accepts me :
979                enter
980        else :
981                block
982\end{lstlisting}
983\end{tabular}
984\end{center}
985
986For the \pseudo{monitor is free} condition it is easy to implement a check that can evaluate the condition in a few instruction. However, a fast check for \pseudo{monitor accepts me} is much harder to implement depending on the constraints put on the monitors. Indeed, monitors are often expressed as an entry queue and some acceptor queue as in the following figure :
987
988\begin{center}
989{\resizebox{0.4\textwidth}{!}{\input{monitor}}}
990\end{center}
991
992There are other alternatives to these pictures but in the case of this picture implementing a fast accept check is relatively easy. Indeed simply updating a bitmask when the acceptor queue changes is enough to have a check that executes in a single instruction, even with a fairly large number of acceptor. However, this relies on the fact that all the acceptable routines are declared with the monitor type. For OO languages this doesn't compromise much since monitors already have an exhaustive list of member routines. However, for \CFA this isn't the case, routines can be added to a type anywhere after its declaration. Its important to note that the bitmask approach does not actually require an exhaustive list of routines, but it requires a dense unique ordering of routines with an upper-bound and that ordering must be consistent across translation units.
993The alternative would be to have a picture more like this one:
994
995\begin{center}
996{\resizebox{0.4\textwidth}{!}{\input{ext_monitor}}}
997\end{center}
998
999Not storing the queues inside the monitor means that the storage can vary between routines, allowing for more flexibility and extensions. Storing an array of function-pointers would solve the issue of uniquely identifying acceptable routines. However, the single instruction bitmask compare has been replaced by dereferencing a pointer followed by a linear search. Furthermore, supporting nested external scheduling may now require additionnal searches on calls to accept to check if a routine is already queued in.
1000
1001At this point we must make a decision between flexibility and performance. Many design decisions in \CFA achieve both flexibility and performance, for example polymorphic routines add significant flexibility but inlining them means the optimizer can easily remove any runtime cost. Here however, the cost of flexibility cannot be trivially removed.
1002
1003In either cases here are a few alternatives for the different syntaxes this syntax : \\
1004\begin{center}
1005{\renewcommand{\arraystretch}{1.5}
1006\begin{tabular}[t]{l @{\hskip 0.35in} l}
1007\hline
1008\multicolumn{2}{ c }{\code{accept} on type}\\
1009\hline
1010Alternative 1 & Alternative 2 \\
1011\begin{lstlisting}
1012mutex struct A
1013accept( void f(A & mutex a) )
1014{};
1015\end{lstlisting} &\begin{lstlisting}
1016mutex struct A {}
1017accept( void f(A & mutex a) );
1018
1019\end{lstlisting} \\
1020Alternative 3 & Alternative 4 \\
1021\begin{lstlisting}
1022mutex struct A {
1023        accept( void f(A & mutex a) )
1024};
1025
1026\end{lstlisting} &\begin{lstlisting}
1027mutex struct A {
1028        accept :
1029                void f(A & mutex a) );
1030};
1031\end{lstlisting}\\
1032\hline
1033\multicolumn{2}{ c }{\code{accept} on routine}\\
1034\hline
1035\begin{lstlisting}
1036mutex struct A {};
1037
1038void f(A & mutex a)
1039
1040accept( void f(A & mutex a) )
1041void g(A & mutex a) {
1042        /*...*/
1043}
1044\end{lstlisting}&\\
1045\end{tabular}
1046}
1047\end{center}
1048
1049An other aspect to consider is what happens if multiple overloads of the same routine are used. For the time being it is assumed that multiple overloads of the same routine should be scheduled regardless of the overload used. However, this could easily be extended in the future.
1050
1051% #     # #     # #       ####### ###    #     # ####### #     #
1052% ##   ## #     # #          #     #     ##   ## #     # ##    #
1053% # # # # #     # #          #     #     # # # # #     # # #   #
1054% #  #  # #     # #          #     #     #  #  # #     # #  #  #
1055% #     # #     # #          #     #     #     # #     # #   # #
1056% #     # #     # #          #     #     #     # #     # #    ##
1057% #     #  #####  #######    #    ###    #     # ####### #     #
1058
1059\subsubsection{Multi-monitor scheduling}
1060
1061External scheduling, like internal scheduling, becomes orders of magnitude more complex when we start introducing multi-monitor syntax. Even in the simplest possible case some new semantics need to be established :
1062\begin{lstlisting}
1063        accept( void f(mutex struct A & mutex this))
1064        mutex struct A {};
1065
1066        mutex struct B {};
1067
1068        void g(A & mutex a, B & mutex b) {
1069                accept(f); //ambiguous, which monitor
1070        }
1071\end{lstlisting}
1072
1073The obvious solution is to specify the correct monitor as follows :
1074
1075\begin{lstlisting}
1076        accept( void f(mutex struct A & mutex this))
1077        mutex struct A {};
1078
1079        mutex struct B {};
1080
1081        void g(A & mutex a, B & mutex b) {
1082                accept( f, b );
1083        }
1084\end{lstlisting}
1085
1086This is unambiguous. Both locks will be acquired and kept, when routine \code{f} is called the lock for monitor \code{a} will be temporarily transferred from \code{g} to \code{f} (while \code{g} still holds lock \code{b}). This behavior can be extended to multi-monitor accept statment as follows.
1087
1088\begin{lstlisting}
1089        accept( void f(mutex struct A & mutex, mutex struct A & mutex))
1090        mutex struct A {};
1091
1092        mutex struct B {};
1093
1094        void g(A & mutex a, B & mutex b) {
1095                accept( f, b, a );
1096        }
1097\end{lstlisting}
1098
1099Note that the set of monitors passed to the \code{accept} statement must be entirely contained in the set of monitor already acquired in the routine. \code{accept} used in any other context is Undefined Behaviour.
1100
1101% ######  ####### #######    #    ### #        #####
1102% #     # #          #      # #    #  #       #     #
1103% #     # #          #     #   #   #  #       #
1104% #     # #####      #    #     #  #  #        #####
1105% #     # #          #    #######  #  #             #
1106% #     # #          #    #     #  #  #       #     #
1107% ######  #######    #    #     # ### #######  #####
1108%
1109%                #####  #     # ####### #     # #######  #####
1110%             #     # #     # #       #     # #       #     #
1111%             #     # #     # #       #     # #       #
1112%    #####    #     # #     # #####   #     # #####    #####
1113%             #   # # #     # #       #     # #             #
1114%             #    #  #     # #       #     # #       #     #
1115%                #### #  #####  #######  #####  #######  #####
1116
1117
1118\subsubsection{Implementation Details: External scheduling queues}
1119To support multi-monitor external scheduling means that some kind of entry-queues must be used that is aware of both monitors. However, acceptable routines must be aware of the entry queues which means they must be stored inside at least one of the monitors that will be acquired. This in turn adds the requirement a systematic algorithm of disambiguating which queue is relavant regardless of user ordering. The proposed algorithm is to fall back on monitors lock ordering and specify that the monitor that is acquired first is the lock with the relevant entry queue. This assumes that the lock acquiring order is static for the lifetime of all concerned objects but that is a reasonnable constraint. This algorithm choice has two consequences, the entry queue of the highest priority monitor is no longer a true FIFO queue and the queue of the lowest priority monitor is both required and probably unused. The queue can no longer be a FIFO queue because instead of simply containing the waiting threads in order arrival, they also contain the second mutex. Therefore, another thread with the same highest priority monitor but a different lowest priority monitor may arrive first but enter the critical section after a thread with the correct pairing. Secondly, since it may not be known at compile time which monitor will be the lowest priority monitor, every monitor needs to have the correct queues even though it is probable that half the multi-monitor queues will go unused for the entire duration of the program.
1120
1121\subsection{Other concurrency tools}
1122TO BE CONTINUED...
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133\newpage
1134% ######     #    ######     #    #       #       ####### #       ###  #####  #     #
1135% #     #   # #   #     #   # #   #       #       #       #        #  #     # ##   ##
1136% #     #  #   #  #     #  #   #  #       #       #       #        #  #       # # # #
1137% ######  #     # ######  #     # #       #       #####   #        #   #####  #  #  #
1138% #       ####### #   #   ####### #       #       #       #        #        # #     #
1139% #       #     # #    #  #     # #       #       #       #        #  #     # #     #
1140% #       #     # #     # #     # ####### ####### ####### ####### ###  #####  #     #
1141\section{Parallelism}
1142Historically, computer performance was about processor speeds and instructions count. However, with heat dissipation being a direct consequence of speed increase, parallelism has become the new source for increased performance~\cite{Sutter05, Sutter05b}. In this decade, it is not longer reasonnable to create a high-performance application without caring about parallelism. Indeed, parallelism is an important aspect of performance and more specifically throughput and hardware utilization. The lowest-level approach of parallelism is to use \glspl{kthread} in combination with semantics like \code{fork}, \code{join}, etc. However, since these have significant costs and limitations, \glspl{kthread} are now mostly used as an implementation tool rather than a user oriented one. There are several alternatives to solve these issues that all have strengths and weaknesses. While there are many variations of the presented paradigms, most of these variations do not actually change the guarantees or the semantics, they simply move costs in order to achieve better performance for certain workloads.
1143
1144\subsection{User-level threads}
1145A direct improvement on the \gls{kthread} approach is to use \glspl{uthread}. These threads offer most of the same features that the operating system already provide but can be used on a much larger scale. This approach is the most powerfull solution as it allows all the features of multi-threading, while removing several of the more expensives costs of using kernel threads. The down side is that almost none of the low-level threading problems are hidden, users still have to think about data races, deadlocks and synchronization issues. These issues can be somewhat alleviated by a concurrency toolkit with strong garantees but the parallelism toolkit offers very little to reduce complexity in itself.
1146
1147Examples of languages that support \glspl{uthread} are Erlang~\cite{Erlang} and \uC~\cite{uC++book}.
1148
1149\subsubsection{Fibers : user-level threads without preemption}
1150A popular varient of \glspl{uthread} is what is often reffered to as \glspl{fiber}. However, \glspl{fiber} do not present meaningful semantical differences with \glspl{uthread}. Advocates of \glspl{fiber} list their high performance and ease of implementation as majors strenghts of \glspl{fiber} but the performance difference between \glspl{uthread} and \glspl{fiber} is controversial and the ease of implementation, while true, is a weak argument in the context of language design. Therefore this proposal largely ignore fibers.
1151
1152An example of a language that uses fibers is Go~\cite{Go}
1153
1154\subsection{Jobs and thread pools}
1155The approach on the opposite end of the spectrum is to base parallelism on \glspl{pool}. Indeed, \glspl{pool} offer limited flexibility but at the benefit of a simpler user interface. In \gls{pool} based systems, users express parallelism as units of work and a dependency graph (either explicit or implicit) that tie them together. This approach means users need not worry about concurrency but significantly limits the interaction that can occur among jobs. Indeed, any \gls{job} that blocks also blocks the underlying worker, which effectively means the CPU utilization, and therefore throughput, suffers noticeably. It can be argued that a solution to this problem is to use more workers than available cores. However, unless the number of jobs and the number of workers are comparable, having a significant amount of blocked jobs always results in idles cores.
1156
1157The gold standard of this implementation is Intel's TBB library~\cite{TBB}.
1158
1159\subsection{Paradigm performance}
1160While the choice between the three paradigms listed above may have significant performance implication, it is difficult to pindown the performance implications of chosing a model at the language level. Indeed, in many situations one of these paradigms may show better performance but it all strongly depends on the workload. Having a large amount of mostly independent units of work to execute almost guarantess that the \gls{pool} based system has the best performance thanks to the lower memory overhead. However, interactions between jobs can easily exacerbate contention. User-level threads allow fine-grain context switching, which results in better resource utilisation, but context switches will be more expansive and the extra control means users need to tweak more variables to get the desired performance. Furthermore, if the units of uninterrupted work are large enough the paradigm choice is largely amorticised by the actual work done.
1161
1162%  #####  #######    #          ####### ######  ######
1163% #     # #         # #            #    #     # #     #
1164% #       #        #   #           #    #     # #     #
1165% #       #####   #     # #####    #    ######  ######
1166% #       #       #######          #    #     # #     #
1167% #     # #       #     #          #    #     # #     #
1168%  #####  #       #     #          #    ######  ######
1169
1170\section{\CFA 's Thread Building Blocks}
1171As a system-level language, \CFA should offer both performance and flexibilty as its primary goals, simplicity and user-friendliness being a secondary concern. Therefore, the core of parallelism in \CFA should prioritize power and efficiency. With this said, deconstructing popular paradigms in order to get simple building blocks yields \glspl{uthread} as the core parallelism block. \Glspl{pool} and other parallelism paradigms can then be built on top of the underlying threading model.
1172
1173\subsection{Coroutines : A stepping stone}\label{coroutine}
1174While the main focus of this proposal is concurrency and paralellism, it is important to adress coroutines which are actually a significant underlying aspect of the concurrency system. Indeed, while having nothing todo with parallelism and arguably very little to do with concurrency, coroutines need to deal with context-switchs and and other context management operations. Therefore, this proposal includes coroutines both as an intermediate step for the implementation of threads and a first class feature of \CFA.
1175
1176The core API of coroutines revolve around two features : independent stacks and \code{suspend}/\code{resume}.
1177Here is an example of a solution to the fibonnaci problem using \CFA coroutines :
1178\begin{lstlisting}
1179        struct Fibonacci {
1180              int fn; // used for communication
1181              coroutine_descriptor c;
1182        };
1183
1184        void ?{}(Fibonacci* this) {
1185              this->fn = 0;
1186        }
1187
1188        coroutine_descriptor* get_¶coroutine¶(Fibonacci* this) {
1189              return &this->c;
1190        }
1191
1192        void co_main(Fibonacci* this) {
1193                int fn1, fn2;           // retained between resumes
1194                this->fn = 0;
1195                fn1 = this->fn;
1196                suspend(this);          // return to last resume
1197
1198                this->fn = 1;
1199                fn2 = fn1;
1200                fn1 = this->fn;
1201                suspend(this);          // return to last resume
1202
1203                for ( ;; ) {
1204                        this->fn = fn1 + fn2;
1205                        fn2 = fn1;
1206                        fn1 = this->fn;
1207                        suspend(this);  // return to last resume
1208                }
1209        }
1210
1211        int next(Fibonacci* this) {
1212                resume(this); // transfer to last suspend
1213                return this.fn;
1214        }
1215
1216        void main() {
1217                Fibonacci f1, f2;
1218                for ( int i = 1; i <= 10; i += 1 ) {
1219                        sout | next(&f1) | '§\verb+ +§' | next(&f2) | endl;
1220                }
1221        }
1222\end{lstlisting}
1223
1224\subsubsection{Construction}
1225One important design challenge for coroutines and threads (shown in section \ref{threads}) is that the runtime system needs to run some code after the user-constructor runs. In the case of the coroutines this challenge is simpler since there is no loss of determinism brough by preemption or scheduling, however, the underlying challenge remains the same for coroutines and threads.
1226
1227The runtime system needs to create the coroutine's stack and more importantly prepare it for the first resumption. The timing of the creation is non trivial since users both expect to have fully constructed objects once the main is called and to be able to resume the coroutine from the main (Obviously we only solve cases where these two statements don't conflict). There are several solutions to this problem but the chosen options effectively forces the design of the coroutine.
1228
1229Furthermore, \CFA faces an extra challenge which is that polymorphique routines rely on invisible thunks when casted to non-polymorphic routines and these thunks have function scope, for example :
1230
1231TODO : Simple case where a thunk would be created.
1232
1233
1234
1235\subsubsection{Alternative: Inheritance}
1236One solution to this challenge would be to use inheritence,
1237
1238\begin{lstlisting}
1239        struct Fibonacci {
1240              int fn; // used for communication
1241              coroutine c;
1242        };
1243
1244        void ?{}(Fibonacci* this) {
1245              this->fn = 0;
1246                (&this->c){};
1247        }
1248\end{lstlisting}
1249
1250There are two downsides to the approach. The first, which is relatively minor, is that the base class needs to be made aware of the main routine pointer, regardless of whether we use a parameter or a virtual pointer, this means the coroutine data must be made larger to store a value that is actually a compile time constant (The address of the main routine). The second problem which is both subtle but significant, is that now can get the initialisation order of there coroutines wrong. Indeed, every field of a \CFA struct will be constructed but in the order of declaration, unless users explicitly write otherwise. This means that users who forget to initialize a the coroutine at the right time may resume the coroutine at with an uninitilized object. For coroutines, this is unlikely to be a problem, for threads however, this is a significant problem.
1251
1252\subsubsection{Alternative: Reserved keyword}
1253The next alternative is to use language support to annotate coroutines as follows :
1254
1255\begin{lstlisting}
1256        coroutine struct Fibonacci {
1257              int fn; // used for communication
1258        };
1259\end{lstlisting}
1260
1261This mean the compiler can solve problems by injecting code where needed. The downside of this approach is that it makes coroutine a special case in the language. Users who would want to extend coroutines or build their own for various reasons can only do so in ways offered by the language. Furthermore, implementing coroutines without language supports also displays the power of \CFA.
1262
1263\subsubsection{Alternative: Lamda Objects}
1264
1265Boost does not use objects...
1266TO BE CONTINUED...
1267
1268\subsubsection{Trait based coroutines}
1269
1270Finally the approach chosen, which is the one closest to \CFA idioms, is to use trait-based lazy coroutines, the approach shown in section \ref{coroutine}. This approach defines a coroutine as anything that satisfies the \code{is_coroutine} and is used as a coroutine is a coroutine. This entails the an object is not a coroutine until \code{resume} (and \code{prime}) is called on the object. Correspondingly, any object that is passed to \code{resume} is a coroutine since it must satisfy the \code{is_coroutine} trait to compile.
1271
1272% ####### #     # ######  #######    #    ######   #####
1273%    #    #     # #     # #         # #   #     # #     #
1274%    #    #     # #     # #        #   #  #     # #
1275%    #    ####### ######  #####   #     # #     #  #####
1276%    #    #     # #   #   #       ####### #     #       #
1277%    #    #     # #    #  #       #     # #     # #     #
1278%    #    #     # #     # ####### #     # ######   #####
1279
1280\subsection{Thread Interface}\label{threads}
1281The basic building blocks of \CFA are \glspl{cfathread}. By default these are implemented as \glspl{uthread}, and as such, offer a flexible and lightweight threading interface (lightweight compared to \glspl{kthread}). A thread can be declared using a struct declaration with prefix \code{thread} as follows :
1282
1283\begin{lstlisting}
1284        trait is_¶thread¶(dtype T) {
1285                void co_main(T* this);
1286                coroutine* get_coroutine(T* this);
1287        };
1288
1289        thread struct foo {};
1290\end{lstlisting}
1291
1292Obviously, for this thread implementation to be usefull it must run some user code. Several other threading interfaces use a function-pointer representation as the interface of threads (for example : \Csharp~\cite{Csharp} and Scala~\cite{Scala}). However, this proposal considers that statically tying a \code{main} routine to a thread superseeds this approach. Since the \code{main} routine is already a special routine in \CFA (where the program begins), the existing syntax for declaring routines names with special semantics can be extended, i.e. operator overloading. As such the \code{main} routine of a thread can be defined as :
1293\begin{lstlisting}
1294        thread struct foo {};
1295
1296        void ?main(foo* this) {
1297                sout | "Hello World!" | endl;
1298        }
1299\end{lstlisting}
1300
1301In this example, threads of type \code{foo} will start there execution in the \code{void ?main(foo*)} routine which in this case prints \code{"Hello World!"}. While this proposoal encourages this approach which is enforces strongly type programming. Users may prefer to use the routine based thread semantics for the sake of simplicity. With these semantics it is trivial to write a thread type that takes a function pointer as parameter and executes it on its stack asynchronously :
1302\begin{lstlisting}
1303        typedef void (*voidFunc)(void);
1304
1305        thread struct FuncRunner {
1306                voidFunc func;
1307        };
1308
1309        //ctor
1310        void ?{}(FuncRunner* this, voidFunc inFunc) {
1311                func = inFunc;
1312        }
1313
1314        //main
1315        void t_main(FuncRunner* this) {
1316                this->func();
1317        }
1318\end{lstlisting}
1319
1320Of course for threads to be useful, it must be possible to start and stop threads and wait for them to complete execution. While using an \acrshort{api} such as \code{fork} and \code{join} is relatively common in the literature, such an interface is unnecessary. Indeed, the simplest approach is to use \acrshort{raii} principles and have threads \code{fork} once the constructor has completed and \code{join} before the destructor runs.
1321\begin{lstlisting}
1322thread struct World; //FuncRunner declared above
1323
1324void ?main(thread World* this) {
1325        sout | "World!" | endl;
1326}
1327
1328void main() {
1329        World w;
1330        //Thread run forks here
1331
1332        //Print to "Hello " and "World!" will be run concurrently
1333        sout | "Hello " | endl;
1334
1335        //Implicit join at end of scope
1336}
1337\end{lstlisting}
1338This semantic has several advantages over explicit semantics : typesafety is guaranteed, a thread is always started and stopped exaclty once and users cannot make any progamming errors. However, one of the apparent drawbacks of this system is that threads now always form a lattice, that is they are always destroyed in opposite order of construction. While this seems like a significant limitation, existing \CFA semantics can solve this problem. Indeed, by using dynamic allocation to create threads will naturally let threads outlive the scope in which the thread was created much like dynamically allocating memory will let objects outlive the scope in which thy were created :
1339
1340\begin{lstlisting}
1341        thread struct MyThread {
1342                //...
1343        };
1344
1345        //ctor
1346        void ?{}(MyThread* this,
1347                     bool is_special = false) {
1348                //...
1349        }
1350
1351        //main
1352        void ?main(MyThread* this) {
1353                //...
1354        }
1355
1356        void foo() {
1357                MyThread* special_thread;
1358                {
1359                        MyThread thrds = {false};
1360                        //Start a thread at the beginning of the scope
1361
1362                        DoStuff();
1363
1364                        //create a other thread that will outlive the thread in this scope
1365                        special_thread = new MyThread{true};
1366
1367                        //Wait for the thread to finish
1368                }
1369                DoMoreStuff();
1370
1371                //Now wait for the special
1372        }
1373\end{lstlisting}
1374
1375Another advantage of this semantic is that it naturally scale to multiple threads meaning basic synchronisation is very simple :
1376
1377\begin{lstlisting}
1378        thread struct MyThread {
1379                //...
1380        };
1381
1382        //ctor
1383        void ?{}(MyThread* this) {}
1384
1385        //main
1386        void ?main(MyThread* this) {
1387                //...
1388        }
1389
1390        void foo() {
1391                MyThread thrds[10];
1392                //Start 10 threads at the beginning of the scope
1393
1394                DoStuff();
1395
1396                //Wait for the 10 threads to finish
1397        }
1398\end{lstlisting}
1399
1400\newpage
1401\bf{WORK IN PROGRESS}
1402\subsection{The \CFA Kernel : Processors, Clusters and Threads}\label{kernel}
1403
1404
1405\subsection{Paradigms}\label{cfaparadigms}
1406Given these building blocks we can then reproduce the all three of the popular paradigms. Indeed, we get \glspl{uthread} as the default paradigm in \CFA. However, disabling \glspl{preemption} on the \gls{cfacluster} means \glspl{cfathread} effectively become \glspl{fiber}. Since several \glspl{cfacluster} with different scheduling policy can coexist in the same application, this allows \glspl{fiber} and \glspl{uthread} to coexist in the runtime of an application.
1407
1408% \subsection{High-level options}\label{tasks}
1409%
1410% \subsubsection{Thread interface}
1411% constructors destructors
1412%       initializer lists
1413% monitors
1414%
1415% \subsubsection{Futures}
1416%
1417% \subsubsection{Implicit threading}
1418% Finally, simpler applications can benefit greatly from having implicit parallelism. That is, parallelism that does not rely on the user to write concurrency. This type of parallelism can be achieved both at the language level and at the system level.
1419%
1420% \begin{center}
1421% \begin{tabular}[t]{|c|c|c|}
1422% Sequential & System Parallel & Language Parallel \\
1423% \begin{lstlisting}
1424% void big_sum(int* a, int* b,
1425%                int* out,
1426%                size_t length)
1427% {
1428%       for(int i = 0; i < length; ++i ) {
1429%               out[i] = a[i] + b[i];
1430%       }
1431% }
1432%
1433%
1434%
1435%
1436%
1437% int* a[10000];
1438% int* b[10000];
1439% int* c[10000];
1440% //... fill in a and b ...
1441% big_sum(a, b, c, 10000);
1442% \end{lstlisting} &\begin{lstlisting}
1443% void big_sum(int* a, int* b,
1444%                int* out,
1445%                size_t length)
1446% {
1447%       range ar(a, a + length);
1448%       range br(b, b + length);
1449%       range or(out, out + length);
1450%       parfor( ai, bi, oi,
1451%       [](int* ai, int* bi, int* oi) {
1452%               oi = ai + bi;
1453%       });
1454% }
1455%
1456% int* a[10000];
1457% int* b[10000];
1458% int* c[10000];
1459% //... fill in a and b ...
1460% big_sum(a, b, c, 10000);
1461% \end{lstlisting}&\begin{lstlisting}
1462% void big_sum(int* a, int* b,
1463%                int* out,
1464%                size_t length)
1465% {
1466%       for (ai, bi, oi) in (a, b, out) {
1467%               oi = ai + bi;
1468%       }
1469% }
1470%
1471%
1472%
1473%
1474%
1475% int* a[10000];
1476% int* b[10000];
1477% int* c[10000];
1478% //... fill in a and b ...
1479% big_sum(a, b, c, 10000);
1480% \end{lstlisting}
1481% \end{tabular}
1482% \end{center}
1483%
1484% \subsection{Machine setup}\label{machine}
1485% Threads are all good and well but wee still some OS support to fully utilize available hardware.
1486%
1487% \textbf{\large{Work in progress...}} Do wee need something beyond specifying the number of kernel threads?
1488
1489%    #    #       #
1490%   # #   #       #
1491%  #   #  #       #
1492% #     # #       #
1493% ####### #       #
1494% #     # #       #
1495% #     # ####### #######
1496\section{Putting it all together}
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507% ####### #     # ####### #     # ######  #######
1508% #       #     #    #    #     # #     # #
1509% #       #     #    #    #     # #     # #
1510% #####   #     #    #    #     # ######  #####
1511% #       #     #    #    #     # #   #   #
1512% #       #     #    #    #     # #    #  #
1513% #        #####     #     #####  #     # ######
1514\section{Future work}
1515Concurrency and parallelism is still a very active field that strongly benefits from hardware advances. As such certain features that aren't necessarily mature enough in their current state could become relevant in the lifetime of \CFA.
1516\subsection{Transactions}
1517
1518% ####### #     # ######
1519% #       ##    # #     #
1520% #       # #   # #     #
1521% #####   #  #  # #     #
1522% #       #   # # #     #
1523% #       #    ## #     #
1524% ####### #     # ######
1525\section*{Acknowledgements}
1526
1527\clearpage
1528\printglossary[type=\acronymtype]
1529\printglossary
1530
1531\clearpage
1532\bibliographystyle{plain}
1533\bibliography{cw92,distSharedMem,lfp92,mlw92,parallel,parallelIO,partheory,pl,pldi92,ps,realtime,techreportsPAB,visual,local}
1534
1535
1536\end{document}
Note: See TracBrowser for help on using the repository browser.