Changeset 47b5b63


Ignore:
Timestamp:
Sep 20, 2017, 12:03:55 PM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
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:
b462670, e4d6335, f980549
Parents:
d22e90f (diff), 39fea2f (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:/u/cforall/software/cfa/cfa-cc

Location:
src/libcfa/concurrency
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/concurrency/coroutine.c

    rd22e90f r47b5b63  
    6565        this.errno_ = 0;
    6666        this.state = Start;
    67         this.starter = NULL;
     67        this.starter = this_coroutine;
    6868        this.last = NULL;
    6969}
     
    171171                suspend();
    172172        }
     173
     174        void __leave_coroutine(void) {
     175                coroutine_desc * src = this_coroutine;          // optimization
     176
     177                assertf( src->starter != 0,
     178                        "Attempt to suspend coroutine \"%.256s\" (%p) that does not have a starter.\n"
     179                        "Possible cause is a resume of a coroutine already destroyed or not yet constructed",
     180                        src->name, src );
     181                assertf( src->starter->state != Halted,
     182                        "Attempt by coroutine \"%.256s\" (%p) to suspend back to terminated coroutine \"%.256s\" (%p).\n"
     183                        "Possible cause is terminated coroutine's main routine has already returned.",
     184                        src->name, src, src->starter->name, src->starter );
     185
     186                CoroutineCtxSwitch( src, src->starter );
     187        }
    173188}
    174189
  • src/libcfa/concurrency/invoke.c

    rd22e90f r47b5b63  
    2828
    2929extern void __suspend_internal(void);
     30extern void __leave_coroutine(void);
    3031extern void __leave_thread_monitor( struct thread_desc * this );
    3132extern void disable_interrupts();
     
    5253
    5354      //Final suspend, should never return
    54       __suspend_internal();
     55      __leave_coroutine();
    5556      abortf("Resumed dead coroutine");
    5657}
  • src/libcfa/concurrency/invoke.h

    rd22e90f r47b5b63  
    8080            int errno_;                               // copy of global UNIX variable errno
    8181            enum coroutine_state state;               // current execution status for coroutine
    82             struct coroutine_desc *starter;           // first coroutine to resume this one
    83             struct coroutine_desc *last;                    // last coroutine to resume this one
     82            struct coroutine_desc * starter;          // first coroutine to resume this one
     83            struct coroutine_desc * last;             // last coroutine to resume this one
    8484      };
    8585
  • src/libcfa/concurrency/kernel.c

    rd22e90f r47b5b63  
    102102        this.errno_ = 0;
    103103        this.state = Start;
     104        this.starter = NULL;
    104105}
    105106
     
    110111//-----------------------------------------------------------------------------
    111112// Processor coroutine
     113
     114// Construct the processor context of the main processor
    112115void ?{}(processorCtx_t & this, processor * proc) {
    113116        (this.__cor){ "Processor" };
     117        this.__cor.starter = &mainThread->cor;
    114118        this.proc = proc;
    115119        proc->runner = &this;
    116120}
    117121
     122// Construct the processor context of non-main processors
    118123void ?{}(processorCtx_t & this, processor * proc, current_stack_info_t * info) {
    119124        (this.__cor){ info };
Note: See TracChangeset for help on using the changeset viewer.