Context

From COMP15212 Wiki
On path: Processes 1: Processes • 2: Context • 3: Process Control Block (PCB) • 4: Multi Threading • 5: Threads • 6: Interprocess Communication • 7: Process Scheduling • 8: Scheduler • 9: Process States • 10: Process Priority
On path: OS Topics 1: Concepts • 2: Cache • 3: Context • 4: Processor Privilege • 5: Process Scheduling • 6: Exceptions • 7: Interrupts • 8: Direct Memory Access (DMA) • 9: Virtualisation • 10: Hypervisor
Depends on ProcessesSecurity

Caution: not all the terms used here may be familiar on a first visit.

An executing process will have a particular context. This is the environment in which it operates, and includes its variables – in memory or processor registers – and the resources which it ‘owns’.

Most of this will be kept in the main memory of the computer. The main memory is (in some sense) ‘large’ and can accommodate several processes simultaneously. In addition to the memory assigned to a process, there are usually some resources which need to be shared. One example – probably already familiar – is that the processor running the code has some ‘registers’ which store variables temporarily during execution. There will also be some ‘resources’ (such as particular files in use) which the O.S. keeps track of.

Process context

This figure assumes a virtual memory system which shares the physical memory amongst processes. In the figure the blue process is currently executing. It occupies the processor and the virtual address space; if it is not too ‘hungry’ for space it will share the pages of the physical memory with other (not-executing-at-this-moment) processes.

There will be a Process Control Block (PCB) associated with the process; this holds (or points to) information such as the process’ identity, parent, priority, resources it is holding (such as memory, peripherals etc.) etc.

Register values are part of the process’ context; thus they require saving (in some reserved memory, by the OS) whenever the running process changes. This is part of the process of context switching.

A simple processor (best to stick to a simple processor to start with!) can only run one process at a time. If your computer is running several processes ‘simultaneously’ it is therefore running one for a (short) time, then context switching to another and so on. This is done fast enough for a human not to notice the stop-start behaviour although your ‘favourite’ process may perceptibly slow down if the machine is very busy as it gets a lesser share of processor time.

Timesharing


More details

A process’ full context includes:

  • state held within the processor (‘registers’ etc.).
  • the memory management page tables.
  • a list of resources owned by that process.
  • any specific cached information

Also refer to: Operating System Concepts, 10th Edition: Chapter 3.2.3, pages 114-115


Articles on Concepts
About this resource • Application Binary Interface (ABI) • Arrays • Atomicity • Boot • Cache • Cacheability • Caching • Concepts • Containers • Context • Context Switching • Deadlock • Direct Memory Access (DMA) • Environment Variables • Exceptions • File Attributes • Fragmentation • Hypervisor • Interrupts • Operation Ordering • PATH • Pointers • Process Scheduling • Processes • Processor Privilege • Queues • Real Time • Reentrancy • Relocatable Code • Spooling and Buffering • Synchronisation • Thrashing • Threads • Virtual Memory • Virtualisation
Articles on Major concepts
Cache • Cacheability • Concepts • Context • Direct Memory Access (DMA) • Exceptions • Hypervisor • Metadata • Process Scheduling • Processor Privilege • Real Time • Reentrancy • Synchronisation • Virtualisation
Articles on Processes
About this resource • Atomicity • Containers • Context • Context Switching • Daemons • Fork Unix • Hypervisor • Idle • Interprocess Communication • Multi Threading • Mutual exclusion • Pipes • Pointer Arithmetic • Process Control Block (PCB) • Process Priority • Process Scheduling • Process States • Processes • Queues • Queues Extra • Race Conditions • Real Time • Resources • Scheduler • Signal and Wait • Sleep • Starvation • Synchronisation • Thrashing • Threads • Unix Signals