• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
shared memory + mmap problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

shared memory + mmap problem


  • Subject: shared memory + mmap problem
  • From: Michael Heins <email@hidden>
  • Date: Fri, 21 Jan 2005 14:57:14 -0700


I'm having trouble on my 10.3.7 system mapping more than 1 page of memory. Below is my little command line test program that illustrates the problem. I run it like this: prog abc 4096, where "abc" is the shared memory segment name, and 4096 is the segment size in bytes.


On my system, the mmap succeeds for sizes between 1-4096 and fails for sizes above 4096. Is this a known bug in Darwin? Am I overlooking a problem in my code?

Thanks.


#include <sys/types.h> #include <sys/mman.h> #include <fcntl.h> #include <stdio.h> #include <sys/stat.h>

//
// Run with two arguments, the name of the shared memory segment, and the size.
//
int
main( int argc, char **argv)
{
char *id = argv[1], *buf;
int fd, size = atoi( argv[2]);


	if ((fd = shm_open( id, O_RDWR | O_CREAT, 0666)) == -1) {
		perror( "shm_open");
		return -1;
	}

	ftruncate( fd, size);  // ignore return status

	buf = mmap( 0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
	if ((int)buf == -1) {
		perror( "mmap");
	} else {
		printf( "mmap returned %x\n", buf);
		munmap( buf, size);
	}
	shm_unlink( id);
	return 0;
}


Michael Heins AA7XY

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • shared memory + mmap problem
      • From: Michael Heins <email@hidden>
  • Prev by Date: Re: Compiling mount_smbfs
  • Next by Date: shared memory + mmap problem
  • Previous by thread: Re: Compiling mount_smbfs
  • Next by thread: shared memory + mmap problem
  • Index(es):
    • Date
    • Thread