zwilling@barney.cs.wisc.edu (Mike Zwilling) (01/09/90)
I'm running Mach 2.5 on a micro-vax III and am having problems writing an external pager. A couple months ago I posted a request for advice on writing external pagers, but received none. Since then I've been sidetracked, but now I'm working on it again. While trying to get my pager to work, I attempted to use the Network memory server (netmemoryserver) supplied with the 2.5 distribution. I seem to be having the same problem with it as with my pager, so below is a sample program utilizing the netmemoryserver which demonstrates the problem. Basically, I can allocate the memory, but when I first "touch" it, a bus error occurs. If I replace the vm_map call with a vm_allocate, everything works fine, so apparently when the page fault occurs, the netmemoryserver is not being "activated." Any advice would be greatly appreciated, even confirmation that the attached program is correct. If I get it running, I'll post the solution. Thanks in advance, Mike Zwilling University of Wisconsin -- Madison Computer Sciences Dept. 1210 W. Dayton St. Madison, WI 53706 email: zwilling@cs.wisc.edu ph# (608) 263-4076 /********************** cut here **********************************/ #include <mach.h> #include <servers/netname.h> #include <mach_error.h> #include <netmemory.h> #include <stdio.h> #include <strings.h> main() { port_t mem_port; memory_object_t paging_object; port_t control_port; int serv_err; kern_return_t retcode; vm_address_t address; char c; printf("Looking up port for memory server\n"); retcode = netname_look_up(name_server_port,"", "netmemoryserver", &mem_port); if (retcode != KERN_SUCCESS) { mach_error("error looking up port for memory server",retcode); printf("memory server may not be running\n"); exit(1); } printf("Allocating memory object\n"); retcode = netmemory_create(mem_port, 8192, &paging_object, &control_port); if (retcode != KERN_SUCCESS) mach_error("Error from netmemory_create is",retcode); /* * I've tried both including and excluding this call * init_netmemory(control_port); */ printf("Allocating region in the memory object\n"); retcode = vm_map(task_self_, &address, 4096, 0, TRUE, paging_object, 0, 0, VM_PROT_WRITE, VM_PROT_WRITE, VM_INHERIT_SHARE); if (retcode != KERN_SUCCESS) mach_error("Error from vm_map is",retcode); c = * ((char*)address); /* crashes on this line */ *(char*)address = 'X'; /* or this line */ *(((char*)address) + 1) = '\0'; /* or this line */ printf("Data on page 1 is: %s\n", (char*)address); } -- Mike Zwilling University of Wisconsin -- Madison Computer Sciences Dept. 1210 W. Dayton St. Madison, WI 53706 email: zwilling@cs.wisc.edu ph# (608) 263-4076
zwilling@barney.cs.wisc.edu (Mike Zwilling) (01/10/90)
In article <9510@spool.cs.wisc.edu> I wrote: >I'm running Mach 2.5 on a micro-vax III and am having problems writing >an external pager. ... >While trying to get my pager to work, I attempted to use the >Network memory server (netmemoryserver) supplied with the 2.5 >distribution. I seem to be having the same problem with it as with >my pager, so below is a sample program utilizing the netmemoryserver >which demonstrates the problem. Thanks to Rich Draves at CMU I was able to get the program to work. The fix simply involved changing the two VM_PROT_WRITE parameters in the vm_map() call to VM_PROT_ALL. I still haven't been able to get my pager to work, but at least the problem is in a different area of the program/pager now. Mike -- Mike Zwilling University of Wisconsin -- Madison Computer Sciences Dept. 1210 W. Dayton St. Madison, WI 53706 email: zwilling@cs.wisc.edu ph# (608) 263-4076