Hi, everyone:

I have a question about the share memory use mmap. (in rtlinux-2.2)
I use the example in mmap, but what i want to know is is there is a 
limit of the size of share memory, for when i try to map a region
about 1000 int, in the kernel module the computer always dead.

Following is the program i use.

===================================
#include <rtl.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/mman.h>

//DATA * start;
int *start;
size_t length = 1000;
#define BASE_ADDRESS (96*0x100000) 
        //96Mb I have reserve the left 32Mb in lilo.conf

int init_module(void )
{
        int i;

        int fd = open("/dev/mem", O_RDWR);
        if (fd < 0) {
                rtl_printf("failed to open /dev/mem\n");
                return -1;
        }
        start = (int *)mmap(0,length*sizeof(int),PROT_READ|PROT_WRITE,
                        MAP_SHARED,fd,BASE_ADDRESS);
        if (start == (int *) -1) {
                rtl_printf("failed to map /dev/mem\n");
                return -1;
        }
        rtl_printf("%p\n",start);
        for (i = 0; i < 1000; i++) {
                rtl_printf ("%d\t",i);
                start[i]=i;
                rtl_printf ("%d\n", start[i]);
                }
        return 0;
}

void cleanup_module(void )
{
       munmap(start, length);
}

#ifndef MODULE 

int main(void)
{
        if (init_module() == 0) {
                cleanup_module();
        }
        return 0;
}
#endif
===========================

If i run this program in module, then the computer is dead.
If i run in user program, it's ok.

Anyone have some some suggestion about this?

Thanks in anvance.

Zhixu Liu


-- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
---
For more information on Real-Time Linux see:
http://www.rtlinux.org/rtlinux/

Reply via email to