Changeset cf966b5 for doc/proposals/concurrency/text/together.tex
- Timestamp:
- Nov 28, 2017, 3:52:01 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 6c2ba38
- Parents:
- f7a4f89
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/proposals/concurrency/text/together.tex
rf7a4f89 rcf966b5 7 7 8 8 \section{Threads as monitors} 9 As it was subtly alluded in section \ref{threads}, \code{threads} in \CFA are in fact monitors, which means that all monitor features are available when using threads. For example, here is a very simple two thread pipeline that could be used for a simulator of a game engine : 10 \begin{cfacode} 9 As it was subtly alluded in section \ref{threads}, \code{thread}s in \CFA are in fact monitors, which means that all monitor features are available when using threads. For example, here is a very simple two thread pipeline that could be used for a simulator of a game engine : 10 \begin{figure}[H] 11 \begin{cfacode}[caption={Toy simulator using \code{thread}s and \code{monitor}s.},label={lst:engine-v1}] 11 12 // Visualization declaration 12 13 thread Renderer {} renderer; … … 36 37 } 37 38 \end{cfacode} 39 \end{figure} 38 40 One of the obvious complaints of the previous code snippet (other than its toy-like simplicity) is that it does not handle exit conditions and just goes on forever. Luckily, the monitor semantics can also be used to clearly enforce a shutdown order in a concise manner : 39 \begin{cfacode} 41 \begin{figure}[H] 42 \begin{cfacode}[caption={Same toy simulator with proper termination condition.},label={lst:engine-v2}] 40 43 // Visualization declaration 41 44 thread Renderer {} renderer; … … 76 79 // Call destructor for renderer to signify shutdown 77 80 \end{cfacode} 81 \end{figure} 78 82 79 83 \section{Fibers \& Threads} … … 84 88 } 85 89 \end{cfacode} 86 This function is called by the kernel to fetch the default preemption rate, where 0 signifies an infinite time-slice i.e. no preemption. However, once clusters are fully implemented, it will be possible to create fibers and uthreads in on the same system :90 This function is called by the kernel to fetch the default preemption rate, where 0 signifies an infinite time-slice, i.e., no preemption. However, once clusters are fully implemented, it will be possible to create fibers and \glspl{uthread} in the same system, as in listing \ref{lst:fiber-uthread} 87 91 \begin{figure} 88 \begin{cfacode} 92 \begin{cfacode}[caption={Using fibers and \glspl{uthread} side-by-side in \CFA},label={lst:fiber-uthread}] 89 93 //Cluster forward declaration 90 94 struct cluster;
Note: See TracChangeset
for help on using the changeset viewer.