Ignore:
Timestamp:
Feb 13, 2017, 5:04:43 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:
ee897e4b
Parents:
75f3522
Message:

Implemented better condition lock to solve race condition on thread/processor termination

File:
1 edited

Legend:

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

    r75f3522 rdb6f06a  
    3030      #define SCHEDULER_CAPACITY 10
    3131
     32      struct spinlock {
     33            volatile int lock;
     34      };
     35
    3236      struct simple_thread_list {
    3337            struct thread * head;
    3438            struct thread ** tail;
     39      };
     40
     41      // struct simple_lock {
     42      //        struct simple_thread_list blocked;
     43      // };
     44
     45      struct signal_once {
     46            volatile bool condition;
     47            struct spinlock lock;
     48            struct simple_thread_list blocked;
    3549      };
    3650
     
    4054            void append( struct simple_thread_list *, struct thread * );
    4155            struct thread * pop_head( struct simple_thread_list * );
     56
     57            // void ?{}(simple_lock * this);
     58            // void ^?{}(simple_lock * this);
     59
     60            void ?{}(spinlock * this);
     61            void ^?{}(spinlock * this);
     62
     63            void ?{}(signal_once * this);
     64            void ^?{}(signal_once * this);
    4265      }
    4366      #endif
     
    6083            int errno_;                         // copy of global UNIX variable errno
    6184            enum coroutine_state state; // current execution status for coroutine
    62             bool notHalted;                     // indicate if execuation state is not halted
    63 
     85            bool notHalted;                   // indicate if execuation state is not halted
    6486            struct coroutine *starter;  // first coroutine to resume this one
    6587            struct coroutine *last;             // last coroutine to resume this one
    6688      };
    6789
    68       struct simple_lock {
    69         struct simple_thread_list blocked;
    70       };
    71 
    7290      struct thread {
    7391            struct coroutine c;
    74             struct simple_lock lock;
     92            signal_once terminated;             // indicate if execuation state is not halted
    7593            struct thread * next;
    7694      };
Note: See TracChangeset for help on using the changeset viewer.