07-07-2026
89 lines
2.0 kB
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* codexion.h :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: mleitao <marvin@42.fr> +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2026/06/12 19:22:14 by mleitao #+# #+# */
9/* Updated: 2026/07/07 00:54:19 by mleitao ### ########.fr */
10/* */
11/* ************************************************************************** */
12
13#ifndef CODEXION_H
14# define CODEXION_H
15
16# include <pthread.h>
17
18enum e_arg
19{
20 ARG_CODERS,
21 ARG_BURNOUT,
22 ARG_COMPILE,
23 ARG_DEBUG,
24 ARG_REFACTOR,
25 ARG_COMPILES_REQUIRED,
26 ARG_COOLDOWN
27};
28
29enum e_schd
30{
31 SCHD_FIFO,
32 SCHD_EDF
33};
34
35typedef struct s_args
36{
37 unsigned int v[7];
38 enum e_schd scheduler;
39} t_args;
40
41typedef struct s_req
42{
43 long key;
44 unsigned int coder_id;
45} t_req;
46
47typedef struct s_heap
48{
49 t_req *arr;
50 unsigned int size;
51} t_heap;
52
53typedef struct s_sim t_sim;
54
55typedef struct s_dongle
56{
57 unsigned int id;
58 unsigned int held;
59 unsigned int ticket;
60 long release_ts;
61 t_heap queue;
62 pthread_mutex_t lock;
63 pthread_cond_t wait;
64} t_dongle;
65
66typedef struct s_coder
67{
68 unsigned int id;
69 unsigned int compiles_done;
70 long last_compile_start;
71 pthread_t thread;
72 pthread_mutex_t state_lock;
73 t_dongle *left;
74 t_dongle *right;
75 t_sim *sim;
76} t_coder;
77
78struct s_sim
79{
80 t_args args;
81 long start_ms;
82 unsigned int stop;
83 pthread_mutex_t stop_lock;
84 pthread_mutex_t log_lock;
85 t_dongle *dongles;
86 t_coder *coders;
87};
88
89#endif