Ignore:
Timestamp:
Apr 4, 2019, 3:37:55 PM (6 years ago)
Author:
tdelisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
8c01e1b
Parents:
2fabdc02
Message:

Swapped memory storage for context and stack information inside the coroutine implementation

File:
1 edited

Legend:

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

    r2fabdc02 rb2f6113  
    6262        #endif
    6363
    64         struct coStack_t {
    65                 size_t size;                                                                    // size of stack
    66                 void * storage;                                                                 // pointer to stack
    67                 void * limit;                                                                   // stack grows towards stack limit
    68                 void * base;                                                                    // base of stack
    69                 void * context;                                                                 // address of cfa_context_t
    70                 void * top;                                                                             // address of top of storage
    71                 bool userStack;                                                                 // whether or not the user allocated the stack
     64        struct __stack_context_t {
     65                void * SP;
     66
     67                void * FP;
     68                // copy of global UNIX variable errno
     69                int errno_;
     70        };
     71
     72        // low adresses  :           +----------------------+ <- start of allocation
     73        //                           |  optional guard page |
     74        //                           +----------------------+ <- __stack_t.limit
     75        //                           |                      |
     76        //                           |       /\ /\ /\       |
     77        //                           |       || || ||       |
     78        //                           |                      |
     79        //                           |    program  stack    |
     80        //                           |                      |
     81        // __stack_info_t.storage -> +----------------------+ <- __stack_t.base
     82        //                           |      __stack_t       |
     83        // high adresses :           +----------------------+ <- end of allocation
     84
     85        struct __stack_t {
     86                // size of stack
     87                size_t size;
     88
     89                // stack grows towards stack limit
     90                void * limit;
     91
     92                // base of stack
     93                void * base;
     94        };
     95
     96        struct __stack_info_t {
     97                // pointer to stack
     98                struct __stack_t * storage;
     99
     100                // whether or not the user allocated the stack
     101                bool userStack;
    72102        };
    73103
     
    75105
    76106        struct coroutine_desc {
     107                // context that is switch during a CtxSwitch
     108                struct __stack_context_t context;
     109
    77110                // stack information of the coroutine
    78                 struct coStack_t stack;
     111                struct __stack_info_t stack;
    79112
    80113                // textual name for coroutine/task, initialized by uC++ generated code
    81114                const char * name;
    82115
    83                 // copy of global UNIX variable errno
    84                 int errno_;
    85 
    86116                // current execution status for coroutine
    87117                enum coroutine_state state;
     118
    88119                // first coroutine to resume this one
    89120                struct coroutine_desc * starter;
     
    230261        // assembler routines that performs the context switch
    231262        extern void CtxInvokeStub( void );
    232         void CtxSwitch( void * from, void * to ) asm ("CtxSwitch");
     263        void CtxSwitch( struct __stack_context_t * from, struct __stack_context_t * to ) asm ("CtxSwitch");
    233264        // void CtxStore ( void * this ) asm ("CtxStore");
    234265        // void CtxRet   ( void * dst  ) asm ("CtxRet");
Note: See TracChangeset for help on using the changeset viewer.