From 10ec964fec1226d26b1fbd8d3ab79da6b581193f Mon Sep 17 00:00:00 2001 From: zenon Date: Thu, 7 Jun 2018 10:40:55 +0200 Subject: [PATCH] Read and write solution characterwise --- generator.c | 14 +++----------- supervisor.c | 2 +- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/generator.c b/generator.c index b1ff7bd..8773c68 100644 --- a/generator.c +++ b/generator.c @@ -170,21 +170,13 @@ void printGraph() } } -void putSolution(sem_t sUsedSpace, sem_t sFreeSpace, sem_t sWriteEnd, int *solution) +void putItem(sem_t sUsedSpace, sem_t sFreeSpace, sem_t sWriteEnd, int value) { sem_wait(&sWriteEnd); sem_wait(&sFreeSpace); - if (solution[0] == -1) { - shared->data[shared->tail] = -1; - shared->tail = (shared->tail + 1) % MAX_ITEMS; - } - - int i = 0; - while (solution[i] != -1) { - shared->data[shared->tail] = solution[i]; - shared->tail = (shared->tail + 1) % MAX_ITEMS; - } + shared->data[shared->tail] = -1; + shared->tail = (shared->tail + 1) % MAX_ITEMS; sem_post(&sUsedSpace); sem_post(&sWriteEnd); diff --git a/supervisor.c b/supervisor.c index 5317b03..db7b91c 100644 --- a/supervisor.c +++ b/supervisor.c @@ -36,7 +36,7 @@ void initCircBuf() return; } -int getSolution(sem_t sUsedSpace, sem_t sFreeSpace, int *solution) +int getItem(sem_t sUsedSpace, sem_t sFreeSpace) { sem_wait(&sUsedSpace);