Skip to content
Snippets Groups Projects
Commit 3d7e930c authored by Alexandru BRĂSLAŞU's avatar Alexandru BRĂSLAŞU
Browse files

Tema3SO

parent efa063c2
No related branches found
No related tags found
No related merge requests found
Pipeline #44258 passed
......@@ -90,13 +90,14 @@ static void *thread_loop_function(void *arg)
while (1) {
t = dequeue_task(tp);
if (tp->stop)
pthread_mutex_lock(&tp->mutexCoada);
int ok = tp->stop;
pthread_mutex_unlock(&tp->mutexCoada);
if (ok)
break;
if (t != NULL) {
t->action(t->argument);
pthread_mutex_lock(&tp->mutexCoada);
destroy_task(t);
pthread_mutex_unlock(&tp->mutexCoada);
}
}
pthread_mutex_lock(&tp->mutexCoada);
......
......@@ -44,15 +44,11 @@ static void process_node(unsigned int idx)
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;
pthread_mutex_lock(&tp->mutexCoada);
os_arg_t *arg = malloc(sizeof(*arg));
pthread_mutex_unlock(&tp->mutexCoada);
arg->x = graph->nodes[idx]->neighbours[i];
arg->auxFunc = process_node;
pthread_mutex_lock(&tp->mutexCoada);
os_task_t *t = create_task(&action, (void *)arg, &destroy_arg);
pthread_mutex_unlock(&tp->mutexCoada);
enqueue_task(tp, t);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment