I/O: Get buffer from kernel to usermode
Posted: Mon Jun 01, 2009 2:50 pm
Hi,
how have you solved the problem where you have to copy a buffer read from disk back to the user thread which issued the call?
- user thread calls system routine "read" (i.e to read a file), goes to kernel mode and starts disk I/O.
- system call returns immediately since this is non-blocking I/O. User thread does other things...
- Disk interrupts, at this point some kernel space DMA buffers are filled with the data the user needs.
- How to get the data back to the user's address space?
The solutions I could imagine are:
- Windows style APCs (where a "completion-routine" is queued to the thread that issued the I/O. Before the thread runs, the APC routine runs first. At this point we have the user's address space).
- Temporarily map the user's address space at a suitable moment after the interrupt?
Do you know how this is handled in Linux?
Bye
Zoomby
how have you solved the problem where you have to copy a buffer read from disk back to the user thread which issued the call?
- user thread calls system routine "read" (i.e to read a file), goes to kernel mode and starts disk I/O.
- system call returns immediately since this is non-blocking I/O. User thread does other things...
- Disk interrupts, at this point some kernel space DMA buffers are filled with the data the user needs.
- How to get the data back to the user's address space?
The solutions I could imagine are:
- Windows style APCs (where a "completion-routine" is queued to the thread that issued the I/O. Before the thread runs, the APC routine runs first. At this point we have the user's address space).
- Temporarily map the user's address space at a suitable moment after the interrupt?
Do you know how this is handled in Linux?
Bye
Zoomby