Ignore:
File:
1 edited

Legend:

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

    r381fdee r4c1b48f3  
    1010// Created On       : Tue Jan 17 12:27:26 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Feb  9 14:41:55 2018
    13 // Update Count     : 6
     12// Last Modified On : Fri Mar 30 22:33:59 2018
     13// Update Count     : 30
    1414//
    1515
     
    1717#include "bits/defs.h"
    1818#include "bits/locks.h"
     19
     20#define TL_GET( member ) kernelThreadData.member
     21#define TL_SET( member, value ) kernelThreadData.member = value;
    1922
    2023#ifdef __cforall
     
    3033                static inline struct thread_desc             * & get_next( struct thread_desc             & this );
    3134                static inline struct __condition_criterion_t * & get_next( struct __condition_criterion_t & this );
     35
     36                extern thread_local struct KernelThreadData {
     37                        struct coroutine_desc * volatile this_coroutine;
     38                        struct thread_desc    * volatile this_thread;
     39                        struct processor      * volatile this_processor;
     40
     41                        struct {
     42                                volatile unsigned short disable_count;
     43                                volatile bool enabled;
     44                                volatile bool in_progress;
     45                        } preemption_state;
     46                } kernelThreadData;
    3247        }
     48
     49        static inline struct coroutine_desc * volatile active_coroutine() { return TL_GET( this_coroutine ); }
     50        static inline struct thread_desc * volatile active_thread() { return TL_GET( this_thread ); }
     51        static inline struct processor * volatile active_processor() { return TL_GET( this_processor ); }
    3352        #endif
    3453
    3554        struct coStack_t {
    36                 // size of stack
    37                 size_t size;
    38 
    39                 // pointer to stack
    40                 void *storage;
    41 
    42                 // stack grows towards stack limit
    43                 void *limit;
    44 
    45                 // base of stack
    46                 void *base;
    47 
    48                 // address of cfa_context_t
    49                 void *context;
    50 
    51                 // address of top of storage
    52                 void *top;
    53 
    54                 // whether or not the user allocated the stack
    55                 bool userStack;
     55                size_t size;                                                                    // size of stack
     56                void * storage;                                                                 // pointer to stack
     57                void * limit;                                                                   // stack grows towards stack limit
     58                void * base;                                                                    // base of stack
     59                void * context;                                                                 // address of cfa_context_t
     60                void * top;                                                                             // address of top of storage
     61                bool userStack;                                                                 // whether or not the user allocated the stack
    5662        };
    5763
     
    5965
    6066        struct coroutine_desc {
    61                 // stack information of the coroutine
    62                 struct coStack_t stack;
    63 
    64                 // textual name for coroutine/task, initialized by uC++ generated code
    65                 const char *name;
    66 
    67                 // copy of global UNIX variable errno
    68                 int errno_;
    69 
    70                 // current execution status for coroutine
    71                 enum coroutine_state state;
    72 
    73                 // first coroutine to resume this one
    74                 struct coroutine_desc * starter;
    75 
    76                 // last coroutine to resume this one
    77                 struct coroutine_desc * last;
     67                struct coStack_t stack;                                                 // stack information of the coroutine
     68                const char * name;                                                              // textual name for coroutine/task, initialized by uC++ generated code
     69                int errno_;                                                                             // copy of global UNIX variable errno
     70                enum coroutine_state state;                                             // current execution status for coroutine
     71                struct coroutine_desc * starter;                                // first coroutine to resume this one
     72                struct coroutine_desc * last;                                   // last coroutine to resume this one
    7873        };
    7974
Note: See TracChangeset for help on using the changeset viewer.