home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.unix.programmer:6067 comp.unix.ultrix:9541
- Newsgroups: comp.unix.programmer,comp.unix.ultrix
- Path: sparky!uunet!munnari.oz.au!metro!usage!spectrum!roy
- From: roy@spectrum.cs.unsw.oz.au (Prabal Kumar Roy)
- Subject: =========Problem using mmap on DECstations========
- Message-ID: <1993Jan28.002610.16041@usage.csd.unsw.OZ.AU>
- Sender: news@usage.csd.unsw.OZ.AU
- Nntp-Posting-Host: prussian.spectrum.cs.unsw.oz.au
- Reply-To: roy@spectrum.cs.unsw.oz.au (Prabal Kumar Roy)
- Organization: none
- Date: Thu, 28 Jan 1993 00:26:10 GMT
- Lines: 51
-
- Greetings:
-
- I am trying to use the mmap command on DECStation 5000. In the following test
- program I am trying to reserve 1000 bytes of memory and trying to write some stuff
- in that area.
-
- However, at the statement *intptr = 1; I am getting the following error.
- pid 10810 (a.out) was killed on kernel access, at pc 0x400284. Bus error (core
- dumped).
-
- So the statement result = (caddr_t) mmap(0,..............) has got me some
- memory which is in the kernel area, so when I am trying to access it later I am
- getting a core dump. Any help will be greatly appreciated.
-
- Prabal K. Roy
- AI Lab
- U. of New South Wales
- Sydney 2033
- AUSTRALIA
- ----------
-
- #include <sys/types.h>
- #include <stdio.h>
- #include <sys/stat.h>
- #include <sys/mman.h>
- #include <fcntl.h>
- #include <string.h>
- #include <limits.h>
- #define PERMS 0666
- #define TRUE 1
- #define FALSE 0
-
- main ()
- {
- int fd;
- caddr_t result;
- int *intptr;
- char *charptr;
-
- fd = creat("myfile", PERMS);
-
- result = (caddr_t) mmap(0, 1000, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
- close(fd);
-
- intptr = (int *) result;
- *intptr = 1;
- result = result + sizeof(int);
- charptr = (char *) result;
- strcpy(charptr, "hello world");
-
- }
-