-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththread_error.h
More file actions
48 lines (25 loc) · 821 Bytes
/
thread_error.h
File metadata and controls
48 lines (25 loc) · 821 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <setjmp.h>
#include <pthread.h>
#include <stdlib.h>
#include <unistd.h>
#define MAX_N_TASKS_IN_QUEUE 10
typedef struct {
void (*function)(void*);
void* argument;
}thread_task;
struct god_thread {
void (*createThreads)(int n_threads);
void (*addTask)(thread_task task);
void (*destroyThreads)();
};
extern const struct god_thread ThreadGod;
//To implement: Inside the main function
struct god_error {
void (*criticalErrorExit)(int error_code);
int (*anchorCriticalErrorExitPoint)();
};
thread_task __thread_task_queue[MAX_N_TASKS_IN_QUEUE];
//Add inside main function
#define ANCHOR_ERROR_EXIT if(int __anchor_error_code = setjmp(__anchor_jump_buffer)) return __anchor_error_code;
void critical_error_exit(int error_code);
volatile jmp_buf __anchor_jump_buffer;