deadlock broken by taking the lower index dongle first; no monitor and scheduling yet
This commit is contained in:
parent
13019ac0bc
commit
7748a53eb2
2 changed files with 58 additions and 39 deletions
|
|
@ -15,47 +15,53 @@
|
|||
# include <pthread.h>
|
||||
# include <sys/time.h>
|
||||
|
||||
typedef struct s_state t_state;
|
||||
typedef struct s_args t_args;
|
||||
typedef struct s_dongle t_dongle;
|
||||
typedef struct s_coder t_coder;
|
||||
|
||||
typedef struct s_args
|
||||
{
|
||||
int number_of_coders;
|
||||
int time_to_burnout;
|
||||
int time_to_compile;
|
||||
int time_to_debug;
|
||||
int time_to_refactor;
|
||||
int number_of_compiles_required;
|
||||
int dongle_cooldown;
|
||||
char *scheduler;
|
||||
} t_args;
|
||||
int number_of_coders;
|
||||
int time_to_burnout;
|
||||
int time_to_compile;
|
||||
int time_to_debug;
|
||||
int time_to_refactor;
|
||||
int number_of_compiles_required;
|
||||
int dongle_cooldown;
|
||||
char *scheduler;
|
||||
} t_args;
|
||||
|
||||
typedef struct s_dongle
|
||||
{
|
||||
pthread_mutex_t lock;
|
||||
long last_used;
|
||||
} t_dongle;
|
||||
int index;
|
||||
pthread_mutex_t lock;
|
||||
long last_used;
|
||||
} t_dongle;
|
||||
|
||||
typedef struct s_coder
|
||||
{
|
||||
int coder_id;
|
||||
pthread_t thread;
|
||||
t_dongle *right_dongle;
|
||||
t_dongle *left_dongle;
|
||||
long last_compile;
|
||||
int compiles_done;
|
||||
void *state;
|
||||
} t_coder;
|
||||
int coder_id;
|
||||
pthread_t thread;
|
||||
t_dongle *right_dongle;
|
||||
t_dongle *left_dongle;
|
||||
long last_compile;
|
||||
int compiles_done;
|
||||
t_state *state;
|
||||
} t_coder;
|
||||
|
||||
typedef struct s_state
|
||||
{
|
||||
t_args args;
|
||||
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 args;
|
||||
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);
|
||||
t_args *parse_arguments(int count, char **args);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue