Created
August 16, 2018 06:51
-
-
Save liuliu/dda279757bbccaf00c996deae00fecc7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
union ptr_splitter { | |
void *ptr; | |
uint32_t part[2]; | |
}; | |
static const int default_stack_size = 65536; | |
typedef struct schd_s schd_t; | |
typedef struct task_s task_t; | |
typedef void (*task_fn_t)(task_t *task); | |
struct task_s { | |
struct task_s* prev; | |
struct task_s* next; | |
schd_t* schd; | |
int done; | |
struct task_s* waitfor; | |
// For swapcontext / makecontext / getcontext. | |
ucontext_t context; | |
char *stack; | |
task_fn_t fn; | |
}; | |
struct schd_s { | |
task_t* head; | |
task_t* tail; | |
struct { | |
int suspend; | |
} count; | |
pthread_cond_t cv; | |
pthread_mutex_t mutex; | |
ucontext_t caller, callee; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment