5. Chapter 5: Distributed Operating System
5.4. Processes and threads
Processes and threads- A process consists of an execution environment together with one or more threads.
- Execution environment
- unit of resource management
- A collection of local kernel-managed resources to which its threads have access.
- Consists of
- An address space
- Thread synchronization and communication resources such as semaphores and communication interfaces (example: sockets).
- Higher-level resources such as open files and windows.
- Expensive to create and manage, but several threads can share them.
- Represent the protection domain in which its threads execute.
- Threads can be created and destroyed dynamically, as needed.
- Thread - operation system abstraction of an activity.
- Multiple threads of execution
- Maximize the degree of concurrent execution between operations
- Enabling the overlap of computation with input and output.
- Enabling concurrent processing on multiprocessors.
- Helpful within servers, where concurrent processing of clients’ requests can reduce the tendency for servers to become bottlenecks.
- Execution environment provides protection from threads outside it.
- Certain kernels allow the controlled sharing of resources between execution environments residing at the same computer.
Address
spaces
- A unit of management of a process’s virtual memory.
- Large (232 bytes or 264 bytes)
- Consists of one or more regions, separated by inaccessible areas of virtual memory.
- A region is an area of contiguous virtual memory that is accessible by the threads of the owning process.
- Regions do not overlap.
- Each region is specified by the following properties:
- Its extent (lowest virtual address and size)
- Read/write/execute permissions for the process’s threads
- Whether it can be grown upwards or downwards.
Figure
: Address space

- Gaps are left between regions to allow for growth.
- Generalization of the UNIX address space, which has three regions:
- A fixed → unmodifiable text region containing program code
- A heap → part of which is initialized by values stored in the program’s binary file, which is extensible towards higher virtual addresses
- A stack → which is extensible towards lower virtual addresses.
- The provision of an indefinite number of regions is motivated by several factors;
- To support separate stack for each thread.
- Make it possible to detect attempts to exceed the stack limits and to control each stack’s growth.
- Unallocated virtual memory lies beyond each stack region, and attempts to access to these will cause an exception
- To enable files in general
- not just the text and data sections of binary files – to be mapped into the address space.
- Mapped file – accessed as an array of bytes in memory
- Shared memory region
- Same physical memory as one or more regions belonging to other address spaces.
- Libraries
- a single of copy of the library code can be shared by being mapped as a region in the address spaces of processes that require it.
- Kernel
- kernel code and data are mapped into every address space at the same location.
- When a process makes a system call or an exception occurs, there is no need to switch to a new set of address mappings.
- Data sharing and communication
- it can be considerably more efficient for the data to be shared by being mapped as regions in both address spaces than by being passed in messages between them.
Creation
of new process
- The design of the process-created mechanism has to take into account the utilization of multiple computers.
- Two independent aspects:
- The choice of a target host
- The creation of an execution environment
- Choice of process host
- The choice is a matter of policy.
- Location policy
- Determines which node should host a new process selected for transfer.
- Depends on the relative loads of nodes.
- The choice of target host is transparent to programmer and the user.
- Static
- Operate without regard to the current state of the system
- Based on mathematical analysis aimed at optimizing a parameter such as overall process throughput.
- Maybe deterministic – node A should always transfer process to node B
- Maybe probabilistic – node A should transfer processes to any of nodes B – E at random
- Adaptive
- Apply heuristics to make their allocation decisions, based on unpredictable runtime factors such as a measure of the load on each node.
- Load-sharing systems maybe
- Centralized
- Load manager component collects information about the nodes and use it to allocate new processes to nodes.
- Hierarchical
- Several load managers, organized in a tree structure.
- Managers make process allocation decisions as far down the tree as possible, but managers may transfer processes to one another, via a common ancestor, under certain load conditions.
- Decentralized
- Nodes exchange information with one another directly to make allocation decisions.
- Example: The Spawn system considers nodes to be ‘buyers’ and ‘sellers’ of computational resources and arranges them in a (decentralized) ‘market economy’.
- Load-sharing algorithms
- Sender-initiated
- The node that requires a new process to be created is responsible for initiating the transfer decision.
- Initiates a transfer when its own load crosses a threshold.
- Receiver-initiated
- A node whose load is below a given threshold advertises its existence to other nodes so that relatively loaded nodes can transfer work to it.
- Migratory load-sharing systems
- Can shift load at any time
- Process migration mechanism – transfer of an executing process from one node to another.
- Creation of a new execution environment
- Two approaches to defining and initializing the address space of a newly created process.
- First approach address space is of a statically defined format.
- Second approach address space can be defined with respect to an existing execution environment.
- UNIX: the newly created child process physically shares the parent’s text region and has heap and stack regions that are copies of the parent’s in extent (as well as in initial contents).
- This scheme has been generalized so that each region of the parent process maybe inherited by (or omitted from) the child process.
Figure
: Copy-on-write
