Welcome! Log In Create A New Profile

Advanced

How to get the kernel to swap out a process?

Posted by James N 
Good Afternoon All,

I am trying to implement some memory control in a master/slave program I'm writing, and have been fighting with the kernel memory management. I am hoping you all can help me.

Say we have three slaves process, and the master hands each of them a job to run. Also assume that the master underestimates the amount of memory those jobs will require, and the processes begin to swap.

The master process monitors the memory of its slaves, and it notices the swapping. In order to control the swapping, the master sends one of the slaves a message that says "I'm putting you to sleep," at which point the slave blocks on a socket waiting to for the "wake back up now" message.

What I expect and would like to happen at this point is that the kernel swaps out the sleeping process, and uses that memory to run the other two processes. In practice what happens is that the kernel is very reluctant to take pages away from the sleeping process. It will eventually do it if the other two processes swap hard enough, but it seems to prefer to let the other two processes swap while allowing the sleeping process to keep the pages it already has. You can see this in top, the process goes to sleep, but it's RSS does not decrease.

Is there a way a process can ask to be swapped out?
Author:

Your Email:


Subject:


Spam prevention:
Please, solve the mathematical question and enter the answer in the input field below. This is for blocking bots that try to post this form automatically.
Question: how much is 12 plus 17?
Message: