Changes in / [00f89a6:2325b57]


Ignore:
Location:
doc/uC++toCFA
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • doc/uC++toCFA/.gitignore

    r00f89a6 r2325b57  
    33*.pdf
    44*.ps
     5*.cc
     6*.cfa
  • doc/uC++toCFA/uC++toCFA.tex

    r00f89a6 r2325b57  
    1111%% Created On       : Wed Apr  6 14:53:29 2016
    1212%% Last Modified By : Peter A. Buhr
    13 %% Last Modified On : Mon Nov 11 21:51:39 2024
    14 %% Update Count     : 6144
     13%% Last Modified On : Wed Nov 13 18:09:58 2024
     14%% Update Count     : 6207
    1515%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1616
     
    540540
    541541
     542\section{Thread}
     543
     544\begin{cquote}
     545\begin{tabular}{@{}l|ll@{}}
     546\begin{uC++}
     547
     548@_Task@ T {
     549        // private task fields
     550        void main() {
     551                ... @_Resume E( ... ) _At partner@;
     552                ... @uThisTask();@ ...
     553        }
     554  public:
     555};
     556\end{uC++}
     557&
     558\begin{cfa}
     559#include <$thread$.hfa>
     560@thread@ T {
     561        // private task fields
     562
     563};
     564void main( @T & t@ ) {
     565        ... @resumeAt( partner, ExceptionInst( E, ... )@ );
     566        ... @active_thread();@ ...
     567}
     568\end{cfa}
     569\\
     570\multicolumn{2}{@{}l@{}}{\lstinline{T t; // start thread in main routine}}
     571\end{tabular}
     572\end{cquote}
     573
     574
    542575\section{\lstinline{COBEGIN}/\lstinline{COFOR}}
    543576
     
    658691
    659692
    660 \section{Thread}
    661 
    662 \begin{cquote}
    663 \begin{tabular}{@{}l|ll@{}}
    664 \begin{uC++}
    665 
    666 @_Task@ T {
    667         // private task fields
    668         void main() {
    669                 ... _Resume E( ... ) _At partner;
    670                 ... uThisTask(); ...
    671         }
    672   public:
    673 };
    674 \end{uC++}
    675 &
    676 \begin{cfa}
    677 #include <$thread$.hfa>
    678 @thread@ T {
    679         // private task fields
    680 
    681 };
    682 void main( @T & t@ ) {
    683         ... resumeAt( partner, ExceptionInst( E, ... ) );
    684         ... active_thread(); ...
    685 }
    686 \end{cfa}
    687 \\
    688 \multicolumn{2}{@{}l@{}}{\lstinline{T t; // start thread in main routine}}
    689 \end{tabular}
    690 \end{cquote}
    691 
    692 
    693693\section{Locks}
    694694
     
    721721\end{cquote}
    722722
     723
     724\section{Barrier}
     725
     726\begin{cquote}
     727\begin{tabular}{@{}l|ll@{}}
     728\begin{uC++}
     729#include <iostream>
     730using namespace std;
     731#include <uBarrier.h>
     732
     733@_Cormonitor@ Barrier
     734                : @public uBarrier@ { // inheritance
     735        int total;
     736  public:
     737        Barrier( unsigned int group ) :
     738                        @uBarrier( group )@ {
     739                total = 0;
     740        }
     741        void @block@( int subtotal ) {
     742                total += subtotal;
     743                @uBarrier::block();@
     744        }
     745  private:
     746        void @last@() { cout << total << endl; }
     747};
     748enum { N = 3 };
     749Barrier b{ N };
     750
     751_Task T {
     752        void main() {
     753                for ( int i = 0; i < 10; i += 1 ) {
     754                        b.block( 1 );
     755                }
     756        }
     757};
     758int main() {
     759        uProcessor p[N - 1];
     760        T t[N];
     761}
     762\end{uC++}
     763&
     764\begin{cfa}
     765#include <fstream.hfa>
     766#include <$thread$.hfa>
     767#include <barrier.hfa>
     768#include <mutex_stmt.hfa>
     769struct Barrier {
     770        @barrier b;@                    // containment
     771        int total;
     772};
     773void ?{}( Barrier & B, unsigned int group ) with(B) {
     774        @?{}( b, group );@              // initialize barrier
     775        total = 0;
     776}
     777unsigned int block( Barrier & B, int subtotal ) with(B) {
     778        @mutex( b )@ {  total += subtotal; } // use barrier's mutual exclusion
     779        void @last@() { sout | total; } // called by Gth arriving thread
     780        @block@( b, last ); // wait for barrier trigger
     781}
     782
     783
     784enum { N = 3 };
     785Barrier b{ N };
     786
     787thread T {};
     788void main( T & ) {
     789        for ( 10 ) {
     790                block( b, 1 );
     791        }
     792}
     793
     794int main() {
     795        processor p[N - 1];
     796        T t[N];
     797}
     798\end{cfa}
     799\end{tabular}
     800\end{cquote}
     801
     802\newpage
    723803
    724804\section{Monitor}
     
    789869\end{cquote}
    790870
    791 \newpage
     871\enlargethispage{1000pt}
    792872
    793873External Scheduling
Note: See TracChangeset for help on using the changeset viewer.