75 lines
1.2 KiB
C
75 lines
1.2 KiB
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <pthread.h>
|
|
|
|
#include "routing4SITA.h"
|
|
|
|
|
|
void *Search(void* arguments);
|
|
|
|
int main() {
|
|
printf("hello world!\n");
|
|
|
|
pthread_t startThread;
|
|
THREAD_DATA_t* data;
|
|
data = (THREAD_DATA_t*) malloc(sizeof(THREAD_DATA_t));
|
|
data->node = getStartNode();
|
|
data->cost = 0;
|
|
|
|
pthread_create(&startThread, NULL, Search, data);
|
|
|
|
for(;;) {
|
|
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
|
|
void *Search(void* arguments) {
|
|
|
|
THREAD_DATA_t *data = (THREAD_DATA_t*) arguments;
|
|
|
|
printf("Number: %i\n", data->node->id);
|
|
printf("Cost to this node: %i\n", data->cost);
|
|
|
|
if(data->node->id == 8) {
|
|
printf("End found! Cost: %i\n", data->cost);
|
|
return NULL;
|
|
}
|
|
|
|
if(data->node->nodescount == 0) {
|
|
printf("No next nodes\n");
|
|
return NULL;
|
|
}
|
|
|
|
pthread_t threads[data->node->nodescount];
|
|
|
|
for(int i = 0; i < data->node->nodescount; i++) {
|
|
THREAD_DATA_t* nextdata;
|
|
nextdata = (THREAD_DATA_t*) malloc(sizeof(THREAD_DATA_t));
|
|
nextdata->node = (data->node->nodesnext[i]);
|
|
nextdata->cost = data->node->nodescost[i] + data->cost;
|
|
pthread_create(&threads[i], NULL, Search, nextdata);
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|