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 8118303 was
8118303,
checked in by Thierry Delisle <tdelisle@…>, 8 years ago
|
First prototype of cfa threads running (1 thread on 1 processor)
|
-
Property mode set to
100644
|
File size:
1.7 KB
|
Line | |
---|
1 | #include <stdbool.h> |
---|
2 | #include <stdint.h> |
---|
3 | |
---|
4 | #ifdef __CFORALL__ |
---|
5 | extern "C" { |
---|
6 | #endif |
---|
7 | |
---|
8 | #if ! defined(__CFA_INVOKE_PRIVATE__) |
---|
9 | #ifndef _INVOKE_H_ |
---|
10 | #define _INVOKE_H_ |
---|
11 | |
---|
12 | #define unlikely(x) __builtin_expect(!!(x), 0) |
---|
13 | |
---|
14 | struct coStack_t { |
---|
15 | unsigned int size; // size of stack |
---|
16 | void *storage; // pointer to stack |
---|
17 | void *limit; // stack grows towards stack limit |
---|
18 | void *base; // base of stack |
---|
19 | void *context; // address of cfa_context_t |
---|
20 | void *top; // address of top of storage |
---|
21 | bool userStack; |
---|
22 | }; |
---|
23 | |
---|
24 | enum coroutine_state { Start, Inactive, Active, Halt, Primed }; |
---|
25 | |
---|
26 | struct coroutine { |
---|
27 | struct coStack_t stack; |
---|
28 | const char *name; // textual name for coroutine/task, initialized by uC++ generated code |
---|
29 | int errno_; // copy of global UNIX variable errno |
---|
30 | enum coroutine_state state; // current execution status for coroutine |
---|
31 | bool notHalted; // indicate if execuation state is not halted |
---|
32 | |
---|
33 | struct coroutine *starter; // first coroutine to resume this one |
---|
34 | struct coroutine *last; // last coroutine to resume this one |
---|
35 | }; |
---|
36 | |
---|
37 | struct thread_h { |
---|
38 | struct coroutine c; |
---|
39 | }; |
---|
40 | |
---|
41 | #endif //_INVOKE_H_ |
---|
42 | #else //! defined(__CFA_INVOKE_PRIVATE__) |
---|
43 | #ifndef _INVOKE_PRIVATE_H_ |
---|
44 | #define _INVOKE_PRIVATE_H_ |
---|
45 | |
---|
46 | struct machine_context_t { |
---|
47 | void *SP; |
---|
48 | void *FP; |
---|
49 | void *PC; |
---|
50 | }; |
---|
51 | |
---|
52 | // assembler routines that performs the context switch |
---|
53 | extern void CtxInvokeStub( void ); |
---|
54 | void CtxSwitch( void *from, void *to ) asm ("CtxSwitch"); |
---|
55 | |
---|
56 | #endif //_INVOKE_PRIVATE_H_ |
---|
57 | #endif //! defined(__CFA_INVOKE_PRIVATE__) |
---|
58 | #ifdef __CFORALL__ |
---|
59 | } |
---|
60 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.