diff --git a/src/.gdb_history b/src/.gdb_history index 042f8b2b403e0455a649fe06c0ad168b7fad5093..d4270d5635fccef8e512927df91b85232d4dcec0 100644 --- a/src/.gdb_history +++ b/src/.gdb_history @@ -74,3 +74,20 @@ b thread_loop_function r ../tests/in/test1.in n q +b os_threadpool.c:102 +r ../tests/in/test1.in +ni +q +b os_threadpool.c:64 +r ../tests/in/test1.in +ni +q +b os_threadpool.c:120 +r ../tests/in/test1.in +ni +info threads +ni +info threads +thread 2 +ni +q diff --git a/src/os_threadpool.c b/src/os_threadpool.c index 8756cbfa223fdf4bf5bb23659488f13369ffb9fb..aad0bb09c151c1310069edd8957270ac8586eccf 100644 --- a/src/os_threadpool.c +++ b/src/os_threadpool.c @@ -39,10 +39,10 @@ void enqueue_task(os_threadpool_t *tp, os_task_t *t) assert(t != NULL); /* TODO: Enqueue task to the shared task queue. Use synchronization. */ - pthread_mutex_lock(&tp->mutexCoada); + //pthread_mutex_lock(&tp->mutexCoada); list_add_tail(&tp->head, &t->list); pthread_cond_broadcast(&tp->Wait); - pthread_mutex_unlock(&tp->mutexCoada); + //pthread_mutex_unlock(&tp->mutexCoada); } /* diff --git a/src/os_threadpool.h b/src/os_threadpool.h index f31d59a159298d4b9ef58c7257e9f7055735bc35..da8277f717da8e9fe9e53ca58183d07836043a34 100644 --- a/src/os_threadpool.h +++ b/src/os_threadpool.h @@ -31,9 +31,7 @@ typedef struct os_threadpool { pthread_cond_t WakeUp; int stop; unsigned int threadsOut; - int (*verifProcessing)(void); - /* TODO: Define threapool / queue synchronization data. */ } os_threadpool_t; diff --git a/src/parallel b/src/parallel index cc2d045898678a0e598d65676a1e5ccc4ee525ff..88cb07462b5b54ce0a6b4723fdd3bed9dcfbb750 100755 Binary files a/src/parallel and b/src/parallel differ diff --git a/src/parallel.c b/src/parallel.c index 05417db891702127706518ca4838b00b7167f9ab..78900ddc60b1edd49da296d327d8dd68da64104a 100644 --- a/src/parallel.c +++ b/src/parallel.c @@ -37,11 +37,11 @@ static void action(void *arg) static void process_node(unsigned int idx) { /* TODO: Implement thread-pool based processing of graph. */ - pthread_mutex_lock(&tp->mutexSuma); + pthread_mutex_lock(&tp->mutexCoada); sum += graph->nodes[idx]->info; - pthread_mutex_unlock(&tp->mutexSuma); graph->visited[idx] = DONE; for (unsigned int i = 0; i < graph->nodes[idx]->num_neighbours; ++i) { + if (graph->visited[graph->nodes[idx]->neighbours[i]] == NOT_VISITED) { graph->visited[graph->nodes[idx]->neighbours[i]] = PROCESSING; os_arg_t *arg = malloc(sizeof(*arg)); @@ -53,9 +53,10 @@ static void process_node(unsigned int idx) enqueue_task(tp, t); } } + pthread_mutex_unlock(&tp->mutexCoada); } -int verifProcessing() +int verifProcessing(void) { for (unsigned int i = 0; i < graph->num_nodes; ++i) { if (graph->visited[i] == PROCESSING) diff --git a/src/serial b/src/serial index 317ab1a62ae71ba361c52a77619005524db3dcbe..e0865c76c5a667357f2a9b9c688ae2c5db9057e5 100755 Binary files a/src/serial and b/src/serial differ