Changeset ec95d11


Ignore:
Timestamp:
Jun 8, 2017, 7:55:13 AM (7 years ago)
Author:
Peter A. Buhr <pabuhr@…>
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:
5a7966b, 8f8af30
Parents:
d7dc824
Message:

formatting

Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • src/tests/Makefile.am

    rd7dc824 rec95d11  
    1111## Created On       : Sun May 31 09:08:15 2015
    1212## Last Modified By : Peter A. Buhr
    13 ## Last Modified On : Thu May 25 14:39:15 2017
    14 ## Update Count     : 43
     13## Last Modified On : Thu Jun  8 07:41:43 2017
     14## Update Count     : 44
    1515###############################################################################
    1616
     
    2020
    2121if BUILD_CONCURRENCY
    22 concurrent=yes
    23 quick_test+= coroutine thread monitor
    24 concurrent_test=coroutine thread monitor multi-monitor sched-int-barge sched-int-block sched-int-disjoint sched-int-wait sched-ext sched-ext-multi preempt
     22concurrent = yes
     23quick_test += coroutine thread monitor
     24concurrent_test = coroutine thread monitor multi-monitor sched-int-barge sched-int-block sched-int-disjoint sched-int-wait sched-ext sched-ext-multi preempt
    2525else
    2626concurrent=no
  • src/tests/coroutine.c

    rd7dc824 rec95d11  
     1//
     2// Cforall Version 1.0.0 Copyright (C) 2017 University of Waterloo
     3//
     4// The contents of this file are covered under the licence agreement in the
     5// file "LICENCE" distributed with Cforall.
     6//
     7// fibonacci.c --
     8//
     9// Author           : Thierry Delisle
     10// Created On       : Thu Jun  8 07:29:37 2017
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Thu Jun  8 07:37:12 2017
     13// Update Count     : 5
     14//
     15
    116#include <fstream>
    217#include <coroutine>
    318
    419coroutine Fibonacci {
    5       int fn; // used for communication
     20        int fn;                                         // used for communication
    621};
    722
    8 void ?{}(Fibonacci* this) {
    9       this->fn = 0;
     23void ?{}( Fibonacci * this ) {
     24        this->fn = 0;
    1025}
    1126
    12 void main(Fibonacci* this) {
    13       int fn1, fn2;             // retained between resumes
    14       this->fn = 0;
    15       fn1 = this->fn;
    16       suspend();                // return to last resume
     27void main( Fibonacci * this ) {
     28        int fn1, fn2;                                   // retained between resumes
     29        this->fn = 0;                                   // case 0
     30        fn1 = this->fn;
     31        suspend();                                              // return to last resume
    1732
    18       this->fn = 1;
    19       fn2 = fn1;
    20       fn1 = this->fn;
    21       suspend();                // return to last resume
     33        this->fn = 1;                                   // case 1
     34        fn2 = fn1;
     35        fn1 = this->fn;
     36        suspend();                                              // return to last resume
    2237
    23       for ( ;; ) {
    24             this->fn = fn1 + fn2;
    25             fn2 = fn1;
    26             fn1 = this->fn;
    27             suspend(); // return to last resume
    28       }
     38        for ( ;; ) {                                    // general case
     39                this->fn = fn1 + fn2;
     40                fn2 = fn1;
     41                fn1 = this->fn;
     42                suspend();                                      // return to last resume
     43        } // for
    2944}
    3045
    31 int next(Fibonacci* this) {
    32       resume(this); // transfer to last suspend
    33       return this->fn;
     46int next( Fibonacci * this ) {
     47        resume( this );                                 // transfer to last suspend
     48        return this->fn;
    3449}
    3550
    3651int main() {
    37       Fibonacci f1, f2;
    38       for ( int i = 1; i <= 10; i += 1 ) {
    39             sout | next(&f1) | ' ' | next(&f2) | endl;
    40       }
     52        Fibonacci f1, f2;
     53        for ( int i = 1; i <= 10; i += 1 ) {
     54                sout | next( &f1 ) | ' ' | next( &f2 ) | endl;
     55        } // for
     56}
    4157
    42       return 0;
    43 }
     58// Local Variables: //
     59// tab-width: 4 //
     60// compile-command: "cfa fibonacci.c" //
     61// End: //
Note: See TracChangeset for help on using the changeset viewer.