ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am trying to program Posix file based process shared semaphores and Posix shared memory with gcc version 2.96 on my system with a Linux 2.4.7-10 kernel. I've run the posixtst program which indicates that my kernel should support Posix semaphores and shared memory. However, the man pages have no information on the file based semaphore calls, sem_open() and sem_unlink(), or shared memory calls such as shm_open() and shm_unlink(). Furthermore, when compiling with a header include statement for semaphore.h and sys/mman.h, all semaphore and shared memory calls are reported as undefined references. I have also attempted to compile with sys/ipc.h, sys/sem.h, and sys/shm.h (which are all System V) in addition to the headers named above. In addition, I have seen university text that said process shared Posix semaphores are not supported in Linux. Is this true? If not, is there an include or a library I need during compile that would add support for these calls?
i linked -lrt, but my program still aborted. use strerror(errno),i got the following info:function not implemented.
my os is slackware linux ,kernel is 2.4.18.gcc 3.2.2
i mount tmpfs,and i got the following info:
No such file or directory
my code is like this:
if ((fd = shm_open(alloc_key_ss.str().data(), O_RDWR, S_IRWXU | S_IRWXG)) == -1) {...}
and i tested alloc_key_ss.str().data(),it exist!
Originally posted by dragonman I am trying to program Posix file based process shared semaphores and Posix shared memory with gcc version 2.96 on my system with a Linux 2.4.7-10 kernel. I've run the posixtst program which indicates that my kernel should support Posix semaphores and shared memory. However, the man pages have no information on the file based semaphore calls, sem_open() and sem_unlink(), or shared memory calls such as shm_open() and shm_unlink(). Furthermore, when compiling with a header include statement for semaphore.h and sys/mman.h, all semaphore and shared memory calls are reported as undefined references. I have also attempted to compile with sys/ipc.h, sys/sem.h, and sys/shm.h (which are all System V) in addition to the headers named above. In addition, I have seen university text that said process shared Posix semaphores are not supported in Linux. Is this true? If not, is there an include or a library I need during compile that would add support for these calls?
Thanks.
Steve Davis.
Hi Steve,
Did you get any soln. to your problem(s)? I ran into similar problems when trying something similar on Suse Linux 9.0 (Kernel: 2.4.21-199). sem_open: gives "Function not implemented" ans does sem_close(). I've been trying to implement POSIX semaphores, but it is a wee bit tricky. Please do let me know if you come across any website having the source code etc. or if you've fixed your problem.
I am having the same issue and wonder if any one has the answer to this question. I would appricate if you would post it. I read mixed reports saying that support for shared-memory and semaphores are not fully supported in Linux and some reports saying that the standards are out there now for Linux. I was going to use System V because of its wide implementation, but read that that standards body has evaporated or merged and POSIX is the way to go. Any clarification or source reference would be appreciated.
I posted a reply from gotom for a similar issue hoping that it may help some of you...
Because you don't mount tmpfs on /dev/shm. Please use the newer glibc
(>= 2.3.2.ds1-11) or install the latest "initscripts". I guess you
may disable tmpfs on /dev/shm.
I have just run into this same problem and I did not see that any of the posts answered the question. I have written software to use POSIX named semaphores, which can be used between different processes on the same host. I wrote the software to be used on several different platforms and have successfully used it on other UNIX platforms. It won't build under Linux because it appears to only support POSIX thread semaphores; you can't do a sem_open, sem_unlink. Is this capability scheduled to be included in Linux? We use kernel version 2.4 in Redhat enterprise workstation 3.
You can build on linux 2.4, but you have to run on linux 2.6 (for example, SUSE 9). Linux 2.4 does not have the full support. If you have trouble building, include -lrt to the linker. I hope this helps.
I am also using POSIX with Linux, and realized that you must be very careful while doing that. For example, sem_open returns to 0 instead of -1 on error!! I'd recommend you to use the standard names; such as "SEM_FAILED" instead of "-1".
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.