restructured the program; doesn't handle deadlocks yet
This commit is contained in:
parent
ebe57f783d
commit
13019ac0bc
4 changed files with 145 additions and 59 deletions
|
|
@ -24,17 +24,37 @@ typedef struct s_args
|
|||
int time_to_refactor;
|
||||
int number_of_compiles_required;
|
||||
int dongle_cooldown;
|
||||
int scheduler;
|
||||
char *scheduler;
|
||||
} t_args;
|
||||
|
||||
typedef struct s_data
|
||||
typedef struct s_dongle
|
||||
{
|
||||
pthread_mutex_t lock;
|
||||
long last_used;
|
||||
} t_dongle;
|
||||
|
||||
typedef struct s_coder
|
||||
{
|
||||
struct timeval start;
|
||||
int coder_id;
|
||||
pthread_t thread;
|
||||
t_dongle *right_dongle;
|
||||
t_dongle *left_dongle;
|
||||
long last_compile;
|
||||
int compiles_done;
|
||||
void *state;
|
||||
} t_coder;
|
||||
|
||||
typedef struct s_state
|
||||
{
|
||||
t_args args;
|
||||
pthread_mutex_t *left_dongle;
|
||||
pthread_mutex_t *right_dongle;
|
||||
} t_data;
|
||||
t_coder *coders;
|
||||
t_dongle *dongles;
|
||||
long start;
|
||||
int is_over;
|
||||
pthread_mutex_t over_mutex;
|
||||
pthread_mutex_t print_mutex;
|
||||
pthread_t monitor;
|
||||
} t_state;
|
||||
|
||||
t_args *parse_arguments(int count, char **args);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue