This commit is contained in:
Nikolaj
2021-11-21 12:35:45 +01:00
parent db4ae92595
commit a833af7f36
5 changed files with 12 additions and 5 deletions

Binary file not shown.

View File

@@ -14,7 +14,7 @@
#include "job_queue.h"
pthread_mutex_t stdout_mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
// err.h contains various nonstandard BSD extensions, but they are
// very handy.
@@ -26,7 +26,12 @@ int global_histogram[8] = { 0 };
struct job_queue q;
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");

Binary file not shown.