Forum Discussion
Altera_Forum
Honored Contributor
21 years agoSemaphore support
Hi, I'm currently trying to initialize a semaphore by making a call to sem_init(), but instead of returning a non-zero value and printing a error condition, Nios II reboots. struct sem_...
Altera_Forum
Honored Contributor
21 years agoHi bjskill,
The sem_init() routine initializes the semaphore object that the first argument points to. So you're passing in an un-initialized pointer ... and something ends up getting trashed. Try: /*struct sem_t *msem */ struct sem_t msem /*if (sem_init(msem, 0, 0) != 0)*/ if (sem_init (&msem, 0, 0) != 0) printf("Semaphore not initialized\n"); Regards, --Scott