-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsch_thread.h
More file actions
36 lines (28 loc) · 764 Bytes
/
sch_thread.h
File metadata and controls
36 lines (28 loc) · 764 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
#ifndef SCH_THREAD_H
#define SCH_THREAD_H
#include <pthread.h>
#include <semaphore.h>
#include <stdint.h>
#include "./so_scheduler.h"
#define TH_TERM_INIT_SIZE 64
#define TH_TERM_SIZE_INC_MUL 2
struct sch_thread {
pthread_t id;
uint_fast64_t entry_time;
uint_fast8_t priority;
sem_t *sem;
so_handler *func;
};
struct th_term {
struct sch_thread **v;
size_t end;
size_t allocated;
pthread_mutex_t lock;
};
void *sch_thread_copy(const void *src);
int sch_thread_compare_smaller(void *_a, void *_b);
void sch_thread_free(void *a);
int sch_th_term_push_back(struct th_term *th_term, struct sch_thread *t);
struct sch_thread *sch_th_term_pop_back(struct th_term *th_term);
int sch_th_term_size(const struct th_term *th_term);
#endif /* SCH_THREAD_H */