Hi All, I am on g++ 3.2.2 and red hat linux on x86..not sure which version....I have a software product that I wrote that works on win/solaris/aix and now we are trying to compile it on linux for the first time.
We are getting a message saying synch.h is not found on the linux machine. When we search the machine it is not there. I've talked to the sys admins for the machine and they tell me they are unsure which part of the gnu g++ package they should install to be able to do this sort of coding on linux. They tell me if I can find out what portion of g++ they should install they can install it for me. I am no expert on the g++ compiler or linux so I am not sure how to explain to the sysadmins what exactly they need to do to get the support I need to be able to compile on linux. On solaris/aix synch.h is required to define semaphores I believe. Any guidance would be most gratefully accepted. Best Regards Peter Nolan www.peternolan.com We have a header at the start of the program as follows: #include <synch.h> #include <sys/mman.h> I then define my semaphors as follows: /* shared variables */ sema_t *mutex; /* mutex: semaphore for mutual exclusion */ sema_t *full; /* full: semaphore for process synchronisation */ /* it denotes the number of full slots */ sema_t *empty; /* empty: semaphore for process synchronisation */ /* it denotes the number of empty slots */ I then create them like follows: if ((mutex_fp = creat("/tmp/mutex", PERMISSIONS)) == -1) { printf("Fatal error: cannot create mutex semaphore file\n"); exit(0); } else { write(mutex_fp, dummy_int, 4); close(mutex_fp); } Open them like follows: if ((mutex_fp = open("/tmp/mutex", O_RDWR, 0)) == -1) { printf("Fatal error: cannot open mutex semaphore file\n"); exit(0); } Memory map them as follows: if ((mutex = (sema_t *) mmap((caddr_t) 0, 4, (PROT_READ|PROT_WRITE), MAP_SHARED, mutex_fp, 0)) == MAP_FAILED) { mmap_error(errno); } All I can find that is similar in the linux g++ is semaphore.h that contains code like the following... On linux should I be using these calls rather than sema_init etc? __BEGIN_DECLS /* Initialize semaphore object SEM to VALUE. If PSHARED then share it with other processes. */ extern int sem_init (sem_t *__sem, int __pshared, unsigned int __value) __THROW; /* Free resources associated with semaphore object SEM. */ extern int sem_destroy (sem_t *__sem) __THROW; /* Open a named semaphore NAME with open flaot OFLAG. */ extern sem_t *sem_open (__const char *__name, int __oflag, ...) __THROW; /* Close descriptor for named semaphore SEM. */ extern int sem_close (sem_t *__sem) __THROW; /* Remove named semaphore NAME. */ extern int sem_unlink (__const char *__name) __THROW; /* Wait for SEM being posted. */ extern int sem_wait (sem_t *__sem); #ifdef __USE_XOPEN2K /* Similar to `sem_wait' but wait only until ABSTIME. */ extern int sem_timedwait (sem_t *__restrict __sem, __const struct timespec *__restrict __abstime); #endif /* Test whether SEM is posted. */ extern int sem_trywait (sem_t *__sem) __THROW; /* Post SEM. */ extern int sem_post (sem_t *__sem) __THROW; /* Get current value of SEM and store it in *SVAL. */ extern int sem_getvalue (sem_t *__restrict __sem, int *__restrict __sval) __THROW; __END_DECLS _______________________________________________ Help-gplusplus mailing list Help-gplusplus@gnu.org http://lists.gnu.org/mailman/listinfo/help-gplusplus