From 70167a5345d5cf6a6890f83886684e1472942cb0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Crist=C3=B3v=C3=A3o=20Cruz?= Date: Fri, 2 Apr 2010 00:13:53 +0100 Subject: [PATCH] Inserted multithread capability with mutexes. --- funnysort.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/funnysort.c b/funnysort.c index 803c591..84e2359 100644 --- a/funnysort.c +++ b/funnysort.c @@ -171,7 +171,6 @@ void pick_item (unsigned int line, unsigned int column, board_t *board, item_t * if((newitem != EMPTY) && (newitem != SORTER)) { *item = newitem; poke_item(newline, newcolumn, board, EMPTY); - pthread_mutex_unlock(board->lock[newline]+newcolumn); /* we have the item */ } pthread_mutex_unlock(board->lock[newline]+newcolumn); @@ -207,17 +206,16 @@ void drop_item (unsigned int line, unsigned int column, board_t *board, item_t * newline = (line+h+HEIGHT)%HEIGHT; newcolumn = (column+v+WIDTH)%WIDTH; - //pthread_mutex_lock(&(tabuleiro.mutex[xnovo][ynovo])); + pthread_mutex_lock(board->lock[newline]+newcolumn); peek_item(newline, newcolumn, board, &newitem); if(newitem == *item) { poke_item(line, column, board, newitem); *item = EMPTY; /* and the item is down */ } - //pthread_mutex_unlock(&(tabuleiro.mutex[xnovo][ynovo])); + pthread_mutex_unlock(board->lock[newline]+newcolumn); } } - //pthread_mutex_unlock(&(tabuleiro.mutex[line][column])); } /* Print the base of the board, without any items. */ -- 2.11.4.GIT