Changes in / [e3282fe:4432b52]
- Location:
- doc
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/bibliography/pl.bib
re3282fe r4432b52 961 961 title = {C Programming Language {ISO/IEC} 9899:1999(E)}, 962 962 edition = {2nd}, 963 publisher= {International Standard Organization},964 address = { \href{https://webstore.ansi.org/Standards/INCITS/INCITSISOIEC98991999R2005}{https://webstore.ansi.org/\-Standards/\-INCITS/\-INCITSISOIEC98991999R2005}},963 organization= {International Standard Organization}, 964 address = {Geneva, Switzerland}, 965 965 year = 1999, 966 note = {\href{https://webstore.ansi.org/Standards/INCITS/INCITSISOIEC98991999R2005}{https://webstore.ansi.org/\-Standards/\-INCITS/\-INCITSISOIEC98991999R2005}}, 966 967 } 967 968 … … 972 973 title = {C Programming Language {ISO/IEC} 9889:2011-12}, 973 974 edition = {3rd}, 974 publisher= {International Standard Organization},975 address = { \href{https://www.iso.org/standard/57853.html}{https://\-www.iso.org/\-standard/\-57853.html}},975 organization= {International Standard Organization}, 976 address = {Geneva, Switzerland}, 976 977 year = 2012, 978 note = {\href{https://www.iso.org/standard/57853.html}{https://\-www.iso.org/\-standard/\-57853.html}}, 977 979 } 978 980 … … 982 984 key = {Concepts}, 983 985 title = {{C}{\kern-.1em\hbox{\large\texttt{+\kern-.25em+}}} Programming language -- Extensions for concepts {ISO/IEC} {TS} 19217:2015}, 984 publisher= {International Standard Organization},985 address = { \href{https://www.iso.org/standard/64031.html}{https://\-www.iso.org/\-standard/\-64031.html}},986 organization= {International Standard Organization}, 987 address = {Geneva, Switzerland}, 986 988 year = 2015, 989 note = {\href{https://www.iso.org/standard/64031.html}{https://\-www.iso.org/\-standard/\-64031.html}}, 987 990 } 988 991 … … 1149 1152 title = {C\# Language Specification, Standard ECMA-334}, 1150 1153 organization= {ECMA International Standardizing Information and Communication Systems}, 1154 address = {Geneva, Switzerland}, 1151 1155 month = jun, 1152 1156 year = 2006, … … 1298 1302 title = {Programming Languages -- {Cobol} ISO/IEC 1989:2014}, 1299 1303 edition = {2nd}, 1300 institution= {International Standard Organization},1301 address = { \href{https://www.iso.org/standard/51416.html}{https://\-www.iso.org/\-standard/\-51416.html}},1304 organization= {International Standard Organization}, 1305 address = {Geneva, Switzerland}, 1302 1306 year = 2014, 1307 note = {\href{https://www.iso.org/standard/51416.html}{https://\-www.iso.org/\-standard/\-51416.html}}, 1303 1308 } 1304 1309 … … 1654 1659 title = {$\mu${C}{\kern-.1em\hbox{\large\texttt{+\kern-.25em+}}} Annotated Reference Manual, Version 7.0.0}, 1655 1660 organization= {University of Waterloo}, 1661 address = {Waterloo Ontario, Canada}, 1656 1662 month = sep, 1657 1663 year = 2018, … … 2086 2092 author = {Walter Bright and Andrei Alexandrescu}, 2087 2093 organization= {Digital Mars}, 2094 address = {Vienna Virginia, U.S.A.}, 2088 2095 year = 2016, 2089 2096 note = {\href{http://dlang.org/spec/spec.html}{http://\-dlang.org/\-spec/\-spec.html}}, … … 3353 3360 title = {Programming Languages -- {Fortran} Part 1:Base Language ISO/IEC 1539-1:2010}, 3354 3361 edition = {3rd}, 3355 publisher= {International Standard Organization},3356 address = { \href{https://www.iso.org/standard/50459.html}{https://\-www.iso.org/\-standard/\-50459.html}},3362 organization= {International Standard Organization}, 3363 address = {Geneva, Switzerland}, 3357 3364 year = 2010, 3365 note = {\href{https://www.iso.org/standard/50459.html}{https://\-www.iso.org/\-standard/\-50459.html}}, 3358 3366 } 3359 3367 … … 3364 3372 title = {Programming Languages -- {Fortran} Part 1:Base Language ISO/IEC 1539-1:2018}, 3365 3373 edition = {4rd}, 3366 publisher= {International Standard Organization},3367 address = { \href{https://www.iso.org/standard/72320.html}{https://\-www.iso.org/\-standard/\-72320.html}},3374 organization= {International Standard Organization}, 3375 address = {Geneva, Switzerland}, 3368 3376 year = 2018, 3377 note = {\href{https://www.iso.org/standard/72320.html}{https://\-www.iso.org/\-standard/\-72320.html}}, 3369 3378 } 3370 3379 … … 4744 4753 address = {New York, NY, USA}, 4745 4754 } 4755 4746 4756 @techreport{Mesa, 4747 4757 keywords = {monitors, packages}, … … 4750 4760 title = {Mesa Language Manual}, 4751 4761 institution = {Xerox Palo Alto Research Center}, 4762 address = {Palo Alto, California, U.S.A.}, 4752 4763 number = {CSL--79--3}, 4753 4764 month = apr, … … 6301 6312 title = {{C}{\kern-.1em\hbox{\large\texttt{+\kern-.25em+}}} Programming Language ISO/IEC 14882:1998}, 6302 6313 edition = {1st}, 6303 publisher= {International Standard Organization},6304 address = { \href{https://www.iso.org/standard/25845.html}{https://\-www.iso.org/\-standard/\-25845.html}},6314 organization = {International Standard Organization}, 6315 address = {Geneva, Switzerland}, 6305 6316 year = 1998, 6317 note = {\href{https://www.iso.org/standard/25845.html}{https://\-www.iso.org/\-standard/\-25845.html}}, 6306 6318 } 6307 6319 … … 6312 6324 title = {{C}{\kern-.1em\hbox{\large\texttt{+\kern-.25em+}}} Programming Language ISO/IEC 14882:2014}, 6313 6325 edition = {4th}, 6314 publisher= {International Standard Organization},6315 address = { \href{https://www.iso.org/standard/64029.html}{https://\-www.iso.org/\-standard/\-64029.html}},6326 organization= {International Standard Organization}, 6327 address = {Geneva, Switzerland}, 6316 6328 year = 2014, 6329 note = {\href{https://www.iso.org/standard/64029.html}{https://\-www.iso.org/\-standard/\-64029.html}}, 6317 6330 } 6318 6331 … … 6323 6336 title = {{C}{\kern-.1em\hbox{\large\texttt{+\kern-.25em+}}} Programming Language ISO/IEC 14882:2017}, 6324 6337 edition = {5th}, 6325 publisher= {International Standard Organization},6326 address = { \href{https://www.iso.org/standard/68564.html}{https://\-www.iso.org/\-standard/\-68564.html}},6338 organization= {International Standard Organization}, 6339 address = {Geneva, Switzerland}, 6327 6340 year = 2017, 6341 note = {\href{https://www.iso.org/standard/68564.html}{https://\-www.iso.org/\-standard/\-68564.html}}, 6328 6342 } 6329 6343 … … 6457 6471 title = {The Programming Language Concurrent Pascal}, 6458 6472 journal = ieeese, 6459 volume = 2, 6473 volume = {SE-1}, 6474 number = 2, 6460 6475 month = jun, 6461 6476 year = 1975, 6462 pages = {199-20 6}6477 pages = {199-207} 6463 6478 } 6464 6479 … … 6719 6734 title = {Programming languages -- {Ada} ISO/IEC 8652:2012}, 6720 6735 edition = {3rd}, 6721 publisher= {International Standard Organization},6722 address = { \href{https://www.iso.org/standard/61507.html}{https://\-www.iso.org/\-standard/\-61507.html}},6736 organization= {International Standard Organization}, 6737 address = {Geneva, Switzerland}, 6723 6738 year = 2012, 6739 note = {\href{https://www.iso.org/standard/61507.html}{https://\-www.iso.org/\-standard/\-61507.html}}, 6724 6740 } 6725 6741 … … 7726 7742 title = {The Thoth System: Multi-Process Structuring and Portability}, 7727 7743 publisher = {American Elsevier}, 7744 address = {New York, New York, U.S.A.}, 7728 7745 year = 1982 7729 7746 } -
doc/papers/concurrency/Paper.tex
re3282fe r4432b52 110 110 \newcommand{\abbrevFont}{\textit} % set empty for no italics 111 111 \@ifundefined{eg}{ 112 \newcommand{\EG}{\abbrevFont{e}\abbrevFont{g}} 112 %\newcommand{\EG}{\abbrevFont{e}\abbrevFont{g}} 113 \newcommand{\EG}{for example} 113 114 \newcommand*{\eg}{% 114 115 \@ifnextchar{,}{\EG}% … … 117 118 }}{}% 118 119 \@ifundefined{ie}{ 119 \newcommand{\IE}{\abbrevFont{i}\abbrevFont{e}} 120 %\newcommand{\IE}{\abbrevFont{i}\abbrevFont{e}} 121 \newcommand{\IE}{that is} 120 122 \newcommand*{\ie}{% 121 123 \@ifnextchar{,}{\IE}% … … 264 266 \address[1]{\orgdiv{Cheriton School of Computer Science}, \orgname{University of Waterloo}, \orgaddress{\state{Waterloo, ON}, \country{Canada}}} 265 267 266 \corres{*Peter A. Buhr, Cheriton School of Computer Science, University of Waterloo, 200 University Avenue West, Waterloo, ON ,N2L 3G1, Canada. \email{pabuhr{\char`\@}uwaterloo.ca}}268 \corres{*Peter A. Buhr, Cheriton School of Computer Science, University of Waterloo, 200 University Avenue West, Waterloo, ON N2L 3G1, Canada. \email{pabuhr{\char`\@}uwaterloo.ca}} 267 269 268 270 % \fundingInfo{Natural Sciences and Engineering Research Council of Canada} 269 271 270 272 \abstract[Summary]{ 271 \CFA is a polymorphic, non -object-oriented, concurrent, backwards compatible extension of the C programming language.273 \CFA is a polymorphic, nonobject-oriented, concurrent, backwards compatible extension of the C programming language. 272 274 This paper discusses the design philosophy and implementation of its advanced control-flow and concurrent/parallel features, along with the supporting runtime written in \CFA. 273 275 These features are created from scratch as ISO C has only low-level and/or unimplemented concurrency, so C programmers continue to rely on library approaches like pthreads. … … 280 282 }% 281 283 282 \keywords{ generator, coroutine, concurrency, parallelism, thread, monitor, runtime, C, \CFA (Cforall)}284 \keywords{C \CFA (Cforall) coroutine concurrency generator monitor parallelism runtime thread} 283 285 284 286 … … 291 293 \section{Introduction} 292 294 293 \CFA~\cite{Moss18,Cforall} is a modern, polymorphic, non -object-oriented\footnote{295 \CFA~\cite{Moss18,Cforall} is a modern, polymorphic, nonobject-oriented\footnote{ 294 296 \CFA has object-oriented features, such as constructors, destructors, and simple trait/interface inheritance. 295 297 % Go interfaces, Rust traits, Swift Protocols, Haskell Type Classes and Java Interfaces. … … 298 300 % Java, Rust, and Haskell (not sure about Swift) have nominal inheritance, where there needs to be a specific statement that "this type inherits from this type". 299 301 However, functions \emph{cannot} be nested in structures and there is no mechanism to designate a function parameter as a receiver, \lstinline@this@, parameter.}, 300 backwards-compatible extension of the C programming language.302 , backward-compatible extension of the C programming language. 301 303 In many ways, \CFA is to C as Scala~\cite{Scala} is to Java, providing a vehicle for new typing and control-flow capabilities on top of a highly popular programming language\footnote{ 302 304 The TIOBE index~\cite{TIOBE} for May 2020 ranks the top five \emph{popular} programming languages as C 17\%, Java 16\%, Python 9\%, \CC 6\%, and \Csharp 4\% = 52\%, and over the past 30 years, C has always ranked either first or second in popularity.} … … 309 311 The \CFA control-flow framework extends ISO \Celeven~\cite{C11} with new call/return and concurrent/parallel control-flow. 310 312 Call/return control-flow with argument and parameter passing appeared in the first programming languages. 311 Over the past 50 years, call/return has been augmented with features like static and dynamic call, exceptions (multi -level return) and generators/coroutines (see Section~\ref{s:StatefulFunction}).313 Over the past 50 years, call/return has been augmented with features like static and dynamic call, exceptions (multilevel return) and generators/coroutines (see Section~\ref{s:StatefulFunction}). 312 314 While \CFA has mechanisms for dynamic call (algebraic effects~\cite{Zhang19}) and exceptions\footnote{ 313 315 \CFA exception handling will be presented in a separate paper. 314 The key feature that dovetails with this paper is nonlocal exceptions allowing exceptions to be raised across stacks, with synchronous exceptions raised among coroutines and asynchronous exceptions raised among threads, similar to that in \uC~\cite[\S~5]{uC++}}, this work only discusses retaining state between calls via generators and coroutines. 315 \newterm{Coroutining} was introduced by Conway~\cite{Conway63} (1963), discussed by Knuth~\cite[\S~1.4.2]{Knuth73V1}, implemented in Simula67~\cite{Simula67}, formalized by Marlin~\cite{Marlin80}, and is now popular and appears in old and new programming languages: CLU~\cite{CLU}, \Csharp~\cite{Csharp}, Ruby~\cite{Ruby}, Python~\cite{Python}, JavaScript~\cite{JavaScript}, Lua~\cite{Lua}, \CCtwenty~\cite{C++20Coroutine19}. 316 The key feature that dovetails with this paper is nonlocal exceptions allowing exceptions to be raised across stacks, with synchronous exceptions raised among coroutines and asynchronous exceptions raised among threads, similar to that in \uC~\cite[\S~5]{uC++}} 317 , this work only discusses retaining state between calls via generators and coroutines. 318 \newterm{Coroutining} was introduced by Conway~\cite{Conway63}, discussed by Knuth~\cite[\S~1.4.2]{Knuth73V1}, implemented in Simula67~\cite{Simula67}, formalized by Marlin~\cite{Marlin80}, and is now popular and appears in old and new programming languages: CLU~\cite{CLU}, \Csharp~\cite{Csharp}, Ruby~\cite{Ruby}, Python~\cite{Python}, JavaScript~\cite{JavaScript}, Lua~\cite{Lua}, \CCtwenty~\cite{C++20Coroutine19}. 316 319 Coroutining is sequential execution requiring direct handoff among coroutines, \ie only the programmer is controlling execution order. 317 320 If coroutines transfer to an internal event-engine for scheduling the next coroutines (as in async-await), the program transitions into the realm of concurrency~\cite[\S~3]{Buhr05a}. 318 Coroutines are only a stepping stone toward sconcurrency where the commonality is that coroutines and threads retain state between calls.321 Coroutines are only a stepping stone toward concurrency where the commonality is that coroutines and threads retain state between calls. 319 322 320 323 \Celeven and \CCeleven define concurrency~\cite[\S~7.26]{C11}, but it is largely wrappers for a subset of the pthreads library~\cite{Pthreads}.\footnote{Pthreads concurrency is based on simple thread fork and join in a function and mutex or condition locks, which is low-level and error-prone} … … 322 325 While the \Celeven standard does not state a threading model, the historical association with pthreads suggests implementations would adopt kernel-level threading (1:1)~\cite{ThreadModel}, as for \CC. 323 326 In contrast, there has been a renewed interest during the past decade in user-level (M:N, green) threading in old and new programming languages. 324 As multi -core hardware became available in the 1980/90s, both user and kernel threading were examined.327 As multicore hardware became available in the 1980/1990s, both user and kernel threading were examined. 325 328 Kernel threading was chosen, largely because of its simplicity and fit with the simpler operating systems and hardware architectures at the time, which gave it a performance advantage~\cite{Drepper03}. 326 329 Libraries like pthreads were developed for C, and the Solaris operating-system switched from user (JDK 1.1~\cite{JDK1.1}) to kernel threads. 327 330 As a result, many languages adopt the 1:1 kernel-threading model, like Java (Scala), Objective-C~\cite{obj-c-book}, \CCeleven~\cite{C11}, C\#~\cite{Csharp} and Rust~\cite{Rust}, with a variety of presentation mechanisms. 328 From 2000 onward s, several language implementations have championed the M:N user-threading model, like Go~\cite{Go}, Erlang~\cite{Erlang}, Haskell~\cite{Haskell}, D~\cite{D}, and \uC~\cite{uC++,uC++book}, including putting green threads back into Java~\cite{Quasar}, and many user-threading libraries have appeared~\cite{Qthreads,MPC,Marcel}.331 From 2000 onward, several language implementations have championed the M:N user-threading model, like Go~\cite{Go}, Erlang~\cite{Erlang}, Haskell~\cite{Haskell}, D~\cite{D}, and \uC~\cite{uC++,uC++book}, including putting green threads back into Java~\cite{Quasar}, and many user-threading libraries have appeared~\cite{Qthreads,MPC,Marcel}. 329 332 The main argument for user-level threading is that it is lighter weight than kernel threading because locking and context switching do not cross the kernel boundary, so there is less restriction on programming styles that encourages large numbers of threads performing medium-sized work to facilitate load balancing by the runtime~\cite{Verch12}. 330 333 As well, user-threading facilitates a simpler concurrency approach using thread objects that leverage sequential patterns versus events with call-backs~\cite{Adya02,vonBehren03}. … … 335 338 One solution is low-level qualifiers and functions, \eg @volatile@ and atomics, allowing \emph{programmers} to explicitly write safe, race-free~\cite{Boehm12} programs. 336 339 A safer solution is high-level language constructs so the \emph{compiler} knows the concurrency boundaries, \ie where mutual exclusion and synchronization are acquired and released, and provide implicit safety at and across these boundaries. 337 While the optimization problem is best known with respect to concurrency, it applies to other complex control-flow ,like exceptions and coroutines.340 While the optimization problem is best known with respect to concurrency, it applies to other complex control-flows like exceptions and coroutines. 338 341 As well, language solutions allow matching the language paradigm with the approach, \eg matching the functional paradigm with data-flow programming or the imperative paradigm with thread programming. 339 342 … … 346 349 However, spurious wakeup is \emph{not} a foundational concurrency property~\cite[\S~9]{Buhr05a}; 347 350 it is a performance design choice. 348 We argue removing spurious wakeup and signals-as-hints make concurrent programming simpler and safer as there is less local non -determinism to manage.351 We argue removing spurious wakeup and signals-as-hints make concurrent programming simpler and safer as there is less local nondeterminism to manage. 349 352 If barging acquisition is allowed, its specialized performance advantage should be available as an option not the default. 350 353 … … 375 378 376 379 % \item 377 % a non -blocking I/O library380 % a nonblocking I/O library 378 381 379 382 \item … … 404 407 \begin{description}[leftmargin=\parindent,topsep=3pt,parsep=0pt] 405 408 \item[\newterm{execution state}:] 406 is the state information needed by a control-flow feature to initialize and manage both compute data and execution location(s), and de-initialize.409 It is the state information needed by a control-flow feature to initialize and manage both compute data and execution location(s), and de-initialize. 407 410 For example, calling a function initializes a stack frame including contained objects with constructors, manages local data in blocks and return locations during calls, and de-initializes the frame by running any object destructors and management operations. 408 411 State is retained in fixed-sized aggregate structures (objects) and dynamic-sized stack(s), often allocated in the heap(s) managed by the runtime system. … … 413 416 414 417 \item[\newterm{threading}:] 415 is execution of code that occurs independently of other execution, where an individual thread's execution is sequential.418 It is execution of code that occurs independently of other execution, where an individual thread's execution is sequential. 416 419 Multiple threads provide \emph{concurrent execution}; 417 420 concurrent execution becomes parallel when run on multiple processing units, \eg hyper-threading, cores, or sockets. … … 419 422 420 423 \item[\newterm{mutual-exclusion / synchronization (MES)}:] 421 is the concurrency mechanism to perform an action without interruption and establish timing relationships among multiple threads.424 It is the concurrency mechanism to perform an action without interruption and establish timing relationships among multiple threads. 422 425 We contented these two properties are independent, \ie mutual exclusion cannot provide synchronization and vice versa without introducing additional threads~\cite[\S~4]{Buhr05a}. 423 Limiting MES functionality results in contrived solutions and inefficiency on multi -core von Neumann computers where shared memory is a foundational aspect of its design.426 Limiting MES functionality results in contrived solutions and inefficiency on multicore von Neumann computers where shared memory is a foundational aspect of its design. 424 427 \end{description} 425 428 These properties are fundamental as they cannot be built from existing language features, \eg a basic programming language like C99~\cite{C99} cannot create new control-flow features, concurrency, or provide MES without (atomic) hardware mechanisms. 426 429 427 430 428 \subsection{Structuring Execution Properties}431 \subsection{Structuring execution properties} 429 432 430 433 Programming languages seldom present the fundamental execution properties directly to programmers. … … 447 450 \vspace*{-5pt} 448 451 \begin{tabular}{c|c||l|l} 449 \multicolumn{2}{c||}{ execution properties} & \multicolumn{2}{c}{mutual exclusion / synchronization} \\452 \multicolumn{2}{c||}{Execution properties} & \multicolumn{2}{c}{Mutual exclusion / synchronization} \\ 450 453 \hline 451 454 stateful & thread & \multicolumn{1}{c|}{No} & \multicolumn{1}{c}{Yes} \\ … … 470 473 Structures are a foundational mechanism for data organization, and access functions provide interface abstraction and code sharing in all programming languages. 471 474 Case 2 is case 1 with thread safety to a structure's state where access functions provide serialization (mutual exclusion) and scheduling among calling threads (synchronization). 472 A @mutex@ structure, often called a \newterm{monitor}, provides a high-level interface for race-free access of shared data in concurrent programming -languages.475 A @mutex@ structure, often called a \newterm{monitor}, provides a high-level interface for race-free access of shared data in concurrent programming languages. 473 476 Case 3 is case 1 where the structure can implicitly retain execution state and access functions use this execution state to resume/suspend across \emph{callers}, but resume/suspend does not retain a function's local state. 474 477 A stackless structure, often called a \newterm{generator} or \emph{iterator}, is \newterm{stackless} because it still borrows the caller's stack and thread, but the stack is used only to preserve state across its callees not callers. 475 Generators provide the first step toward directly solving problems like finite-state machines that retain data and execution state between calls, whereas normal functions restart on each call.478 Generators provide the first step toward directly solving problems like finite-state machines (FSMs) that retain data and execution state between calls, whereas normal functions restart on each call. 476 479 Case 4 is cases 2 and 3 with thread safety during execution of the generator's access functions. 477 480 A @mutex@ generator extends generators into the concurrent domain. … … 488 491 Given the execution-properties taxonomy, programmers now ask three basic questions: is state necessary across callers and how much, is a separate thread necessary, is thread safety necessary. 489 492 Table~\ref{t:ExecutionPropertyComposition} then suggests the optimal language feature needed for implementing a programming problem. 490 The following sections describe how \CFA fills in \emph{all} the non -rejected table entries with language features, while other programming languages may only provide a subset of the table.491 492 493 \subsection{Design Requirements}493 The following sections describe how \CFA fills in \emph{all} the nonrejected table entries with language features, while other programming languages may only provide a subset of the table. 494 495 496 \subsection{Design requirements} 494 497 495 498 The following design requirements largely stem from building \CFA on top of C. … … 497 500 \item 498 501 All communication must be statically type checkable for early detection of errors and efficient code generation. 499 This requirement is consistent with the fact that C is a statically -typed programming-language.502 This requirement is consistent with the fact that C is a statically typed programming language. 500 503 501 504 \item … … 505 508 506 509 \item 507 All communication is performed using function calls, \ie data istransmitted from argument to parameter and results are returned from function calls.510 All communication is performed using function calls, \ie data are transmitted from argument to parameter and results are returned from function calls. 508 511 Alternative forms of communication, such as call-backs, message passing, channels, or communication ports, step outside of C's normal form of communication. 509 512 … … 528 531 529 532 530 \subsection{Asynchronous Await / Call}533 \subsection{Asynchronous await / call} 531 534 532 535 Asynchronous await/call is a caller mechanism for structuring programs and/or increasing concurrency, where the caller (client) postpones an action into the future, which is subsequently executed by a callee (server). … … 540 543 Specifically, control between caller and callee occurs indirectly through the event-engine precluding direct handoff and cycling among events, and requires complex resolution of a control promise and data. 541 544 Note, @async-await@ is just syntactic-sugar over the event engine so it does not solve these deficiencies. 542 For multi -threaded languages like Java, the asynchronous call queues a callee action with an executor (server), which subsequently executes the work by a thread in the executor thread-pool.545 For multithreaded languages like Java, the asynchronous call queues a callee action with an executor (server), which subsequently executes the work by a thread in the executor thread-pool. 543 546 The problem is when concurrent work-units need to interact and/or block as this effects the executor by stopping threads. 544 547 While it is possible to extend this approach to support the necessary mechanisms, \eg message passing in Actors, we show monitors and threads provide an equally competitive approach that does not deviate from normal call communication and can be used to build asynchronous call, as is done in Java. … … 548 551 \label{s:StatefulFunction} 549 552 550 A \emph{stateful function} has the ability to remember state between calls, where state can be either data or execution, \eg plugin, device driver, finite-state machine (FSM).553 A \emph{stateful function} has the ability to remember state between calls, where state can be either data or execution, \eg plugin, device driver, FSM. 551 554 A simple technique to retain data state between calls is @static@ declarations within a function, which is often implemented by hoisting the declarations to the global scope but hiding the names within the function using name mangling. 552 555 However, each call starts the function at the top making it difficult to determine the last point of execution in an algorithm, and requiring multiple flag variables and testing to reestablish the continuation point. … … 606 609 \end{tabular} 607 610 \end{center} 608 \CFA's preferred presentation model for generators/coroutines/threads is a hybrid of functions and classes, giving an object-oriented flavo ur.611 \CFA's preferred presentation model for generators/coroutines/threads is a hybrid of functions and classes, giving an object-oriented flavor. 609 612 Essentially, the generator/coroutine/thread function is semantically coupled with a generator/coroutine/thread custom type via the type's name. 610 613 The custom type solves several issues, while accessing the underlying mechanisms used by the custom types is still allowed for flexibility reasons. … … 621 624 The \CFA \lstinline|with| clause opens an aggregate scope making its fields directly accessible, like Pascal \lstinline|with|, but using parallel semantics; 622 625 multiple aggregates may be opened. 623 \CFA has rebindable references \lstinline|int i, & ip = i, j; `&ip = &j;`| and non -rebindable references \lstinline|int i, & `const` ip = i, j; `&ip = &j;` // disallowed|.626 \CFA has rebindable references \lstinline|int i, & ip = i, j; `&ip = &j;`| and nonrebindable references \lstinline|int i, & `const` ip = i, j; `&ip = &j;` // disallowed|. 624 627 }% 625 628 … … 803 806 called a \emph{generator main} (leveraging the starting semantics for program @main@ in C), which is connected to the generator type via its single reference parameter. 804 807 The generator main contains @suspend@ statements that suspend execution without ending the generator versus @return@. 805 For the Fibonacci generator-main, 806 the top initialization state appears at the start and the middle execution state is denoted by statement @suspend@. 808 For the Fibonacci generator-main, the top initialization state appears at the start and the middle execution state is denoted by statement @suspend@. 807 809 Any local variables in @main@ \emph{are not retained} between calls; 808 810 hence local variables are only for temporary computations \emph{between} suspends. … … 816 818 At the start of the generator main, the @static@ declaration, @states@, is initialized to the N suspend points in the generator, where operator @&&@ dereferences or references a label~\cite{gccValueLabels}. 817 819 Next, the computed @goto@ selects the last suspend point and branches to it. 818 The 820 The cost of setting @restart@ and branching via the computed @goto@ adds very little cost to the suspend and resume calls. 819 821 820 822 An advantage of the \CFA explicit generator type is the ability to allow multiple type-safe interface functions taking and returning arbitrary types. … … 933 935 \ldots\, STX \ldots\, message \ldots\, ESC ETX \ldots\, message \ldots\, ETX 2-byte crc \ldots 934 936 \end{center} 935 where the network message begins with the control character STX, ends with an ETX, and is followed by a 2-byte cyclic-redundancy check.937 where the network message begins with the control character STX, ends with an ETX, and is followed by a two-byte cyclic-redundancy check. 936 938 Control characters may appear in a message if preceded by an ESC. 937 939 When a message byte arrives, it triggers an interrupt, and the operating system services the interrupt by calling the device driver with the byte read from a hardware register. … … 1083 1085 Figure~\ref{f:CPingPongSim} shows the C implementation of the \CFA symmetric generator, where there is still only one additional field, @restart@, but @resume@ is more complex because it does a forward rather than backward jump. 1084 1086 Before the jump, the parameter for the next call @partner@ is placed into the register used for the first parameter, @rdi@, and the remaining registers are reset for a return. 1085 The @jmp comain@ restarts the function but with a different parameter, so the new call's behavio ur depends on the state of the coroutine type, i.e.,branch to restart location with different data state.1086 While the semantics of call forward is a tail-call optimization, which compilers perform, the generator state is different on each call rather a common state for a tail-recursive function ( i.e., the parameter to the function never changes during the forward calls.1087 The @jmp comain@ restarts the function but with a different parameter, so the new call's behavior depends on the state of the coroutine type, \ie branch to restart location with different data state. 1088 While the semantics of call forward is a tail-call optimization, which compilers perform, the generator state is different on each call rather a common state for a tail-recursive function (\ie the parameter to the function never changes during the forward calls). 1087 1089 However, this assembler code depends on what entry code is generated, specifically if there are local variables and the level of optimization. 1088 1090 Hence, internal compiler support is necessary for any forward call or backwards return, \eg LLVM has various coroutine support~\cite{CoroutineTS}, and \CFA can leverage this support should it eventually fork @clang@. … … 1157 1159 \end{cfa} 1158 1160 A call to this function is placed at the end of the device driver's coroutine-main. 1159 For complex finite-state machines, refactoring is part of normal program abstraction, especially when code is used in multiple places.1161 For complex FSMs, refactoring is part of normal program abstraction, especially when code is used in multiple places. 1160 1162 Again, this complexity is usually associated with execution state rather than data state. 1161 1163 … … 1446 1448 1447 1449 1448 \subsection{Generator / Coroutine Implementation}1450 \subsection{Generator / coroutine implementation} 1449 1451 1450 1452 A significant implementation challenge for generators and coroutines (and threads in Section~\ref{s:threads}) is adding extra fields to the custom types and related functions, \eg inserting code after/before the coroutine constructor/destructor and @main@ to create/initialize/de-initialize/destroy any extra fields, \eg the coroutine stack. 1451 There are several solutions to this problem, which follow from the object-oriented flavo ur of adopting custom types.1453 There are several solutions to this problem, which follow from the object-oriented flavor of adopting custom types. 1452 1454 1453 1455 For object-oriented languages, inheritance is used to provide extra fields and code via explicit inheritance: … … 1670 1672 1671 1673 1672 \subsection{Thread Implementation}1674 \subsection{Thread implementation} 1673 1675 1674 1676 Threads in \CFA are user level run by runtime kernel threads (see Section~\ref{s:CFARuntimeStructure}), where user threads provide concurrency and kernel threads provide parallelism. … … 1806 1808 \CFA designated functions are marked by an explicitly parameter-only pointer/reference qualifier @mutex@ (discussed further in Section\ref{s:MutexAcquisition}). 1807 1809 Whereas, Java designated members are marked with \lstinline[language=java]|synchronized| that applies to the implicit reference parameter @this@. 1808 In the example, the increment and setter operations need mutual exclusion while the read-only getter operation can be non -mutex if reading the implementation is atomic.1809 1810 1811 \subsection{Monitor Implementation}1810 In the example, the increment and setter operations need mutual exclusion while the read-only getter operation can be nonmutex if reading the implementation is atomic. 1811 1812 1813 \subsection{Monitor implementation} 1812 1814 1813 1815 For the same design reasons, \CFA provides a custom @monitor@ type and a @trait@ to enforce and restrict the monitor-interface functions. … … 1835 1837 1836 1838 1837 \subsection{Mutex Acquisition}1839 \subsection{Mutex acquisition} 1838 1840 \label{s:MutexAcquisition} 1839 1841 … … 1850 1852 Because of the statically unknown size, \CFA only supports a single reference @mutex@ parameter, @f1@. 1851 1853 1852 The \CFA @mutex@ qualifier does allow the ability to support multi -monitor functions,\footnote{1854 The \CFA @mutex@ qualifier does allow the ability to support multimonitor functions,\footnote{ 1853 1855 While object-oriented monitors can be extended with a mutex qualifier for multiple-monitor members, no prior example of this feature could be found.} 1854 1856 where the number of acquisitions is statically known, called \newterm{bulk acquire}. … … 1980 1982 % There are many aspects of scheduling in a concurrency system, all related to resource utilization by waiting threads, \ie which thread gets the resource next. 1981 1983 % Different forms of scheduling include access to processors by threads (see Section~\ref{s:RuntimeStructureCluster}), another is access to a shared resource by a lock or monitor. 1982 This section discusses scheduling for waiting threads eligible for monitor entry~\cite{Buhr95b}, \ie which user thread gets the shared resource next. (See Section~\ref{s:RuntimeStructureCluster} for scheduling kernel threads on virtual processors.) 1984 This section discusses scheduling for waiting threads eligible for monitor entry~\cite{Buhr95b}, \ie which user thread gets the shared resource next. 1985 (See Section~\ref{s:RuntimeStructureCluster} for scheduling kernel threads on virtual processors.) 1983 1986 While monitor mutual-exclusion provides safe access to its shared data, the data may indicate a thread cannot proceed, \eg a bounded buffer may be full/\-empty so produce/consumer threads must block. 1984 1987 Leaving the monitor and retrying (busy waiting) is impractical for high-level programming. … … 1991 1994 For complex scheduling, the approaches can be combined, so there are threads waiting inside and outside. 1992 1995 1993 \CFA monitors do not allow calling threads to barge ahead of signal led threads via barging prevention, which simplifies synchronization among threads in the monitor and increases correctness.1996 \CFA monitors do not allow calling threads to barge ahead of signaled threads via barging prevention, which simplifies synchronization among threads in the monitor and increases correctness. 1994 1997 A direct consequence of this semantics is that unblocked waiting threads are not required to recheck the waiting condition, \ie waits are not in a starvation-prone busy-loop as required by the signals-as-hints style with barging. 1995 1998 Preventing barging comes directly from Hoare's semantics in the seminal paper on monitors~\cite[p.~550]{Hoare74}. 1996 1999 % \begin{cquote} 1997 2000 % However, we decree that a signal operation be followed immediately by resumption of a waiting program, without possibility of an intervening procedure call from yet a third program. 1998 % It is only in this way that a waiting program has an absolute guarantee that it can acquire the resource just released by the signal ling program without any danger that a third program will interpose a monitor entry and seize the resource instead.~\cite[p.~550]{Hoare74}2001 % It is only in this way that a waiting program has an absolute guarantee that it can acquire the resource just released by the signaling program without any danger that a third program will interpose a monitor entry and seize the resource instead.~\cite[p.~550]{Hoare74} 1999 2002 % \end{cquote} 2000 2003 Furthermore, \CFA concurrency has no spurious wakeup~\cite[\S~9]{Buhr05a}, which eliminates an implicit self barging. 2001 2004 2002 Monitor mutual-exclusion means signal ling cannot have the signaller and signalled thread in the monitor simultaneously, so only the signaller or signallee can proceed and the other waits on an implicit urgent list~\cite[p.~551]{Hoare74}.2005 Monitor mutual-exclusion means signaling cannot have the signaller and signaled thread in the monitor simultaneously, so only the signaller or signallee can proceed and the other waits on an implicit urgent list~\cite[p.~551]{Hoare74}. 2003 2006 Figure~\ref{f:MonitorScheduling} shows internal and external scheduling for the bounded-buffer examples in Figure~\ref{f:GenericBoundedBuffer}. 2004 2007 For internal scheduling in Figure~\ref{f:BBInt}, the @signal@ moves the signallee, front thread of the specified condition queue, to the urgent list (see Figure~\ref{f:MonitorScheduling}) and the signaller continues (solid line). 2005 2008 Multiple signals move multiple signallees to urgent until the condition queue is empty. 2006 2009 When the signaller exits or waits, a thread is implicitly unblocked from urgent, if available, before unblocking a calling thread to prevent barging. 2007 (Java conceptually moves the signal led thread to the calling queue, and hence, allows barging.)2008 Signal is used when the signaller is providing the cooperation needed by the signallee, \eg creating an empty slot in a buffer for a producer, and the signaller immediately exits the monitor to run concurrently consuming the buffer element, and passes control of the monitor to the signal led thread, which can immediately take advantage of the state change.2010 (Java conceptually moves the signaled thread to the calling queue, and hence, allows barging.) 2011 Signal is used when the signaller is providing the cooperation needed by the signallee, \eg creating an empty slot in a buffer for a producer, and the signaller immediately exits the monitor to run concurrently consuming the buffer element, and passes control of the monitor to the signaled thread, which can immediately take advantage of the state change. 2009 2012 Specifically, the @wait@ function atomically blocks the calling thread and implicitly releases the monitor lock(s) for all monitors in the function's parameter list. 2010 Signalling is unconditional because signal ling an empty condition queue does nothing.2013 Signalling is unconditional because signaling an empty condition queue does nothing. 2011 2014 It is common to declare condition queues as monitor fields to prevent shared access, hence no locking is required for access as the queues are protected by the monitor lock. 2012 2015 In \CFA, a condition queue can be created and stored independently. … … 2146 2149 rcnt += 1; 2147 2150 if ( ! empty(RWers) && `front(RWers) == READER` ) 2148 `signal( RWers )`; // daisy-chain signal ling2151 `signal( RWers )`; // daisy-chain signaling 2149 2152 } 2150 2153 void StartWrite( ReadersWriter & mutex rw ) with(rw) { … … 2201 2204 2202 2205 Finally, external scheduling requires urgent to be a stack, because the signaller expects to execute immediately after the specified monitor call has exited or waited. 2203 Internal schedul ling performing multiple signalling results in unblocking from urgent in the reverse order from signalling.2206 Internal scheduling performing multiple signaling results in unblocking from urgent in the reverse order from signaling. 2204 2207 It is rare for the unblocking order to be important as an unblocked thread can be time-sliced immediately after leaving the monitor. 2205 If the unblocking order is important, multiple signal ling can be restructured into daisy-chain signalling, where each thread signals the next thread.2206 Hence, \CFA uses a single urgent stack to correctly handle @waitfor@ and adequately support both forms of signal ling.2208 If the unblocking order is important, multiple signaling can be restructured into daisy-chain signaling, where each thread signals the next thread. 2209 Hence, \CFA uses a single urgent stack to correctly handle @waitfor@ and adequately support both forms of signaling. 2207 2210 (Advanced @waitfor@ features are discussed in Section~\ref{s:ExtendedWaitfor}.) 2208 2211 … … 2270 2273 \end{figure} 2271 2274 2272 Figure~\ref{f:DatingServiceMonitor} shows a dating service demonstrating non -blocking and blocking signalling.2275 Figure~\ref{f:DatingServiceMonitor} shows a dating service demonstrating nonblocking and blocking signaling. 2273 2276 The dating service matches girl and boy threads with matching compatibility codes so they can exchange phone numbers. 2274 2277 A thread blocks until an appropriate partner arrives. … … 2315 2318 \end{cquote} 2316 2319 For @wait( e )@, the default semantics is to atomically block the signaller and release all acquired mutex parameters, \ie @wait( e, m1, m2 )@. 2317 To override the implicit multi -monitor wait, specific mutex parameter(s) can be specified, \eg @wait( e, m1 )@.2320 To override the implicit multimonitor wait, specific mutex parameter(s) can be specified, \eg @wait( e, m1 )@. 2318 2321 Wait cannot statically verify the released monitors are the acquired mutex-parameters without disallowing separately compiled helper functions calling @wait@. 2319 2322 While \CC supports bulk locking, @wait@ only accepts a single lock for a condition queue, so bulk locking with condition queues is asymmetric. … … 2324 2327 } 2325 2328 \end{cfa} 2326 must have acquired at least the same locks as the waiting thread signal led from a condition queue to allow the locks to be passed, and hence, prevent barging.2329 must have acquired at least the same locks as the waiting thread signaled from a condition queue to allow the locks to be passed, and hence, prevent barging. 2327 2330 2328 2331 Similarly, for @waitfor( rtn )@, the default semantics is to atomically block the acceptor and release all acquired mutex parameters, \ie @waitfor( rtn : m1, m2 )@. 2329 To override the implicit multi -monitor wait, specific mutex parameter(s) can be specified, \eg @waitfor( rtn : m1 )@.2332 To override the implicit multimonitor wait, specific mutex parameter(s) can be specified, \eg @waitfor( rtn : m1 )@. 2330 2333 @waitfor@ does statically verify the monitor types passed are the same as the acquired mutex-parameters of the given function or function pointer, hence the prototype must be accessible. 2331 2334 % When an overloaded function appears in an @waitfor@ statement, calls to any function with that name are accepted. … … 2345 2348 ... signal( `e` ); ... 2346 2349 \end{cfa} 2347 The @wait@ only releases @m1@ so the signal ling thread cannot acquire @m1@ and @m2@ to enter @bar@ and @signal@ the condition.2350 The @wait@ only releases @m1@ so the signaling thread cannot acquire @m1@ and @m2@ to enter @bar@ and @signal@ the condition. 2348 2351 While deadlock can occur with multiple/nesting acquisition, this is a consequence of locks, and by extension monitor locking is not perfectly composable. 2349 2352 … … 2409 2412 2410 2413 2411 \subsection{Bulk Barging Prevention}2412 2413 Figure~\ref{f:BulkBargingPrevention} shows \CFA code where bulk acquire adds complexity to the internal-signal ling semantics.2414 \subsection{Bulk barging prevention} 2415 2416 Figure~\ref{f:BulkBargingPrevention} shows \CFA code where bulk acquire adds complexity to the internal-signaling semantics. 2414 2417 The complexity begins at the end of the inner @mutex@ statement, where the semantics of internal scheduling need to be extended for multiple monitors. 2415 2418 The problem is that bulk acquire is used in the inner @mutex@ statement where one of the monitors is already acquired. 2416 When the signal ling thread reaches the end of the inner @mutex@ statement, it should transfer ownership of @m1@ and @m2@ to the waiting threads to prevent barging into the outer @mutex@ statement by another thread.2417 However, both the signal ling and waiting threads W1 and W2 need some subset of monitors @m1@ and @m2@.2419 When the signaling thread reaches the end of the inner @mutex@ statement, it should transfer ownership of @m1@ and @m2@ to the waiting threads to prevent barging into the outer @mutex@ statement by another thread. 2420 However, both the signaling and waiting threads W1 and W2 need some subset of monitors @m1@ and @m2@. 2418 2421 \begin{cquote} 2419 2422 condition c: (order 1) W2(@m2@), W1(@m1@,@m2@)\ \ \ or\ \ \ (order 2) W1(@m1@,@m2@), W2(@m2@) \\ … … 2482 2485 \end{figure} 2483 2486 2484 One scheduling solution is for the signaller S to keep ownership of all locks until the last lock is ready to be transferred, because this semantics fits most closely to the behavio ur of single-monitor scheduling.2487 One scheduling solution is for the signaller S to keep ownership of all locks until the last lock is ready to be transferred, because this semantics fits most closely to the behavior of single-monitor scheduling. 2485 2488 However, this solution is inefficient if W2 waited first and immediate passed @m2@ when released, while S retains @m1@ until completion of the outer mutex statement. 2486 2489 If W1 waited first, the signaller must retain @m1@ amd @m2@ until completion of the outer mutex statement and then pass both to W1. … … 2495 2498 \label{s:waitforImplementation} 2496 2499 2497 In a statically -typed object-oriented programming language, a class has an exhaustive list of members, even when members are added via static inheritance (see Figure~\ref{f:uCinheritance}).2500 In a statically typed object-oriented programming language, a class has an exhaustive list of members, even when members are added via static inheritance (see Figure~\ref{f:uCinheritance}). 2498 2501 Knowing all members at compilation, even separate compilation, allows uniquely numbered them so the accept-statement implementation can use a fast and compact bit mask with $O(1)$ compare. 2499 2502 … … 2539 2542 \hspace{3pt} 2540 2543 \subfloat[\CFA]{\label{f:CFinheritance}\usebox\myboxB} 2541 \caption{Member / Function visibility}2544 \caption{Member / function visibility} 2542 2545 \label{f:MemberFunctionVisibility} 2543 2546 \end{figure} 2544 2547 2545 However, the @waitfor@ statement in translation unit 2 (see Figure~\ref{f:CFinheritance}) cannot see function @g@ in translation unit 1 precluding a unique numbering for a bit-mask because the monitor type only carries the protected shared -data.2548 However, the @waitfor@ statement in translation unit 2 (see Figure~\ref{f:CFinheritance}) cannot see function @g@ in translation unit 1 precluding a unique numbering for a bit-mask because the monitor type only carries the protected shared data. 2546 2549 (A possible way to construct a dense mapping is at link or load-time.) 2547 2550 Hence, function pointers are used to identify the functions listed in the @waitfor@ statement, stored in a variable-sized array. … … 2550 2553 2551 2554 2552 \subsection{Multi -Monitor Scheduling}2555 \subsection{Multimonitor scheduling} 2553 2556 \label{s:Multi-MonitorScheduling} 2554 2557 2555 External scheduling, like internal scheduling, becomes significantly more complex for multi -monitor semantics.2558 External scheduling, like internal scheduling, becomes significantly more complex for multimonitor semantics. 2556 2559 Even in the simplest case, new semantics need to be established. 2557 2560 \begin{cfa} … … 2565 2568 \end{cfa} 2566 2569 Both locks are acquired by function @g@, so when function @f@ is called, the lock for monitor @m2@ is passed from @g@ to @f@, while @g@ still holds lock @m1@. 2567 This behavio ur can be extended to the multi-monitor @waitfor@ statement.2570 This behavior can be extended to the multimonitor @waitfor@ statement. 2568 2571 \begin{cfa} 2569 2572 monitor M { ... }; … … 2574 2577 % Also, the order of the monitors in a @waitfor@ statement must match the order of the mutex parameters. 2575 2578 2576 Figure~\ref{f:UnmatchedMutexSets} shows internal and external scheduling with multiple monitors that must match exactly with a signal ling or accepting thread, \ie partial matching results in waiting.2579 Figure~\ref{f:UnmatchedMutexSets} shows internal and external scheduling with multiple monitors that must match exactly with a signaling or accepting thread, \ie partial matching results in waiting. 2577 2580 In both cases, the set of monitors is disjoint so unblocking is impossible. 2578 2581 … … 2766 2769 2767 2770 2768 \subsection{\texorpdfstring{\protect\lstinline@mutex@ Generators / Coroutines / Threads}{monitor Generators / Coroutines / Threads}}2771 \subsection{\texorpdfstring{\protect\lstinline@mutex@ Generators / coroutines / threads}{monitor Generators / coroutines / threads}} 2769 2772 2770 2773 \CFA generators, coroutines, and threads can also be @mutex@ (Table~\ref{t:ExecutionPropertyComposition} cases 4, 6, 12) allowing safe \emph{direct communication} with threads, \ie the custom types can have mutex functions that are called by other threads. … … 2808 2811 % 2809 2812 % 2810 % \subsection{User Threads}2813 % \subsection{User threads} 2811 2814 % 2812 2815 % A direct improvement on kernel threads is user threads, \eg Erlang~\cite{Erlang} and \uC~\cite{uC++book}. … … 2823 2826 2824 2827 \begin{comment} 2825 \subsection{Thread Pools}2828 \subsection{Thread pools} 2826 2829 2827 2830 In contrast to direct threading is indirect \newterm{thread pools}, \eg Java @executor@, where small jobs (work units) are inserted into a work pool for execution. … … 2902 2905 The purpose of a cluster is to control the amount of parallelism that is possible among threads, plus scheduling and other execution defaults. 2903 2906 The default cluster-scheduler is single-queue multi-server, which provides automatic load-balancing of threads on processors. 2904 However, the design allows changing the scheduler, \eg multi-queue multi -server with work-stealing/sharing across the virtual processors.2907 However, the design allows changing the scheduler, \eg multi-queue multiserver with work-stealing/sharing across the virtual processors. 2905 2908 If several clusters exist, both threads and virtual processors, can be explicitly migrated from one cluster to another. 2906 2909 No automatic load balancing among clusters is performed by \CFA. … … 2912 2915 2913 2916 2914 \subsection{Virtual Processor}2917 \subsection{Virtual processor} 2915 2918 \label{s:RuntimeStructureProcessor} 2916 2919 … … 2935 2938 This storage is allocated at the base of a thread's stack before blocking, which means programmers must add a small amount of extra space for stacks. 2936 2939 2937 In \CFA, ordering of monitor acquisition relies on memory ordering to prevent deadlock~\cite{Havender68}, because all objects have distinct non -overlapping memory layouts, and mutual-exclusion for a monitor is only defined for its lifetime.2940 In \CFA, ordering of monitor acquisition relies on memory ordering to prevent deadlock~\cite{Havender68}, because all objects have distinct nonoverlapping memory layouts, and mutual-exclusion for a monitor is only defined for its lifetime. 2938 2941 When a mutex call is made, pointers to the concerned monitors are aggregated into a variable-length array and sorted. 2939 2942 This array persists for the entire duration of the mutual exclusion and is used extensively for synchronization operations. … … 2954 2957 2955 2958 Nondeterministic preemption provides fairness from long-running threads, and forces concurrent programmers to write more robust programs, rather than relying on code between cooperative scheduling to be atomic. 2956 This atomic reliance can fail on multi -core machines, because execution across cores is nondeterministic.2959 This atomic reliance can fail on multicore machines, because execution across cores is nondeterministic. 2957 2960 A different reason for not supporting preemption is that it significantly complicates the runtime system, \eg Windows runtime does not support interrupts and on Linux systems, interrupts are complex (see below). 2958 2961 Preemption is normally handled by setting a countdown timer on each virtual processor. … … 2962 2965 The only issue with this approach is that signal masks from one kernel thread may be restored on another as part of returning from the signal handler; 2963 2966 therefore, the same signal mask is required for all virtual processors in a cluster. 2964 Because preemption interval is usually long (1 m illisecond) performance cost is negligible.2967 Because preemption interval is usually long (1 ms) performance cost is negligible. 2965 2968 2966 2969 Linux switched a decade ago from specific to arbitrary virtual-processor signal-delivery for applications with multiple kernel threads. … … 2973 2976 2974 2977 2975 \subsection{Debug Kernel}2976 2977 There are two versions of the \CFA runtime kernel: debug and non -debug.2978 The debugging version has many runtime checks and internal assertions, \eg stack non -writable guard page, and checks for stack overflow whenever context switches occur among coroutines and threads, which catches most stack overflows.2979 After a program is debugged, the non -debugging version can be used to significantly decrease space and increase performance.2978 \subsection{Debug kernel} 2979 2980 There are two versions of the \CFA runtime kernel: debug and nondebug. 2981 The debugging version has many runtime checks and internal assertions, \eg stack nonwritable guard page, and checks for stack overflow whenever context switches occur among coroutines and threads, which catches most stack overflows. 2982 After a program is debugged, the nondebugging version can be used to significantly decrease space and increase performance. 2980 2983 2981 2984 … … 2984 2987 2985 2988 To test the performance of the \CFA runtime, a series of microbenchmarks are used to compare \CFA with pthreads, Java 11.0.6, Go 1.12.6, Rust 1.37.0, Python 3.7.6, Node.js 12.14.1, and \uC 7.0.0. 2986 For comparison, the package must be multi -processor (M:N), which excludes libdil and libmil~\cite{libdill} (M:1)), and use a shared-memory programming model, \eg not message passing.2989 For comparison, the package must be multiprocessor (M:N), which excludes libdil and libmil~\cite{libdill} (M:1)), and use a shared-memory programming model, \eg not message passing. 2987 2990 The benchmark computer is an AMD Opteron\texttrademark\ 6380 NUMA 64-core, 8 socket, 2.5 GHz processor, running Ubuntu 16.04.6 LTS, and pthreads/\CFA/\uC are compiled with gcc 9.2.1. 2988 2991 2989 All benchmarks are run using the following harness. (The Java harness is augmented to circumvent JIT issues.) 2992 All benchmarks are run using the following harness. 2993 (The Java harness is augmented to circumvent JIT issues.) 2990 2994 \begin{cfa} 2991 2995 #define BENCH( `run` ) uint64_t start = cputime_ns(); `run;` double result = (double)(cputime_ns() - start) / N; 2992 2996 \end{cfa} 2993 2997 where CPU time in nanoseconds is from the appropriate language clock. 2994 Each benchmark is performed @N@ times, where @N@ is selected so the benchmark runs in the range of 2--20 s econdsfor the specific programming language;2998 Each benchmark is performed @N@ times, where @N@ is selected so the benchmark runs in the range of 2--20 s for the specific programming language; 2995 2999 each @N@ appears after the experiment name in the following tables. 2996 3000 The total time is divided by @N@ to obtain the average time for a benchmark. 2997 3001 Each benchmark experiment is run 13 times and the average appears in the table. 2998 3002 For languages with a runtime JIT (Java, Node.js, Python), a single half-hour long experiment is run to check stability; 2999 all long-experiment results are statistically equivalent, \ie median/average/ standard-deviationcorrelate with the short-experiment results, indicating the short experiments reached a steady state.3003 all long-experiment results are statistically equivalent, \ie median/average/SD correlate with the short-experiment results, indicating the short experiments reached a steady state. 3000 3004 All omitted tests for other languages are functionally identical to the \CFA tests and available online~\cite{CforallConcurrentBenchmarks}. 3001 3005 3002 \ paragraph{Creation}3006 \subsection{Creation} 3003 3007 3004 3008 Creation is measured by creating and deleting a specific kind of control-flow object. … … 3030 3034 3031 3035 \begin{tabular}[t]{@{}r*{3}{D{.}{.}{5.2}}@{}} 3032 \multicolumn{1}{@{}r}{ N\hspace*{10pt}} & \multicolumn{1}{c}{Median} & \multicolumn{1}{c}{Average} & \multicolumn{1}{c@{}}{Std Dev} \\3036 \multicolumn{1}{@{}r}{Object(N)\hspace*{10pt}} & \multicolumn{1}{c}{Median} & \multicolumn{1}{c}{Average} & \multicolumn{1}{c@{}}{Std Dev} \\ 3033 3037 \CFA generator (1B) & 0.6 & 0.6 & 0.0 \\ 3034 3038 \CFA coroutine lazy (100M) & 13.4 & 13.1 & 0.5 \\ … … 3049 3053 3050 3054 \vspace*{-10pt} 3051 \ paragraph{Internal Scheduling}3052 3053 Internal scheduling is measured using a cycle of two threads signal ling and waiting.3055 \subsection{Internal scheduling} 3056 3057 Internal scheduling is measured using a cycle of two threads signaling and waiting. 3054 3058 Figure~\ref{f:schedint} shows the code for \CFA, with results in Table~\ref{t:schedint}. 3055 3059 Note, the \CFA incremental cost for bulk acquire is a fixed cost for small numbers of mutex objects. … … 3093 3097 3094 3098 \begin{tabular}{@{}r*{3}{D{.}{.}{5.2}}@{}} 3095 \multicolumn{1}{@{}r}{ N\hspace*{10pt}} & \multicolumn{1}{c}{Median} & \multicolumn{1}{c}{Average} & \multicolumn{1}{c@{}}{Std Dev} \\3099 \multicolumn{1}{@{}r}{Object(N)\hspace*{10pt}} & \multicolumn{1}{c}{Median} & \multicolumn{1}{c}{Average} & \multicolumn{1}{c@{}}{Std Dev} \\ 3096 3100 \CFA @signal@, 1 monitor (10M) & 364.4 & 364.2 & 4.4 \\ 3097 3101 \CFA @signal@, 2 monitor (10M) & 484.4 & 483.9 & 8.8 \\ … … 3106 3110 3107 3111 3108 \ paragraph{External Scheduling}3112 \subsection{External scheduling} 3109 3113 3110 3114 External scheduling is measured using a cycle of two threads calling and accepting the call using the @waitfor@ statement. … … 3140 3144 \label{t:schedext} 3141 3145 \begin{tabular}{@{}r*{3}{D{.}{.}{3.2}}@{}} 3142 \multicolumn{1}{@{}r}{ N\hspace*{10pt}} & \multicolumn{1}{c}{Median} &\multicolumn{1}{c}{Average} & \multicolumn{1}{c@{}}{Std Dev} \\3146 \multicolumn{1}{@{}r}{Object(N)\hspace*{10pt}} & \multicolumn{1}{c}{Median} &\multicolumn{1}{c}{Average} & \multicolumn{1}{c@{}}{Std Dev} \\ 3143 3147 \CFA @waitfor@, 1 monitor (10M) & 367.1 & 365.3 & 5.0 \\ 3144 3148 \CFA @waitfor@, 2 monitor (10M) & 463.0 & 464.6 & 7.1 \\ … … 3149 3153 \end{multicols} 3150 3154 3151 \ paragraph{Mutual-Exclusion}3155 \subsection{Mutual-Exclusion} 3152 3156 3153 3157 Uncontented mutual exclusion, which frequently occurs, is measured by entering and leaving a critical section. 3154 For monitors, entering and leaving a mutex function ismeasured, otherwise the language-appropriate mutex-lock is measured.3155 For comparison, a spinning (v ersusblocking) test-and-test-set lock is presented.3158 For monitors, entering and leaving a mutex function are measured, otherwise the language-appropriate mutex-lock is measured. 3159 For comparison, a spinning (vs.\ blocking) test-and-test-set lock is presented. 3156 3160 Figure~\ref{f:mutex} shows the code for \CFA with results in Table~\ref{t:mutex}. 3157 3161 Note the incremental cost of bulk acquire for \CFA, which is largely a fixed cost for small numbers of mutex objects. … … 3176 3180 \label{t:mutex} 3177 3181 \begin{tabular}{@{}r*{3}{D{.}{.}{3.2}}@{}} 3178 \multicolumn{1}{@{}r}{ N\hspace*{10pt}} & \multicolumn{1}{c}{Median} &\multicolumn{1}{c}{Average} & \multicolumn{1}{c@{}}{Std Dev} \\3182 \multicolumn{1}{@{}r}{Object(N)\hspace*{10pt}} & \multicolumn{1}{c}{Median} &\multicolumn{1}{c}{Average} & \multicolumn{1}{c@{}}{Std Dev} \\ 3179 3183 test-and-test-set lock (50M) & 19.1 & 18.9 & 0.4 \\ 3180 3184 \CFA @mutex@ function, 1 arg. (50M) & 48.3 & 47.8 & 0.9 \\ … … 3190 3194 \end{multicols} 3191 3195 3192 \ paragraph{Context Switching}3196 \subsection{Context switching} 3193 3197 3194 3198 In procedural programming, the cost of a function call is important as modularization (refactoring) increases. … … 3237 3241 \label{t:ctx-switch} 3238 3242 \begin{tabular}{@{}r*{3}{D{.}{.}{3.2}}@{}} 3239 \multicolumn{1}{@{}r}{ N\hspace*{10pt}} & \multicolumn{1}{c}{Median} &\multicolumn{1}{c}{Average} & \multicolumn{1}{c@{}}{Std Dev} \\3243 \multicolumn{1}{@{}r}{Object(N)\hspace*{10pt}} & \multicolumn{1}{c}{Median} &\multicolumn{1}{c}{Average} & \multicolumn{1}{c@{}}{Std Dev} \\ 3240 3244 C function (10B) & 1.8 & 1.8 & 0.0 \\ 3241 3245 \CFA generator (5B) & 1.8 & 2.0 & 0.3 \\ … … 3290 3294 3291 3295 \medskip 3292 \textbf{Flexible Scheduling:}3296 \textbf{Flexible scheduling:} 3293 3297 An important part of concurrency is scheduling. 3294 3298 Different scheduling algorithms can affect performance, both in terms of average and variation. … … 3296 3300 One solution is to offer various tuning options, allowing the scheduler to be adjusted to the requirements of the workload. 3297 3301 However, to be truly flexible, a pluggable scheduler is necessary. 3298 Currently, the \CFA pluggable scheduler is too simple to handle complex scheduling, \eg quality of service and real -time, where the scheduler must interact with mutex objects to deal with issues like priority inversion~\cite{Buhr00b}.3302 Currently, the \CFA pluggable scheduler is too simple to handle complex scheduling, \eg quality of service and real time, where the scheduler must interact with mutex objects to deal with issues like priority inversion~\cite{Buhr00b}. 3299 3303 3300 3304 \smallskip … … 3302 3306 Many modern workloads are not bound by computation but IO operations, common cases being web servers and XaaS~\cite{XaaS} (anything as a service). 3303 3307 These types of workloads require significant engineering to amortizing costs of blocking IO-operations. 3304 At its core, non -blocking I/O is an operating-system level feature queuing IO operations, \eg network operations, and registering for notifications instead of waiting for requests to complete.3308 At its core, nonblocking I/O is an operating-system level feature queuing IO operations, \eg network operations, and registering for notifications instead of waiting for requests to complete. 3305 3309 Current trends use asynchronous programming like callbacks, futures, and/or promises, \eg Node.js~\cite{NodeJs} for JavaScript, Spring MVC~\cite{SpringMVC} for Java, and Django~\cite{Django} for Python. 3306 However, these solutions lead to code that is hard to create, read and maintain.3307 A better approach is to tie non -blocking I/O into the concurrency system to provide ease of use with low overhead, \eg thread-per-connection web-services.3308 A non -blocking I/O library is currently under development for \CFA.3310 However, these solutions lead to code that is hard to create, read, and maintain. 3311 A better approach is to tie nonblocking I/O into the concurrency system to provide ease of use with low overhead, \eg thread-per-connection web-services. 3312 A nonblocking I/O library is currently under development for \CFA. 3309 3313 3310 3314 \smallskip 3311 \textbf{Other Concurrency Tools:}3315 \textbf{Other concurrency tools:} 3312 3316 While monitors offer flexible and powerful concurrency for \CFA, other concurrency tools are also necessary for a complete multi-paradigm concurrency package. 3313 3317 Examples of such tools can include futures and promises~\cite{promises}, executors and actors. … … 3316 3320 3317 3321 \smallskip 3318 \textbf{Implicit Threading:}3322 \textbf{Implicit threading:} 3319 3323 Basic \emph{embarrassingly parallel} applications can benefit greatly from implicit concurrency, where sequential programs are converted to concurrent, with some help from pragmas to guide the conversion. 3320 3324 This type of concurrency can be achieved both at the language level and at the library level. -
doc/papers/concurrency/annex/local.bib
re3282fe r4432b52 29 29 booktitle = {Supercomputing, 2005. Proceedings of the ACM/IEEE SC 2005 Conference}, 30 30 publisher = {IEEE}, 31 location = {Seattle, Washington, U.S.A.}, 32 month = nov, 31 33 year = {2005}, 32 34 pages = {35-35}, 33 month = nov,34 35 } 35 36 … … 58 59 59 60 @manual{Cpp-Transactions, 60 61 title = {Tech. Spec. for C++ Extensions for Transactional Memory},62 organization= {International Standard ISO/IEC TS 19841:2015},63 publisher = {American National Standards Institute},64 address = {http://www.iso.org},65 year = 2015,61 keywords = {C++, Transactional Memory}, 62 title = {Tech. Spec. for C++ Extensions for Transactional Memory {ISO/IEC} {TS} 19841:2015}, 63 organization= {International Standard Organization}, 64 address = {Geneva, Switzerland}, 65 year = 2015, 66 note = {\href{https://www.iso.org/standard/66343.html}{https://\-www.iso.org/\-standard/\-66343.html}}, 66 67 } 67 68 … … 109 110 @manual{affinityLinux, 110 111 key = {TBB}, 111 title = "{Linux man page - sched\_setaffinity(2)}" 112 title = "{Linux man page - sched\_setaffinity(2)}", 113 note = {\href{https://man7.org/linux/man-pages/man2/sched_setaffinity.2.html}{https://\-man7.org/\-linux/man-pages/\-man2/sched\_setaffinity.2.html}}, 112 114 } 113 115 114 116 @manual{affinityWindows, 115 title = "{Windows (vs.85) - SetThreadAffinityMask function}" 117 title = "{Windows documentation - SetThreadAffinityMask function}", 118 note = {\href{https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-setthreadaffinitymask}{https://\-docs.microsoft.com/\-en-us/\-windows/\-win32/api/\-winbase/\-nf-winbase-setthreadaffinitymask}} 116 119 } 117 120 -
doc/papers/concurrency/mail
re3282fe r4432b52 10 10 Dear Dr Buhr, 11 11 12 Your manuscript entitled "Concurrency in C ∀" has been received by Software:12 Your manuscript entitled "Concurrency in Cforall" has been received by Software: 13 13 Practice and Experience. It will be given full consideration for publication in 14 14 the journal. … … 41 41 Dear Dr Buhr, 42 42 43 Many thanks for submitting SPE-18-0205 entitled "Concurrency in C ∀" to Software: Practice and Experience.43 Many thanks for submitting SPE-18-0205 entitled "Concurrency in Cforall" to Software: Practice and Experience. 44 44 45 45 In view of the comments of the referees found at the bottom of this letter, I cannot accept your paper for publication in Software: Practice and Experience. I hope that you find the referees' very detailed comments helpful. -
doc/papers/concurrency/mail2
re3282fe r4432b52 1 2 1 Date: Wed, 26 Jun 2019 20:12:38 +0000 3 2 From: Aaron Thomas <onbehalfof@manuscriptcentral.com> … … 1286 1285 1287 1286 Wiley Author Services 1287 1288 1289 1290 From: "Pacaanas, Joel -" <jpacaanas@wiley.com> 1291 To: "Peter A. Buhr" <pabuhr@uwaterloo.ca> 1292 CC: Thierry Delisle <tdelisle@uwaterloo.ca> 1293 Subject: RE: Action: Proof of SPE_EV_SPE2925 for Software: Practice And Experience ready for review 1294 Date: Thu, 5 Nov 2020 02:03:27 +0000 1295 1296 Dear Dr Buhr, 1297 1298 Thank you for letting me know. We will wait for your corrections then. 1299 1300 Best regards, 1301 Joel 1302 1303 Joel Q. Pacaanas 1304 Production Editor 1305 On behalf of Wiley 1306 Manila 1307 We partner with global experts to further innovative research. 1308 1309 E-mail: jpacaanas@wiley.com 1310 Tel: +632 88558618 1311 Fax: +632 5325 0768 1312 1313 -----Original Message----- 1314 From: Peter A. Buhr [mailto:pabuhr@uwaterloo.ca] 1315 Sent: Thursday, November 5, 2020 5:57 AM 1316 To: SPE Proofs <speproofs@wiley.com> 1317 Cc: Thierry Delisle <tdelisle@uwaterloo.ca> 1318 Subject: Re: Action: Proof of SPE_EV_SPE2925 for Software: Practice And Experience ready for review 1319 1320 This is an external email. 1321 1322 We appreciate that the COVID-19 pandemic may create conditions for you that 1323 make it difficult for you to review your proof within standard time 1324 frames. If you have any problems keeping to this schedule, please reach out 1325 to me at (SPEproofs@wiley.com) to discuss alternatives. 1326 1327 Hi, 1328 1329 We are in the middle of reading the proofs but it will take a little more 1330 time. I can send the proofs back by Monday Nov 9, but probably earlier. 1331 1332 1333 1334 From: "Pacaanas, Joel -" <jpacaanas@wiley.com> 1335 To: "Peter A. Buhr" <pabuhr@uwaterloo.ca> 1336 CC: "tdelisle@uwaterloo.ca" <tdelisle@uwaterloo.ca> 1337 Subject: RE: Action: Proof of SPE_EV_SPE2925 for Software: Practice And Experience ready for review 1338 Date: Fri, 20 Nov 2020 05:27:18 +0000 1339 1340 Dear Peter, 1341 1342 We have now reset the proof back to original stage. Please refer to the below editable link. 1343 1344 https://wiley.eproofing.in/Proof.aspx?token=ab7739d5678447fbbe5036f3bcba2445081500061 1345 1346 Since the proof was reset, your added corrections before has also been removed. Please add them back. 1347 1348 Please return your corrections at your earliest convenience. 1349 1350 Best regards, 1351 Joel 1352 1353 Joel Q. Pacaanas 1354 Production Editor 1355 On behalf of Wiley 1356 Manila 1357 We partner with global experts to further innovative research. 1358 1359 E-mail: jpacaanas@wiley.com 1360 Tel: +632 88558618 1361 Fax: +632 5325 0768 1362 1363 1364 1365 From: "Wiley Online Proofing" <notifications@eproofing.in> 1366 To: pabuhr@uwaterloo.ca 1367 Cc: SPEproofs@wiley.com 1368 Reply-To: eproofing@wiley.com 1369 Date: 26 Nov 2020 18:57:27 +0000 1370 Subject: Corrections successfully submitted for SPE_EV_SPE2925, Advanced control-flow in Cforall. 1371 1372 Corrections successfully submitted 1373 1374 Dear Dr. Peter Buhr, 1375 1376 Thank you for reviewing the proof of the Software: Practice And Experience article Advanced control-flow in Cforall. 1377 1378 View Article https://wiley.eproofing.in/Proof.aspx?token=ab7739d5678447fbbe5036f3bcba2445081500061 1379 1380 This is a read-only version of your article with the corrections you have marked up. 1381 1382 If you encounter any problems or have questions please contact me, Joel Pacaanas at (SPEproofs@wiley.com). For the quickest response include the journal name and your article ID (found in the subject line) in all correspondence. 1383 1384 Best regards, 1385 Joel Pacaanas
Note: See TracChangeset
for help on using the changeset viewer.