Click to See Complete Forum and Search --> : shm_open problem


chrisliu
09-06-2005, 03:15 PM
Hi all,

I wrote to simple program to set up a shared memory in Mandrake Linux 10.0. Below is my simple program:

#define SHM_AREA_NAME "/shmarea"
#define MYSHMSIZE 1048576
#define SHM_NAME "/dblinks.shm"

main( )
{
int shm_descr;
int status;

/* Create a shared memory area */
shm_descr = shm_open( SHM_AREA_NAME, O_CREAT|O_RDWR, S_IRWXU);
perror( NULL );

}

I was able to compile and link the program without any problem. However, I got the following message at run-time as a return value from shm_open.

"Function not implemented"

Any help is appreciated

--Christopher

bwkaz
09-06-2005, 07:18 PM
"function not implemented" is the string that you get when you run perror(whatever) when ENOSYS is the value in errno.

shm_open calls into glibc, at sysdeps/unix/sysv/linux/shm_open.c (at least in glibc 2.3.4). The contents of this file tell me that shm_open will set errno to ENOSYS when the function that's supposed to search for the mount point fails.

To use SysV shared memory, you need a tmpfs mounted somewhere. The documentation points people to /dev/shm, so that's presumably where it should be mounted. You need a line like this in your /etc/fstab:

<string> /dev/shm tmpfs defaults 0 0

(where <string> can be any string, as long as it doesn't have spaces in it), and then you have to mount /dev/shm by either becoming root and doing it, or rebooting.

chrisliu
09-07-2005, 02:06 PM
bwkaz,

Thanks.. Shared Memory is up and running.