Try setting global semaphores as non-static

This commit is contained in:
zenon 2018-06-08 12:28:57 +02:00
parent ac4559ab26
commit 255708ebc0
2 changed files with 15 additions and 13 deletions

View File

@ -13,13 +13,13 @@ static const char *pname;
static struct circ_buf *shared;
static int shmfd;
int shmfd;
static sem_t *sUsedSpace;
sem_t *sUsedSpace;
static sem_t *sFreeSpace;
sem_t *sFreeSpace;
static sem_t *sWriteEnd;
sem_t *sWriteEnd;
struct sigaction sa;
@ -223,6 +223,9 @@ void wait_sem(sem_t *sem)
void putSolution(int *solution)
{
if (shared->quit == 1)
return;
wait_sem(sWriteEnd);
for (int i = 0; i < MAX_ITEMS; i++) {

View File

@ -12,13 +12,13 @@ static const char *pname;
struct circ_buf *shared;
static int shmfd;
int shmfd;
static sem_t *sUsedSpace;
sem_t *sUsedSpace;
static sem_t *sFreeSpace;
sem_t *sFreeSpace;
static sem_t *sWriteEnd;
sem_t *sWriteEnd;
struct sigaction sa;
@ -121,12 +121,11 @@ void getSolution(sem_t *sUsedSpace, sem_t *sFreeSpace)
// Compute length of newSolution
if (solution[0] != -1) {
for (int i = 0; i < MAX_ITEMS; i++) {
if (solution[i] == -1) {
newSolutionLength = i;
break;
}
int i = 0;
while ((solution[i] != -1) && (i != (MAX_ITEMS - 1))) {
i++;
}
newSolutionLength = i;
}
if (newSolutionLength == 0) {