Algorithms
Algorithms
Multilevel queue scheduling – another class of scheduling algorithms has been created for situations has
been created for situations in which processes are easily classified into different groups
Foreground (interactive)
Background (batch)
If process uses too much CPU time, it will be moved to a lower priority queue
Leaves I/O-bound and interactive processes in the higher-priority queues
A process that waits too long in a lower-priority queue may be move to a higher-priority
queue to prevent starvation
Parameters
- asymmetric multiprocessing
One processor handles all system activities while other is for user only
- symmetric multiprocessing
Processor affinity
Soft affinity – OS has a policy of attempting to keep a process running on the same processor –
but not guaranteeing that it will do so
Hard affinity – allowing a process to specify a subset of processors on which it may run
Load balancing
Attempts to keep the workload evenly distributed across all processors in an SMP system
Push migration - involves the operating system proactively moving processes from a heavily
loaded processor to a less loaded one, attempting to balance the workload without waiting for
processes to finish.
Pull migration - allows underloaded processors to request processes from overloaded ones,
effectively pulling tasks to balance the load when they notice a performance drop. Both
methods aim for optimal resource utilization in a multi-processor system.
Multicore processors
Latency
- The amount of time that elapses from when an event occurs to when it is serviced
Interrupt latency
- is the time interval between the arrival of an interrupt signal and the start of the corresponding
interrupt handler's execution.
Deadlock - A deadlock is a situation in a multi-processing environment where two or more processes are
unable to proceed because each is waiting for resources held by the other. In this state, none of the
involved processes can continue execution, leading to a complete standstill. Deadlocks typically occur
when the necessary conditions for deadlock—mutual exclusion, hold and wait, no preemption, and
circular wait—are present
We can use a protocol to prevent or avoid deadlocks, ensuring that the system will never enter a
deadlocked state.
Deadlock avoidance
Requires that the operating system be given additional information in advance concerning which
resources a process will request and use during its lifetime
- When process enters the system, it must declare the maximum number of instances of each resource
type that it may need
- When resources are requested, the system must determine whether the allocation of these resources
will leave the system in a safe state
If it will, the resources are allocated; otherwise, the process must wait until some other process
releases enough resources
Available
A vector of length m indicates the number of available resources of each type. If available[i]
equals k, then k instances of resources type Rj are available
Max
An n x m matrix defines the maximum demand of each process. If max[i][j] equals k, then
process P, may request at most k instances of resource type Rj,
Allocation
An n x m matrix defines the number of resources of each type currently allocated to each
process, if allocation[i][j] equals k, then process P, is currently allocated k instances of resource
type rj
Need
an n x m matrix indicates the remaining resource need of each process, if need[i][j] equals k,
then process P, may need k more instances of resource type rj to complete its task. Note that
need[i][j] equal max[i][j] – allocates[i][j].
deadlock detection