Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!uwvax!barney.cs.wisc.edu!zwilling From: zwilling@barney.cs.wisc.edu (Mike Zwilling) Newsgroups: comp.os.mach Subject: Problem using external pagers Message-ID: <9510@spool.cs.wisc.edu> Date: 8 Jan 90 22:35:15 GMT Sender: news@spool.cs.wisc.edu Organization: U of Wisconsin CS Dept Lines: 85 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 #include #include #include #include #include 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