source: src/libcfa/concurrency/invoke.h @ 4a9ccc3

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since 4a9ccc3 was bd98b58, checked in by Thierry Delisle <tdelisle@…>, 8 years ago

Kernel now uses intrusive lists and blocking locks for ready queue management.
Update the plan for concurrency.

  • Property mode set to 100644
File size: 2.4 KB
RevLine 
[5c81105]1#include <stdbool.h>
2#include <stdint.h>
[78b3f52]3
[5c81105]4#ifdef __CFORALL__
5extern "C" {
6#endif
7
8#if ! defined(__CFA_INVOKE_PRIVATE__)
[78b3f52]9#ifndef _INVOKE_H_
10#define _INVOKE_H_
11
[596f987b]12      #define unlikely(x)    __builtin_expect(!!(x), 0)
[bd98b58]13      #define SCHEDULER_CAPACITY 10
14
15      struct simple_thread_list {
16            struct thread_h * head;
17            struct thread_h ** tail;
18      };
19
20      #ifdef __CFORALL__
21      extern "Cforall" {
22            void ?{}( struct simple_thread_list * );
23            void append( struct simple_thread_list *, struct thread_h * );
24            struct thread_h * pop_head( struct simple_thread_list * );
25      }
26      #endif
[596f987b]27
28      struct coStack_t {
[5c81105]29            unsigned int size;          // size of stack
30            void *storage;                      // pointer to stack
31            void *limit;                        // stack grows towards stack limit
32            void *base;                         // base of stack
33            void *context;                      // address of cfa_context_t
34            void *top;                          // address of top of storage
35            bool userStack;     
36      };
[78b3f52]37
[80d9e49]38      enum coroutine_state { Start, Inactive, Active, Halt, Primed };
[78b3f52]39
[5c81105]40      struct coroutine {
41            struct coStack_t stack;
42            const char *name;                   // textual name for coroutine/task, initialized by uC++ generated code
43            int errno_;                         // copy of global UNIX variable errno
44            enum coroutine_state state; // current execution status for coroutine
45            bool notHalted;                     // indicate if execuation state is not halted
[78b3f52]46
[5c81105]47            struct coroutine *starter;  // first coroutine to resume this one
48            struct coroutine *last;             // last coroutine to resume this one
49      };
[78b3f52]50
[bd98b58]51      struct simple_lock {
52        struct simple_thread_list blocked;
53      };
54
[8118303]55      struct thread_h {
56            struct coroutine c;
[bd98b58]57            struct simple_lock lock;
58            struct thread_h * next;
[8118303]59      };
60
[5c81105]61#endif //_INVOKE_H_
62#else //! defined(__CFA_INVOKE_PRIVATE__)
63#ifndef _INVOKE_PRIVATE_H_
64#define _INVOKE_PRIVATE_H_
65     
[596f987b]66      struct machine_context_t {
[5c81105]67            void *SP;
68            void *FP;
69            void *PC;
70      };
[78b3f52]71
[5c81105]72      // assembler routines that performs the context switch
[b58a5772]73      extern void CtxInvokeStub( void );
[eb2e723]74      void CtxSwitch( void * from, void * to ) asm ("CtxSwitch");
75      void CtxGet( void * this ) asm ("CtxGet");
[78b3f52]76
[5c81105]77#endif //_INVOKE_PRIVATE_H_
78#endif //! defined(__CFA_INVOKE_PRIVATE__)
79#ifdef __CFORALL__
80}
81#endif
Note: See TracBrowser for help on using the repository browser.