tags:

views:

46

answers:

3

In regards to Operating System concepts... Can a process to have two working sets, one that represents data and another that represents code?

A: 

This depends on the OS.

But on common OSes like Windows there is no real difference between data and code so no, it can't split up it's working set in data and code.

Foxfire
+1  A: 

A "Working Set" is a term associated with Virtual Memory Manangement in Operating systems, however it is an abstract idea.

A working set is just the concept that there is a set of virtual memory pages that the application is currently working with and that there are other pages it isn't working with. Any page that is being currently used by the application is by definition part of the 'Working Set', so its impossible to have two.

Operating systems often do distinguish between code and data in a process using various page permissions and memory protection but this is a different concept than a "Working set".

luke
A: 

As you know, the working set is the set of pages that a process needs to have in primary store to avoid thrashing. If some of these are code, and others data, it doesn't matter - the point is that the process needs regular access to these pages.

If you want to subdivide the working set into code and data and possibly other categorizations, to try to model what pages make up the working set, that's fine, but the working set as a whole is still all the pages needed, regardless of how these pages are classified.

EDIT: Blocking on I/O - does tis affect the working set?

Remember that the working set is a model of the pages used over a given time period. When the length of time the process is blocked is short compared to the time period being modelled, then it changes little - the wait is insignificant and the working set over the time period being considered is unaffected.

But when the I/O wait is long compared to the modelled preriod, then it changes much. During the period the process is blocked, it's working set is emmpty. An OS could theoretically swap out all the processes' pages on the basis of this.

The working set model attempts to predict what pages the process will need based on it's past behaviour. In this case, if the process is still blocked at time t+1, then the model of an empty working set is correct, but as soon as the process is unblocked, it's working set will be non-empty - the prediction by the model still says no pages needed, so the predictive power of the model breaks down. But this is to be expected - you can't really predict the future. Normally. And the working set is expected to change over time.

mdma
Would it matter if the process ends up waiting for I/O before it can continue? I mean would this change anything with the working set? Or does this not change anything?