Changeset c3acb841


Ignore:
Timestamp:
Mar 15, 2017, 4:10:41 PM (7 years ago)
Author:
Thierry Delisle <tdelisle@…>
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:
84c52a8
Parents:
0e7b95c
Message:

Renamed type coroutine to coroutine_desc

Location:
src
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • src/benchmark/CorCtxSwitch.c

    r0e7b95c rc3acb841  
    2424
    2525struct GreatSuspender {
    26         coroutine c;
     26        coroutine_desc c;
    2727};
    2828
  • src/benchmark/bench.c

    r0e7b95c rc3acb841  
    8686//=======================================
    8787
    88 struct CoroutineDummy { coroutine c; };
     88struct CoroutineDummy { coroutine_desc c; };
    8989DECL_COROUTINE(CoroutineDummy);
    9090void main(CoroutineDummy * this) {}
     
    119119struct CoroutineResume {
    120120    int N;
    121     coroutine c;
     121    coroutine_desc c;
    122122};
    123123
  • src/benchmark/csv-data.c

    r0e7b95c rc3acb841  
    2626
    2727struct GreatSuspender {
    28         coroutine c;
     28        coroutine_desc c;
    2929};
    3030
  • src/libcfa/concurrency/coroutine

    r0e7b95c rc3acb841  
    2727trait is_coroutine(dtype T) {
    2828      void main(T * this);
    29       coroutine * get_coroutine(T * this);
     29      coroutine_desc * get_coroutine(T * this);
    3030};
    3131
    32 #define DECL_COROUTINE(X) static inline coroutine* get_coroutine(X* this) { return &this->c; } void main(X* this)
     32#define DECL_COROUTINE(X) static inline coroutine_desc* get_coroutine(X* this) { return &this->c; } void main(X* this)
    3333
    3434//-----------------------------------------------------------------------------
    3535// Ctors and dtors
    3636void ?{}(coStack_t * this);
    37 void ?{}(coroutine * this);
    38 void ?{}(coroutine * this, const char * name);
     37void ?{}(coroutine_desc * this);
     38void ?{}(coroutine_desc * this, const char * name);
    3939void ^?{}(coStack_t * this);
    40 void ^?{}(coroutine * this);
     40void ^?{}(coroutine_desc * this);
    4141
    4242//-----------------------------------------------------------------------------
     
    6363
    6464// Get current coroutine
    65 coroutine * this_coroutine(void);
     65coroutine_desc * this_coroutine(void);
    6666
    6767// Private wrappers for context switch and stack creation
    68 extern void CoroutineCtxSwitch(coroutine * src, coroutine * dst);
     68extern void CoroutineCtxSwitch(coroutine_desc * src, coroutine_desc * dst);
    6969extern void create_stack( coStack_t * this, unsigned int storageSize );
    7070
    7171// Suspend implementation inlined for performance
    7272static inline void suspend() {
    73       coroutine * src = this_coroutine();               // optimization
     73      coroutine_desc * src = this_coroutine();          // optimization
    7474
    7575        assertf( src->last != 0,
     
    8888forall(dtype T | is_coroutine(T))
    8989static inline void resume(T * cor) {
    90         coroutine * src = this_coroutine();             // optimization
    91         coroutine * dst = get_coroutine(cor);
     90        coroutine_desc * src = this_coroutine();                // optimization
     91        coroutine_desc * dst = get_coroutine(cor);
    9292
    9393      if( unlikely(!dst->stack.base) ) {
     
    111111}
    112112
    113 static inline void resume(coroutine * dst) {
    114         coroutine * src = this_coroutine();             // optimization
     113static inline void resume(coroutine_desc * dst) {
     114        coroutine_desc * src = this_coroutine();                // optimization
    115115
    116116      // not resuming self ?
  • src/libcfa/concurrency/coroutine.c

    r0e7b95c rc3acb841  
    6060}
    6161
    62 void ?{}(coroutine* this) {
     62void ?{}(coroutine_desc* this) {
    6363        this{ "Anonymous Coroutine" };
    6464}
    6565
    66 void ?{}(coroutine* this, const char * name) {
     66void ?{}(coroutine_desc* this, const char * name) {
    6767        this->name = name;
    6868        this->errno_ = 0;
     
    7272}
    7373
    74 void ?{}(coroutine* this, size_t size) {
     74void ?{}(coroutine_desc* this, size_t size) {
    7575        this{};
    7676        (&this->stack){size};
     
    8888}
    8989
    90 void ^?{}(coroutine* this) {}
     90void ^?{}(coroutine_desc* this) {}
    9191
    9292// Part of the Public API
     
    9494forall(dtype T | is_coroutine(T))
    9595void prime(T* cor) {
    96         coroutine* this = get_coroutine(cor);
     96        coroutine_desc* this = get_coroutine(cor);
    9797        assert(this->state == Start);
    9898
     
    102102
    103103// Wrapper for co
    104 void CoroutineCtxSwitch(coroutine* src, coroutine* dst) {
     104void CoroutineCtxSwitch(coroutine_desc* src, coroutine_desc* dst) {
    105105        // THREAD_GETMEM( This )->disableInterrupts();
    106106
  • src/libcfa/concurrency/invoke.c

    r0e7b95c rc3acb841  
    3333void CtxInvokeCoroutine(
    3434      void (*main)(void *),
    35       struct coroutine *(*get_coroutine)(void *),
     35      struct coroutine_desc *(*get_coroutine)(void *),
    3636      void *this
    3737) {
    3838      // LIB_DEBUG_PRINTF("Invoke Coroutine : Received %p (main %p, get_c %p)\n", this, main, get_coroutine);
    3939
    40       struct coroutine* cor = get_coroutine( this );
     40      struct coroutine_desc* cor = get_coroutine( this );
    4141
    4242      if(cor->state == Primed) {
     
    6363
    6464      struct thread* thrd = get_thread( this );
    65       struct coroutine* cor = &thrd->c;
     65      struct coroutine_desc* cor = &thrd->c;
    6666      cor->state = Active;
    6767
     
    7979void CtxStart(
    8080      void (*main)(void *),
    81       struct coroutine *(*get_coroutine)(void *),
     81      struct coroutine_desc *(*get_coroutine)(void *),
    8282      void *this,
    8383      void (*invoke)(void *)
  • src/libcfa/concurrency/invoke.h

    r0e7b95c rc3acb841  
    7171      enum coroutine_state { Halted, Start, Inactive, Active, Primed };
    7272
    73       struct coroutine {
     73      struct coroutine_desc {
    7474            struct coStack_t stack;
    7575            const char *name;                         // textual name for coroutine/task, initialized by uC++ generated code
    7676            int errno_;                               // copy of global UNIX variable errno
    7777            enum coroutine_state state;       // current execution status for coroutine
    78             struct coroutine *starter;        // first coroutine to resume this one
    79             struct coroutine *last;                   // last coroutine to resume this one
     78            struct coroutine_desc *starter;           // first coroutine to resume this one
     79            struct coroutine_desc *last;                      // last coroutine to resume this one
    8080      };
    8181
    8282      struct thread {
    83             struct coroutine c;                 // coroutine body used to store context
     83            struct coroutine_desc c;                 // coroutine body used to store context
    8484            struct signal_once terminated;      // indicate if execuation state is not halted
    8585            struct thread * next;               // instrusive link field for threads
  • src/libcfa/concurrency/kernel

    r0e7b95c rc3acb841  
    6262        struct processorCtx_t * runner;
    6363        cluster * cltr;
    64         coroutine * current_coroutine;
     64        coroutine_desc * current_coroutine;
    6565        thread * current_thread;
    6666        pthread_t kernel_thread;
  • src/libcfa/concurrency/kernel.c

    r0e7b95c rc3acb841  
    5555thread_local processor * this_processor;
    5656
    57 coroutine * this_coroutine(void) {
     57coroutine_desc * this_coroutine(void) {
    5858        return this_processor->current_coroutine;
    5959}
     
    9999}
    100100
    101 void ?{}( coroutine * this, current_stack_info_t * info) {
     101void ?{}( coroutine_desc * this, current_stack_info_t * info) {
    102102        (&this->stack){ info };
    103103        this->name = "Main Thread";
     
    203203// from the processor coroutine to the target thread
    204204void runThread(processor * this, thread * dst) {
    205         coroutine * proc_cor = get_coroutine(this->runner);
    206         coroutine * thrd_cor = get_coroutine(dst);
     205        coroutine_desc * proc_cor = get_coroutine(this->runner);
     206        coroutine_desc * thrd_cor = get_coroutine(dst);
    207207       
    208208        //Reset the terminating actions here
  • src/libcfa/concurrency/kernel_private.h

    r0e7b95c rc3acb841  
    3535struct processorCtx_t {
    3636        processor * proc;
    37         coroutine c;
     37        coroutine_desc c;
    3838};
    3939
     
    5353}
    5454
    55 extern void ThreadCtxSwitch(coroutine * src, coroutine * dst);
     55extern void ThreadCtxSwitch(coroutine_desc * src, coroutine_desc * dst);
    5656
    5757#endif //KERNEL_PRIVATE_H
  • src/libcfa/concurrency/thread

    r0e7b95c rc3acb841  
    3535
    3636forall( dtype T | is_thread(T) )
    37 static inline coroutine* get_coroutine(T* this) {
     37static inline coroutine_desc* get_coroutine(T* this) {
    3838        return &get_thread(this)->c;
    3939}
    4040
    41 static inline coroutine* get_coroutine(thread* this) {
     41static inline coroutine_desc* get_coroutine(thread* this) {
    4242        return &this->c;
    4343}
  • src/libcfa/concurrency/thread.c

    r0e7b95c rc3acb841  
    7474forall( dtype T | is_thread(T) )
    7575void start( T* this ) {
    76         coroutine* thrd_c = get_coroutine(this);
     76        coroutine_desc* thrd_c = get_coroutine(this);
    7777        thread*  thrd_h = get_thread   (this);
    7878        thrd_c->last = this_coroutine();
     
    9797}
    9898
    99 void ThreadCtxSwitch(coroutine* src, coroutine* dst) {
     99void ThreadCtxSwitch(coroutine_desc* src, coroutine_desc* dst) {
    100100        // set state of current coroutine to inactive
    101101        src->state = Inactive;
  • src/tests/coroutine.c

    r0e7b95c rc3acb841  
    44struct Fibonacci {
    55      int fn; // used for communication
    6       coroutine c;
     6      coroutine_desc c;
    77};
    88
     
    1111}
    1212
    13 coroutine* get_coroutine(Fibonacci* this) {
     13coroutine_desc* get_coroutine(Fibonacci* this) {
    1414      return &this->c;
    1515}
     
    4747#ifdef MORE_DEBUG     
    4848      Fibonacci *pf1 = &f1, *pf2 = &f2;
    49       coroutine *cf1 = &f1.c, *cf2 = &f2.c;
     49      coroutine_desc *cf1 = &f1.c, *cf2 = &f2.c;
    5050      covptr_t  *vf1 = vtable(pf1), *vf2 = vtable(pf2);
    51       coroutine *cv1 = get_coroutine(vf1), *cv2 = get_coroutine(vf2);
     51      coroutine_desc *cv1 = get_coroutine(vf1), *cv2 = get_coroutine(vf2);
    5252      Fibonacci *ov1 = (Fibonacci *)get_object(vf1), *ov2 = (Fibonacci *)get_object(vf2);
    5353
Note: See TracChangeset for help on using the changeset viewer.