Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/kernel.hfa

    re3fea42 r8c50aed  
    1010// Created On       : Tue Jan 17 12:27:26 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Feb  4 12:29:26 2020
    13 // Update Count     : 22
     12// Last Modified On : Wed Dec  4 07:54:51 2019
     13// Update Count     : 18
    1414//
    1515
     
    4545extern struct cluster * mainCluster;
    4646
    47 enum FinishOpCode { No_Action, Release, Schedule, Release_Schedule, Release_Multi, Release_Multi_Schedule, Callback };
    48 
    49 typedef void (*__finish_callback_fptr_t)(void);
    50 
    51 //TODO use union, many of these fields are mutually exclusive (i.e. MULTI vs NOMULTI)
    52 struct FinishAction {
    53         FinishOpCode action_code;
    54         /*
    55         // Union of possible actions
    56         union {
    57                 // Option 1 : locks and threads
    58                 struct {
    59                         // 1 thread or N thread
    60                         union {
    61                                 thread_desc * thrd;
    62                                 struct {
    63                                         thread_desc ** thrds;
    64                                         unsigned short thrd_count;
    65                                 };
    66                         };
    67                         // 1 lock or N lock
    68                         union {
    69                                 __spinlock_t * lock;
    70                                 struct {
    71                                         __spinlock_t ** locks;
    72                                         unsigned short lock_count;
    73                                 };
    74                         };
    75                 };
    76                 // Option 2 : action pointer
    77                 __finish_callback_fptr_t callback;
    78         };
    79         /*/
    80         thread_desc * thrd;
    81         thread_desc ** thrds;
    82         unsigned short thrd_count;
    83         __spinlock_t * lock;
    84         __spinlock_t ** locks;
    85         unsigned short lock_count;
    86         __finish_callback_fptr_t callback;
    87         //*/
    88 };
    89 static inline void ?{}(FinishAction & this) {
    90         this.action_code = No_Action;
    91         this.thrd = 0p;
    92         this.lock = 0p;
    93 }
    94 static inline void ^?{}(FinishAction &) {}
    95 
    9647// Processor
    9748coroutine processorCtx_t {
     
    11667        // RunThread data
    11768        // Action to do after a thread is ran
    118         struct FinishAction finish;
     69        thread_desc * destroyer;
    11970
    12071        // Preemption data
     
    150101};
    151102
    152 void  ?{}(processor & this, const char name[], struct cluster & cltr);
     103void  ?{}(processor & this, const char * name, struct cluster & cltr);
    153104void ^?{}(processor & this);
    154105
    155106static inline void  ?{}(processor & this)                    { this{ "Anonymous Processor", *mainCluster}; }
    156107static inline void  ?{}(processor & this, struct cluster & cltr)    { this{ "Anonymous Processor", cltr}; }
    157 static inline void  ?{}(processor & this, const char name[]) { this{name, *mainCluster }; }
     108static inline void  ?{}(processor & this, const char * name) { this{name, *mainCluster }; }
    158109
    159 static inline [processor *&, processor *& ] __get( processor & this ) {
    160         return this.node.[next, prev];
    161 }
     110static inline [processor *&, processor *& ] __get( processor & this ) /*__attribute__((const))*/ { return this.node.[next, prev]; }
    162111
    163112//-----------------------------------------------------------------------------
     
    195144extern Duration default_preemption();
    196145
    197 void ?{} (cluster & this, const char name[], Duration preemption_rate);
     146void ?{} (cluster & this, const char * name, Duration preemption_rate);
    198147void ^?{}(cluster & this);
    199148
    200149static inline void ?{} (cluster & this)                           { this{"Anonymous Cluster", default_preemption()}; }
    201150static inline void ?{} (cluster & this, Duration preemption_rate) { this{"Anonymous Cluster", preemption_rate}; }
    202 static inline void ?{} (cluster & this, const char name[])        { this{name, default_preemption()}; }
     151static inline void ?{} (cluster & this, const char * name)        { this{name, default_preemption()}; }
    203152
    204 static inline [cluster *&, cluster *& ] __get( cluster & this ) {
    205         return this.node.[next, prev];
    206 }
     153static inline [cluster *&, cluster *& ] __get( cluster & this ) /*__attribute__((const))*/ { return this.node.[next, prev]; }
    207154
    208 static inline struct processor * active_processor() { return TL_GET( this_processor ); } // UNSAFE
    209 static inline struct cluster   * active_cluster  () { return TL_GET( this_processor )->cltr; }
     155static inline struct processor * active_processor() __attribute__((const)) { return TL_GET( this_processor ); } // UNSAFE
     156static inline struct cluster   * active_cluster  () __attribute__((const)) { return TL_GET( this_processor )->cltr; }
    210157
    211158// Local Variables: //
Note: See TracChangeset for help on using the changeset viewer.