I'm recently learning the part of I/O buffering of operating system and according to the book I use,

When a user process issues an I/O request, the OS assigns a buffer in the system portion of main memory to the operation.

I understand how this method is able to avoid the swapping problem in non-buffering situation. But is it assumed that the OS buffering created for the process will never be swapped out?

To extend my question, I was wondering if there is any mechanism where the kernel portion of an OS in memory may also be swapped?


Indeed, it wouldn't make sense to swap out an I/O buffer. The point of that buffer is that it's in RAM. The code to perform the I/O and the code to manage swap must not be swapped out either.

Other kernel code can be swapped out, in principle. However this can be problematic for several reasons. Hardware drivers that aren't involved in swap could be swapped out, but this means the kernel had to be very careful about the whole data party to swap (which may involve a disk over some external communication bus or even the network, as well as filesystem code when swapping to a file). Furthermore a lot of driver vice is very performance-sensitive: the kernel had to read it send data when the hardware is ready and may not be able to afford the time to bring vice and data back out of swap. In addition, RAM is usually assumed to be reliable (it's acceptable for the system to crash if the RAM fails), but swap (on disks or over the network) isn't, and it's difficult to design a kernel that can recover if part of it becomes unavailable. Most kernels take the simple approach and never swap out kernel code and data.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.