On Wed, 15 Jan 2020 18:23:05 +0530, Anupam Kapoor said:
On Wed, 15 Jan 2020 at 6:02 PM Sumit Kumar <sumit686215@gmail.com> wrote:
Does C/C++ provide any API / system call that enables user to force the application to transfer some its physical pages to swap disk ? If so, is it also possible to obtain the least used page using some API ?
would madvise not serve your needs ?
There's this word "force" in the question.
The problem is that madvise() is *advice* to the kernel, not a strict guarantee. There's a difference between "If you need to move pages to disk, consider these pages first" and "Move them to disk now, whether you really wanted to or not".
ofcourse (afaik) there is no way for the application to force the *kernel* to do something like this. but if _all_ that is required is randomly unmapping some marked application pages, _that_ can be naively 'done' by the application itself :) for example, have a list of unmappable pages and an unmapper thread which does the unmapping for you (picking any element in the list at random) -- kind regards anupam In the beginning was the lambda, and the lambda was with Emacs, and Emacs was the lambda. On Sat, Jan 18, 2020 at 3:10 PM Valdis Klētnieks <valdis.kletnieks@vt.edu> wrote:
On Wed, 15 Jan 2020 18:23:05 +0530, Anupam Kapoor said:
On Wed, 15 Jan 2020 at 6:02 PM Sumit Kumar <sumit686215@gmail.com> wrote:
Does C/C++ provide any API / system call that enables user to force the application to transfer some its physical pages to swap disk ? If so, is it also possible to obtain the least used page using some API ? would madvise not serve your needs ?
There's this word "force" in the question.
The problem is that madvise() is *advice* to the kernel, not a strict guarantee. There's a difference between "If you need to move pages to disk, consider these pages first" and "Move them to disk now, whether you really wanted to or not".