| summaryrefslogtreecommitdiff |
diff options
Diffstat (limited to 'src/knowledge/knowledge.c')
| -rw-r--r-- | src/knowledge/knowledge.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/src/knowledge/knowledge.c b/src/knowledge/knowledge.c index 463d40b..c9bfc2a 100644 --- a/src/knowledge/knowledge.c +++ b/src/knowledge/knowledge.c @@ -1,5 +1,6 @@ #include <stdlib.h> #include <string.h> +#include <stdio.h> #include <stdint.h> /* defines SIZE_MAX */ #include "../pipe/pipe.h" @@ -9,8 +10,10 @@ /** Basic functions of the ZoO_knowledge structure ****************************/ /* See: "knowledge.h" */ -void ZoO_knowledge_initialize (struct ZoO_knowledge k [const static 1]) +int ZoO_knowledge_initialize (struct ZoO_knowledge k [const restrict static 1]) { + int error; + k->words = (struct ZoO_knowledge_word *) NULL; k->words_length = 0; k->words_sorted = (ZoO_index *) NULL; @@ -18,6 +21,22 @@ void ZoO_knowledge_initialize (struct ZoO_knowledge k [const static 1]) k->sequences = (ZoO_index **) NULL; k->sequences_length = 0; k->sequences_sorted = (ZoO_index *) NULL; + + error = pthread_mutex_init(&(k->mutex), (const pthread_mutexattr_t *) NULL); + + if (error != 0) + { + fprintf + ( + stderr, + "[F] Unable to initialize knowledge mutex: %s.\n", + strerror(error) + ); + + return -1; + } + + return 0; } int ZoO_knowledge_lock_access @@ -26,8 +45,7 @@ int ZoO_knowledge_lock_access const struct ZoO_pipe io [const restrict static 1] ) { - /* TODO */ - return 0; + return pthread_mutex_lock(&(k->mutex)); } void ZoO_knowledge_unlock_access @@ -36,5 +54,5 @@ void ZoO_knowledge_unlock_access const struct ZoO_pipe io [const restrict static 1] ) { - /* TODO */ + pthread_mutex_unlock(&(k->mutex)); } |


