3
votes

I know that Process Context is something that is stored when a process is preempted, containing all the necessary info to restart the process at a later time.

I also know that theProcess Control Block (PCB) contains all the necessary attributes of the process.

So, does that mean that the Process Context is a part of the PCB? Or is it the other way around? Or are these separate all together? Please help me understand where one ends and the other begins - as well as how they're used together.

What exactly is a process boundary?

Also, how is the PCB affected during a context switch (if at all)?

2

2 Answers

2
votes

What you are describing is largely system dependent. Usually when one talks about the Process Context [Block], one is referring to the hardware state of the process. In other words, a memory location for saving the values of the hardware registers that are limited in scope to a single process.

A Process Control Block (or equivalent) can be anything the operating system wants it to be. It could include, for example, the user name and process quotas. If we presume that the process control block contains everything the operating system maintains about the process, it would either contain the Process Context Block or have a link to it.

Adding to the confusion here is the acronym PCB. At least in ye olde days, PCB referred to the hardware Process Context Block. Apparently some textbooks are using the same abbreviation to refer to the software Process Control Block (as does one particularly poor textbook on Operating Systems that causes so much confusion and questions on this board).

Further adding to the confusion, no system that I have worked on has a Process Control Block as described in such textbooks and Wikipedia. I suspect that this concept is the creation of textbook writers to describe the various data structures an operating system uses to manage a process collectively.

Also, how is the PCB affected during a context switch (if at all)?

If you are referring to the hardware Process Context Block, before switching out the operating system executes a SAVE PROCESS CONTEXT (or equivalent) instruction that saves the process's hardware registers to a block of memory. Some processors require multiple instructions to do this. The OS then executes a LOAD PROCESS CONTEXT instruction that reads from another Process Context Block and loads saved registers from another process. As soon a such an instruction executes, the process has been switched.

As to what may be saved in the theoretical Process Control Block, that could be anything the operating system wants. E.g., statistical information. If the Hardware PCB is part of the Software Process Control Block, the paragraph above is part of your answer.

What exactly is a process boundary?

That's a loaded question because there are, in fact multiple boundaries for a process.

From a memory perspective, in user mode, one could say a process's boundary is its user mode address space.

That changes when the process changes modes. When it goes into Kernel Mode, the process effectively has no boundaries. It can directly access the process address space and the shared system address space but it can also access the address spaces of other processes (at least indirectly).

From a disk perspectives, one could say a process's boundary is that imposed by the file system.

2
votes

During a context switch, only the state of the process(which includes Program Counter etc.) is stored in Process Control Block, so that this information could be used at some later point of time to resume the execution.

This operational state data is called the process context whereas process control block is a data structure that contains process identification data, process state data and process control data.