:spakles:

This commit is contained in:
Nikolaj
2021-10-28 14:59:16 +02:00
parent 7118bcc0a8
commit 8691e70920
6 changed files with 7 additions and 3 deletions

BIN
A2/fauxgrep Executable file

Binary file not shown.

Binary file not shown.

View File

@ -35,7 +35,7 @@ int fauxgrep_file(char const *needle, char const *path) {
while (getline(&line, &linelen, f) != -1) {
if (strstr(line, needle) != NULL) {
printf("%s:%d: %s", path, lineno, line);
//printf("%s:%d: %s", path, lineno, line);
}
lineno++;
@ -48,7 +48,6 @@ int fauxgrep_file(char const *needle, char const *path) {
}
void* fauxgrep_thread(void* arg) {
//printf("thread initialized\n");
char* needle = arg;
char const* path;
while (job_queue_pop(&q, (void**) &path) == 0) {
@ -118,6 +117,7 @@ int main(int argc, char * const *argv) {
case FTS_D:
break;
case FTS_F:
//printf("%s\n", p->fts_accpath);
job_queue_push(&q, strdup(p->fts_path));
break;
default:
@ -125,9 +125,12 @@ int main(int argc, char * const *argv) {
}
}
//printf("done pusing jobs\n");
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);

BIN
A2/fhistogram Executable file

Binary file not shown.

View File

@ -32,6 +32,7 @@ int job_queue_destroy(struct job_queue *job_queue) {
free(job_queue->jobs);
job_queue->jobs = NULL;
//job_queue = NULL;
pthread_mutex_unlock(&queue_push);
pthread_mutex_unlock(&queue_pop);
@ -87,7 +88,7 @@ int job_queue_pop(struct job_queue *job_queue, void **data) {
}
if (job_queue->size == job_queue->capacity - 1) {
pthread_mutex_unlock(&queue_pop);
pthread_mutex_unlock(&queue_push);
}
//printf("pop end\n");

Binary file not shown.