1
$\begingroup$

I'm studying OS and I came up with this scenario where the OS works with a paging scheme and virtual memory, and a process wants to start running, but in memory, there's not enough space to allocate the minimum pages the process needs.

So I was wondering, will the OS try to allocate the process pages and end up thrashing? Or will automatically discard the process and trap indicating there's not enough space?

I know there are techniques to avoid thrashing but I don't really know how they are implemented and what the system considers appropriate to run in the system.

$\endgroup$
1
$\begingroup$

There's no set answer; it will come down to what the OS is implemented to do in that situation. I suppose if you implement the OS poorly, arbitrarily bad things could happen.

But in practice, with modern OS's, there's no such thing as "minimum pages the process needs". The way virtual memory works is that the process has no idea what pages are actually mapped into physical memory at any times and which ones aren't; the OS transparently pages in pages as needed. So, that notion doesn't exist.

Thrashing is not a black-and-white phenomenom. For instance, thrashing can happen if 98% of the CPU time is spend paging pages in and out of memory, and only 2% on running the process itself. In that case, forward progress is still being made -- just very slowly.

$\endgroup$
  • $\begingroup$ Thanks for the answer! I understand what you say and I agree with you, but I found in the Silberschatz operating systems (9th ed.) book a way to justify the "minimum pages the process needs" concept. Basically, on page 422 explains how this minimum determines a better performance and how the computer architecture affects this minimum. Really interesting reading. $\endgroup$ – Emirg Aug 17 '18 at 0:14
  • $\begingroup$ Actually OS monitors these amounts since VAX VMS afair (definitely it was in Windows NT from the start). It is mentioned as Working Set in the Task Manager. But, at least in Windows, it's runtime parameter computed by the OS itself, rather than a characteristic mentioned in the executable file header. $\endgroup$ – Bulat Aug 17 '18 at 8:05

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.