changed the circular nature of dongle grabbing to even/odd based to eliminate chained dependency
This commit is contained in:
parent
6a3b577d79
commit
a29a321d75
4 changed files with 5 additions and 5 deletions
4
Makefile
4
Makefile
|
|
@ -7,9 +7,9 @@ OBJS = $(SRCS:.c=.o)
|
||||||
|
|
||||||
CC = cc
|
CC = cc
|
||||||
# CFLAGS = -Wall -Wextra -Werror -pthread -g -fsanitize=thread
|
# CFLAGS = -Wall -Wextra -Werror -pthread -g -fsanitize=thread
|
||||||
CFLAGS = -Wall -Wextra -Werror
|
CFLAGS = -Wall -Wextra -Werror -pthread
|
||||||
|
|
||||||
ARGS = 4 800 200 100 10 3 0 fifo
|
ARGS = 6 900 200 200 200 10 60 fifo
|
||||||
|
|
||||||
all: $(NAME)
|
all: $(NAME)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ static void compile_op(t_coder *coder, t_state *state)
|
||||||
t_dongle *first;
|
t_dongle *first;
|
||||||
t_dongle *second;
|
t_dongle *second;
|
||||||
|
|
||||||
if (coder->right_dongle->idx < coder->left_dongle->idx)
|
if (coder->idx % 2 == 0)
|
||||||
{
|
{
|
||||||
first = coder->left_dongle;
|
first = coder->left_dongle;
|
||||||
second = coder->right_dongle;
|
second = coder->right_dongle;
|
||||||
|
|
|
||||||
|
|
@ -14,10 +14,10 @@
|
||||||
|
|
||||||
static void stop_prog(t_state *state, int i)
|
static void stop_prog(t_state *state, int i)
|
||||||
{
|
{
|
||||||
|
print("%ld %d burned out\n", state, state->coders[i].idx);
|
||||||
pthread_mutex_lock(&state->over_mutex);
|
pthread_mutex_lock(&state->over_mutex);
|
||||||
state->is_over = true;
|
state->is_over = true;
|
||||||
pthread_mutex_unlock(&state->over_mutex);
|
pthread_mutex_unlock(&state->over_mutex);
|
||||||
print("%ld %d has burned out\n", state, state->coders[i].idx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_over(t_state *state)
|
bool is_over(t_state *state)
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ void print(char *str, t_state *state, int coder_idx)
|
||||||
if (!is_over)
|
if (!is_over)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&state->print_mutex);
|
pthread_mutex_lock(&state->print_mutex);
|
||||||
printf(str, now() - state->start, coder_idx);
|
printf(str, now() - state->start, coder_idx + 1);
|
||||||
pthread_mutex_unlock(&state->print_mutex);
|
pthread_mutex_unlock(&state->print_mutex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue