From 8605c6e820ec4aeb18db05e239fe49d141bda3ef Mon Sep 17 00:00:00 2001 From: zenon Date: Fri, 8 Jun 2018 10:21:33 +0200 Subject: [PATCH] getSolution writes head instead of where head is pointing --- supervisor.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/supervisor.c b/supervisor.c index fd9d1cb..34fb04e 100644 --- a/supervisor.c +++ b/supervisor.c @@ -91,15 +91,15 @@ void getSolution(sem_t *sUsedSpace, sem_t *sFreeSpace) solution[i] = -1; } - if (shared->head == -1) { + if (shared->data[shared->head] == -1) { wait_sem(sUsedSpace); shared->head = (shared->head + 1) % MAX_ITEMS; sem_post(sFreeSpace); } else { int i = 0; - while (shared->head != -1) { + while (shared->data[shared->head] != -1) { wait_sem(sUsedSpace); - solution[i] = shared->head; + solution[i] = shared->data[shared->head]; shared->head = (shared->head + 1) % MAX_ITEMS; sem_post(sFreeSpace); i++;