diff options
author | Jack Sangdahl <[email protected]> | 2024-10-03 11:45:34 -0600 |
---|---|---|
committer | Jack Sangdahl <[email protected]> | 2024-10-03 11:45:34 -0600 |
commit | 6e6f4151b7f709fbaf62e40479c700a81436512f (patch) | |
tree | d7bc4fd81a5ab9d163e6e94bb37058c6130eebd2 /pa4_shared_array/array.h | |
parent | eea3d410e709ebac4351f58487ed3c9f49631c44 (diff) | |
download | csci3753-6e6f4151b7f709fbaf62e40479c700a81436512f.tar.gz csci3753-6e6f4151b7f709fbaf62e40479c700a81436512f.zip |
pa4: improvements
Diffstat (limited to 'pa4_shared_array/array.h')
-rw-r--r-- | pa4_shared_array/array.h | 39 |
1 files changed, 5 insertions, 34 deletions
diff --git a/pa4_shared_array/array.h b/pa4_shared_array/array.h index 9d67e1e..3522530 100644 --- a/pa4_shared_array/array.h +++ b/pa4_shared_array/array.h @@ -2,47 +2,18 @@ // CSCI3753 SP24 // PA4 Shared Array #include <semaphore.h> -#include <stdint.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#define ARRAY_SIZE 8 // number of hostnames in data/ is 618 -#define MAX_NAME_LENGTH 16 // longest string length in data/ +#define ARRAY_SIZE 8 typedef struct { - char **array; - uint8_t top; + void *data[ARRAY_SIZE]; + int top; sem_t mutex; - sem_t space; - sem_t items; + sem_t avail; + sem_t empty; } array; -/** - * @brief initialise the array - * @param s - * @return int - */ int array_init(array *s); - -/** - * @brief place element into array. block when full - * @param s - * @param hostname - * @return int - */ int array_put(array *s, char *hostname); - -/** - * @brief remove element from the array. block when empty - * @param s - * @param hostname - * @return int - */ int array_get(array *s, char **hostname); - -/** - * @brief free array's resources - * @param s - */ void array_free(array *s); |