This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "lab.h" | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| // Authored by: Myself | |
| // Thread-safe: Not Thread-safe (allocates shared structures without synchronization) | |
| list_t *list_init(void (*destroy_data)(void *), int (*compare_to)(const void *, const void *)) { | |
| list_t *list = (list_t *)malloc(sizeof(list_t)); // external function: malloc (thread-safe) | |
| if (list == NULL) { | |
| return NULL; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <pthread.h> | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <unistd.h> | |
| #define NUM_THREADS 4 | |
| pthread_mutex_t log_mutex = PTHREAD_MUTEX_INITIALIZER; // EXT(ernal function): mutex to protect output stream | |
| // Authored by: Myself |