Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!lll-winken!uunet!world!bzs From: bzs@world.std.com (Barry Shein) Newsgroups: comp.unix.internals Subject: Re: How do I find my buffers once I have lost them? Message-ID: Date: 8 Nov 90 02:58:42 GMT References: <18747.27394289@windy.dsir.govt.nz> Sender: bzs@world.std.com (Barry Shein) Organization: The World Lines: 56 In-Reply-To: sramtrc@windy.dsir.govt.nz's message of 8 Nov 90 11:33:27 GMT >When the kernel gets the interrupt how can it find the user buffer again >(assuming it has been locked into memory) to do the next transfer? The >buffer may no longer be mapped into the kernel's virtual address space >since at the time of the interrupt some other user process may be running. >How can the kernel even find the original user process (to, say, send a >SIGIO to it)? Does it have to search the process table looking for it? >It can't search physical RAM looking for the buffer since the buffer may >be segmented into many chunks of RAM. Well, one way to handle this is to just use a temp buffer to DMA between and use copyin() and/or copyout() to move the data, but it sounds like you're trying very hard to avoid that, ok. Depending on how much info you really have to keep around you could certainly declare a structure specific to the device with the items you want to know latter, use rmalloc() or similar to create one for each transfer and have the buffer struct point at it when you start. Being as the buf struct is handed back to you at interrupt time you could just snoop in there for the info you saved previously. So the obvious thing would be: struct mydevinfo { pid_t user_pid; caddr_t user_buffer; }; and then when you set up the transfer something like: struct mydevinfo *myp; myp = (struct mydevinfo *)rmalloc(sizeof(struct mydevinfo)); myp->user_pid = pid; myp->user_buffer = buffer; bp->b_un.b_addr = (caddr_t)myp; and in the interrupt handler: struct mydevinfo *myp; myp = (struct mydevinfo *)bp->b_un.b_addr; and so on. sort of disgusting but it would do the job. Maybe I'm missing something here... gee, an internals question...imagine...I just had to *try* to answer, but I'd suggest you wait until people pick apart my suggestion before taking the advice. -- -Barry Shein Software Tool & Die | {xylogics,uunet}!world!bzs | bzs@world.std.com Purveyors to the Trade | Voice: 617-739-0202 | Login: 617-739-WRLD