This commit is contained in:
NikolajDanger
2021-11-02 11:49:41 +01:00
parent 9edf8edc55
commit aad5b42090
6 changed files with 6 additions and 23 deletions

View File

@@ -26,15 +26,7 @@ int global_histogram[8] = { 0 };
struct job_queue q;
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
void update_histogram_mt(int local_histogram[8]) {
pthread_mutex_lock(&mutex);
merge_histogram(local_histogram, global_histogram);
print_histogram(global_histogram);
pthread_mutex_unlock(&mutex);
}
int fhistogram_mt(char const *path) {
FILE *f = fopen(path, "r");
@@ -105,7 +97,6 @@ int main(int argc, char * const *argv) {
pthread_t threads[num_threads];
for (int i = 0 ; i < num_threads ; i++) {
//printf("Initializing thread %i\n", i);
pthread_create(&threads[i], NULL, fhistogram_thread, NULL);
}
@@ -138,7 +129,6 @@ int main(int argc, char * const *argv) {
fts_close(ftsp);
job_queue_destroy(&q);
//printf("done destroying jobqueue\n");
for (int i = 0 ; i < num_threads ; i++) {
pthread_join(threads[i], NULL);