[Date Prev][Date Next] [Chronological] [Thread] [Top]

[rtl] Shared memory, again...



		Hi All!

	I'm using a RH 5.2 (2.0.36),RTL 1.1 on a P133 64MB Ram
(Dell OptiPlex GXi) machine. I tried the following code , but it's not
working:

#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
#include <sys/mman.h>
#define BASE_ADDRESS (63 * 0x100000)
int fd;
int main()
{
	char * data;
	if (fd = open("/dev/mem",O_RDWR) <0)
	{
		printf("\nMem open: ERROR");
		exit(0);
	}
	printf("\n Mem open: OK");
	data = (char*) mmap(0,sizeof(char),PROT_READ | PROT_WRITE , 
				MAP_FILE | MAP_SHARED, fd, BASE_ADDRESS );
	if (MAP_FAILED == data)
	{
		printf("Mapping shared memory: ERROR");
		exit(0);
	}
	/*... some operation with data... */
	close(fd);
	munmap((void *)data,sizeof(char);
}
I tried this following the documentation of Frederick M. Proctor.
The shared mem is initialized to 1M in the lilo.conf (append="mem=63m")).
mmap always returns MAP_FAILED.

Could somebody tell me what could be wrong woth it?

Thanx.  		Christian Fischer, Hungary



--- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail majordomo@rtlinux.cs.nmt.edu OR
echo "unsubscribe rtl <Your_email>" | mail majordomo@rtlinux.cs.nmt.edu
----
For more information on Real-Time Linux see:
http://www.rtlinux.org/~rtlinux/