Changeset 9c31349


Ignore:
Timestamp:
Mar 21, 2017, 3:11:30 PM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
da6d4566
Parents:
cb0e6de
Message:

Removed unnecessary synchronisation routines in threads, now using monitor instead

Location:
src/libcfa/concurrency
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/concurrency/invoke.h

    rcb0e6de r9c31349  
    3838      };
    3939
    40       struct signal_once {
    41             volatile bool condition;
    42             struct spinlock lock;
    43             struct simple_thread_list blocked;
    44       };
    45 
    4640      #ifdef __CFORALL__
    4741      extern "Cforall" {
     
    5246            void ?{}(spinlock * this);
    5347            void ^?{}(spinlock * this);
    54 
    55             void ?{}(signal_once * this);
    56             void ^?{}(signal_once * this);
    5748      }
    5849      #endif
     
    8879      struct thread_desc {
    8980            struct coroutine_desc cor;          // coroutine body used to store context
    90             struct monitor_desc mon;
    91             struct signal_once terminated;      // indicate if execuation state is not halted
     81            struct monitor_desc mon;            // monitor body used for mutual exclusion
    9282            struct thread_desc * next;          // instrusive link field for threads
    9383      };
  • src/libcfa/concurrency/kernel

    rcb0e6de r9c31349  
    3030void lock( spinlock * );
    3131void unlock( spinlock * );
     32
     33struct signal_once {
     34        volatile bool condition;
     35        struct spinlock lock;
     36        struct simple_thread_list blocked;
     37};
     38
     39void ?{}(signal_once * this);
     40void ^?{}(signal_once * this);
    3241
    3342void wait( signal_once * );
  • src/libcfa/concurrency/thread.c

    rcb0e6de r9c31349  
    3535void start( T* this );
    3636
    37 forall( dtype T | is_thread(T) )
    38 void stop( T* this );
    39 
    4037//-----------------------------------------------------------------------------
    4138// Thread ctors and dtors
     
    4643        this->mon.owner = this;
    4744        this->mon.recursion = 1;
    48         (&this->terminated){};
    4945        this->next = NULL;
    5046}
     
    6864forall( dtype T | sized(T) | is_thread(T) )
    6965void ^?{}( scoped(T)* this ) {
    70         stop(&this->handle);
    7166        ^(&this->handle){};
    7267}
     
    8883
    8984        ScheduleThread(thrd_h);
    90 }
    91 
    92 forall( dtype T | is_thread(T) )
    93 void stop( T* this ) {
    94         // wait( & get_thread(this)->terminated );     
    9585}
    9686
     
    118108}
    119109
    120 // C Helper to signal the termination of a thread_desc
    121 // Used in invoke.c
    122 extern "C" {
    123         void __thread_signal_termination( thread_desc * this ) {
    124                 this->cor.state = Halted;
    125                 LIB_DEBUG_PRINTF("Thread end : %p\n", this);
    126                 signal( &this->terminated );   
    127         }
    128 }
    129 
    130110// Local Variables: //
    131111// mode: c //
Note: See TracChangeset for help on using the changeset viewer.