Ignore:
Timestamp:
Apr 4, 2023, 10:12:57 PM (15 months ago)
Author:
Mike Brooks <mlbrooks@…>
Branches:
ADT, ast-experimental, master
Children:
9bb8ee42
Parents:
ff71057 (diff), bb7422a (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

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

    rff71057 re02e13f  
    8888Similarly to create a message type a user must define a struct which \code{inline}'s the base \code{message} struct.
    8989
    90 \begin{cfacode}
     90\begin{cfa}
    9191struct derived_actor {
    9292    inline actor;       // Plan-9 C inheritance
     
    118118    return 0;
    119119}
    120 \end{cfacode}
     120\end{cfa}
    121121
    122122The above code is a simple actor program in \CFA.
     
    125125Key things to highlight include the \code{receive} signature, and calls to \code{start_actor_system}, and \code{stop_actor_system}.
    126126To define a behaviour for some derived actor and derived message type, one must declare a routine with the signature:
    127 \begin{cfacode}
     127\begin{cfa}
    128128Allocation receive( derived_actor & receiver, derived_msg & msg )
    129 \end{cfacode}
     129\end{cfa}
    130130Where \code{derived_actor} and \code{derived_msg} can be any derived actor and derived message types respectively.
    131131The return value of \code{receive} must be a value from the \code{Allocation} enum:
    132 \begin{cfacode}
     132\begin{cfa}
    133133enum Allocation { Nodelete, Delete, Destroy, Finished };
    134 \end{cfacode}
     134\end{cfa}
    135135The \code{Allocation} enum is a set of actions that dictate what the executor should do with a message or actor after a given behaviour has been completed.
    136136In the case of an actor, the \code{receive} routine returns the \code{Allocation} status to the executor which sets the status on the actor and takes the appropriate action.
    137137For messages, they either default to \code{Nodelete}, or they can be passed an \code{Allocation} via the \code{message} constructor.
    138138Message state can be updated via a call to:
    139 \begin{cfacode}
     139\begin{cfa}
    140140void set_allocation( message & this, Allocation state )
    141 \end{cfacode}
     141\end{cfa}
    142142
    143143The following describes the use of each of the \code{Allocation} values:
     
    186186All message sends are done using the left shift operater, \ie <<, similar to the syntax of \CC's output.
    187187The signature of the left shift operator is:
    188 \begin{cfacode}
     188\begin{cfa}
    189189Allocation ?<<?( derived_actor & receiver, derived_msg & msg )
    190 \end{cfacode}
     190\end{cfa}
    191191
    192192An astute eye will notice that this is the same signature as the \code{receive} routine which is no coincidence.
     
    368368To first verify sequential correctness, consider the equivalent sequential swap below:
    369369
    370 \begin{cfacode}
     370\begin{cfa}
    371371void swap( uint victim_idx, uint my_idx  ) {
    372372    // Step 0:
     
    380380    request_queues[my_idx] = vic_queue;
    381381}
    382 \end{cfacode}
     382\end{cfa}
    383383
    384384Step 1 is missing in the sequential example since in only matter in the concurrent context presented later.
     
    386386Temporary copies of each pointer being swapped are stored, and then the original values of each pointer are set using the copy of the other pointer.
    387387
    388 \begin{cfacode}
     388\begin{cfa}
    389389// This routine is atomic
    390390bool CAS( work_queue ** ptr, work_queue ** old, work_queue * new ) {
     
    427427    return true;
    428428}
    429 \end{cfacode}\label{c:swap}
     429\end{cfa}\label{c:swap}
    430430
    431431Now consider the concurrent implementation of the swap.
Note: See TracChangeset for help on using the changeset viewer.