Change wrong wait_sem to post_sem to avoid deadlock

This commit is contained in:
zenon 2018-06-08 10:08:37 +02:00
parent da416ca283
commit 9cb4d66d4b

View File

@ -229,14 +229,14 @@ void putSolution(int *solution)
wait_sem(sFreeSpace); wait_sem(sFreeSpace);
shared->data[shared->tail] = -1; shared->data[shared->tail] = -1;
shared->tail = (shared->tail + 1) % CIRC_BUF_SIZE; shared->tail = (shared->tail + 1) % CIRC_BUF_SIZE;
wait_sem(sUsedSpace); sem_post(sUsedSpace);
} else { } else {
int i = 0; int i = 0;
while (solution[i] != -1) { while (solution[i] != -1) {
wait_sem(sFreeSpace); wait_sem(sFreeSpace);
shared->data[shared->tail] = solution[i]; shared->data[shared->tail] = solution[i];
shared->tail = (shared->tail + 1) % CIRC_BUF_SIZE; shared->tail = (shared->tail + 1) % CIRC_BUF_SIZE;
wait_sem(sUsedSpace); sem_post(sUsedSpace);
i++; i++;
} }
} }