Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/theses/colby_parsons_MMAth/text/CFA_concurrency.tex

    r9509d67a raae9c17  
    11\chapter{Concurrency in \CFA}\label{s:cfa_concurrency}
    22
    3 The groundwork for concurrency in \CFA was laid by Thierry Delisle in his Master's Thesis~\cite{Delisle18}.
    4 In that work, he introduced generators, coroutines, monitors, and user-level threading.
    5 Not listed in that work were basic concurrency features needed as building blocks, such as locks, futures, and condition variables.
     3The groundwork for concurrency in \CFA was laid by Thierry Delisle in his Master's Thesis~\cite{Delisle18}. 
     4In that work, he introduced generators, coroutines, monitors, and user-level threading. 
     5Not listed in that work were basic concurrency features needed as building blocks, such as locks, futures, and condition variables, which he also added to \CFA.
    66
    77\section{Threading Model}\label{s:threading}
     8\CFA provides user-level threading and supports an $M$:$N$ threading model where $M$ user threads are scheduled on $N$ kernel threads, where both $M$ and $N$ can be explicitly set by the user.
     9Kernel threads are created by declaring a @processor@ structure.
     10User-thread types are defined by creating a @thread@ aggregate-type, \ie replace @struct@ with @thread@.
     11For each thread type a corresponding @main@ routine must be defined, which is where the thread starts running once it is created.
     12Examples of \CFA  user thread and processor creation are shown in \VRef[Listing]{l:cfa_thd_init}.
    813
    9 \CFA provides user-level threading and supports an $M$:$N$ threading model where $M$ user threads are scheduled on $N$ kernel threads and both $M$ and $N$ can be explicitly set by the programmer.
    10 Kernel threads are created by declaring processor objects;
    11 user threads are created by declaring a thread objects.
    12 \VRef[Listing]{l:cfa_thd_init} shows a typical examples of creating a \CFA user-thread type, and then as declaring processor ($N$) and thread objects ($M$).
    1314\begin{cfa}[caption={Example of \CFA user thread and processor creation},label={l:cfa_thd_init}]
    14 @thread@ my_thread {                            $\C{// user thread type (like structure)}$
    15         ... // arbitrary number of field declarations
    16 };
    17 void @main@( @my_thread@ & this ) {     $\C{// thread start routine}$
     15@thread@ my_thread {...};                       $\C{// user thread type}$
     16void @main@( my_thread & this ) {       $\C{// thread start routine}$
    1817        sout | "Hello threading world";
    1918}
    20 int main() {                                            $\C{// program starts with a processor (kernel thread)}$
     19
     20int main() {
    2121        @processor@ p[2];                               $\C{// add 2 processors = 3 total with starting processor}$
    2222        {
    23                 @my_thread@ t[2], * t3 = new(); $\C{// create 2 stack allocated, 1 dynamic allocated user threads}$
     23                my_thread t[2], * t3 = new();   $\C{// create 3 user threads, running in main routine}$
    2424                ... // execute concurrently
    25                 delete( t3 );                           $\C{// wait for t3 to end and deallocate}$
    26     } // wait for threads t[0] and t[1] to end and deallocate
    27 } // deallocate additional kernel threads
     25                delete( t3 );                           $\C{// wait for thread to end and deallocate}$
     26        } // wait for threads to end and deallocate
     27}
    2828\end{cfa}
    29 A thread type is are defined using the aggregate kind @thread@.
    30 For each thread type, a corresponding @main@ routine must be defined, which is where the thread starts running once when a thread object are is created.
    31 The @processor@ declaration adds addition kernel threads alongside the existing processor given to each program.
    32 Thus, for $N$ processors, allocate $N-1$ processors.
    33 A thread is implicitly joined at deallocation, either implicitly at block exit for stack allocation or explicitly at @delete@ for heap allocation.
    34 The thread performing the deallocation must wait for the thread to terminate before the deallocation can occur.
     29
     30When processors are added, they are added alongside the existing processor given to each program.
     31Thus, for $N$ processors, allocate $N-1$ processors.
     32A thread is implicitly joined at deallocation, either implicitly at block exit for stack allocation or explicitly at @delete@ for heap allocation.
     33The thread performing the deallocation must wait for the thread to terminate before the deallocation can occur.
    3534A thread terminates by returning from the main routine where it starts.
    3635
    37 \section{Existing and New Concurrency Features}
    38 
     36\section{Existing Concurrency Features}
    3937\CFA currently provides a suite of concurrency features including futures, locks, condition variables, generators, coroutines, monitors.
    4038Examples of these features are omitted as most of them are the same as their counterparts in other languages.
    4139It is worthwhile to note that all concurrency features added to \CFA are made to be compatible each other.
    42 The laundry list of features above and the ones introduced in this thesis can be used in the same program without issue, and the features are designed to interact in meaningful ways.
    43 For example, a thread can inteact with a monitor, which can interact with a coroutine, which can interact with a generator.
     40The laundry list of features above and the ones introduced in this thesis can be used in the same program without issue.
    4441
    4542Solving concurrent problems requires a diverse toolkit.
Note: See TracChangeset for help on using the changeset viewer.