Ignore:
Timestamp:
Aug 11, 2020, 4:40:15 PM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
0d070ca
Parents:
07d867b (diff), 129674b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into new-ast

File:
1 edited

Legend:

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

    r07d867b r22f94a4  
    1717#include "bits/defs.hfa"
    1818#include "bits/locks.hfa"
     19#include "kernel/fwd.hfa"
    1920
    2021#ifdef __cforall
     
    2526#ifndef _INVOKE_H_
    2627#define _INVOKE_H_
    27 
    28 #ifdef __ARM_ARCH
    29         // function prototypes are only really used by these macros on ARM
    30         void disable_global_interrupts();
    31         void enable_global_interrupts();
    32 
    33         #define TL_GET( member ) ( { __typeof__( kernelTLS.member ) target; \
    34                 disable_global_interrupts(); \
    35                 target = kernelTLS.member; \
    36                 enable_global_interrupts(); \
    37                 target; } )
    38         #define TL_SET( member, value ) disable_global_interrupts(); \
    39                 kernelTLS.member = value; \
    40                 enable_global_interrupts();
    41 #else
    42         #define TL_GET( member ) kernelTLS.member
    43         #define TL_SET( member, value ) kernelTLS.member = value;
    44 #endif
    45 
    46         #ifdef __cforall
    47         extern "Cforall" {
    48                 extern __attribute__((aligned(128))) thread_local struct KernelThreadData {
    49                         struct $thread    * volatile this_thread;
    50                         struct processor      * volatile this_processor;
    51 
    52                         struct {
    53                                 volatile unsigned short disable_count;
    54                                 volatile bool enabled;
    55                                 volatile bool in_progress;
    56                         } preemption_state;
    57 
    58                         uint32_t rand_seed;
    59                 } kernelTLS __attribute__ ((tls_model ( "initial-exec" )));
    60         }
    61         #endif
    6228
    6329        struct __stack_context_t {
     
    9258        };
    9359
    94         enum coroutine_state { Halted, Start, Primed, Blocked, Ready, Active, Rerun };
    95         enum __Preemption_Reason { __NO_PREEMPTION, __ALARM_PREEMPTION, __POLL_PREEMPTION, __MANUAL_PREEMPTION };
     60        enum __Coroutine_State { Halted, Start, Primed, Blocked, Ready, Active };
    9661
    9762        struct $coroutine {
     
    10671
    10772                // current execution status for coroutine
    108                 enum coroutine_state state;
     73                enum __Coroutine_State state;
    10974
    11075                // first coroutine to resume this one
     
    161126        };
    162127
     128        // Link lists fields
     129        // instrusive link field for threads
     130        struct __thread_desc_link {
     131                struct $thread * next;
     132                struct $thread * prev;
     133                volatile unsigned long long ts;
     134                int preferred;
     135        };
     136
    163137        struct $thread {
    164138                // Core threading fields
     
    167141
    168142                // current execution status for coroutine
    169                 volatile int state;
    170                 enum __Preemption_Reason preempted;
     143                volatile int ticket;
     144                enum __Coroutine_State state:8;
     145                enum __Preemption_Reason preempted:8;
    171146
    172147                //SKULLDUGGERY errno is not save in the thread data structure because returnToKernel appears to be the only function to require saving and restoring it
     148
     149                // pointer to the cluster on which the thread is running
     150                struct cluster * curr_cluster;
     151
     152                // Link lists fields
     153                // instrusive link field for threads
     154                struct __thread_desc_link link;
    173155
    174156                // coroutine body used to store context
     
    184166                struct $monitor *  self_mon_p;
    185167
    186                 // pointer to the cluster on which the thread is running
    187                 struct cluster * curr_cluster;
    188 
    189168                // monitors currently held by this thread
    190169                struct __monitor_group_t monitors;
    191 
    192                 // Link lists fields
    193                 // instrusive link field for threads
    194                 struct $thread * next;
    195170
    196171                struct {
     
    202177                        // previous function to park/unpark the thread
    203178                        const char * park_caller;
    204                         enum coroutine_state park_result;
     179                        int park_result;
     180                        enum __Coroutine_State park_state;
    205181                        bool park_stale;
    206182                        const char * unpark_caller;
    207                         enum coroutine_state unpark_result;
     183                        int unpark_result;
     184                        enum __Coroutine_State unpark_state;
    208185                        bool unpark_stale;
    209186                #endif
     
    218195        #ifdef __cforall
    219196        extern "Cforall" {
     197
    220198                static inline $thread *& get_next( $thread & this ) __attribute__((const)) {
    221                         return this.next;
     199                        return this.link.next;
    222200                }
    223201
Note: See TracChangeset for help on using the changeset viewer.