- New: The process which is being created (long term scheduler)
- Running: Instructions being executed
- Waiting: The process is waiting for an event to get occur
- Ready: The process is waiting to be assigned to a processor
- Terminated: The process completed its execution
These names of the states are uninformed and they vary across operating system. These stats are mostly found on all systems but some operating systems also more finely define process states. Processer can hold only one process at a time simply it can be running one process at a time. However, many processes may be ready or waiting.
-- --
**Processes waiting in Job Pool**
**Long Term Scheduler**
- selects the process that are to be placed in ready queue.
- decides the priority in which processes must be placed in main memory
**Medium-Term Scheduler**
- places the blocked and suspended processes in the secondary memory (swapping out)
- moving back a swapped out process from secondary memory to main memory is known as swapping in
**Short-Term Scheduler**
- decides the priority in which processes is in the ready queue are allocated CPU time for execution.
-- --
Context Switching
-----------------
**Triggers:**
- Multitasking
- Interrupt Handling
- User and Kernel mode Switch
Hardware Bit - Mode controls what mode we're in. User mode or Kernel Mode. Use sys calls to access Kernel Mode.
1. Arrival Time: The time at which the process enters into the ready queue is called the arrival time.
2. Burst Time: The total amount of time required by the CPU to execute the whole process is called the Burst Time. This does not include the waiting time. It is confusing to calculate the execution time for a process even before executing it hence the scheduling problems based on the burst time cannot be implemented in reality.
3. Completion Time: time at which the process enters into the completion state or the time at which the process completes its execution, is called completion time.
4. Turnaround time: The total amount of time spent by the process from its arrival to its completion, is called Turnaround time.
5. Waiting Time: The Total amount of time for which the process waits for the CPU to be assigned is called waiting time.
6. Response Time: The difference between the arrival time and the time at which the process first gets the CPU is called Response Time.
- convoy effect: long processes cause short ones to starve
SJF - non preemptive
SRTF - preemptive
-- --
How does the OS determine the Burst Time?
-----------------------------------------
- needed for SJF and SRTF
- estimate based on an initial starting default burst value and actual historical run values.
- assigned a default estimated value for its first burst
- last estimated burst and the last actual burst are averaged to provide the process's next estimated burst.
- ensures getting close to the median value
- wouldn't choose this method for scheduling a general purpose system
- prefer a combined priority/quantum scheduling arrangement
- With SJF, a busy system with many short burst jobs could starve the longer burst CPU intensive jobs. And if a job had short previous run times then got into a compute intensive loop, even other "short" jobs could wait excessive times before getting CPU time. It can work well for systems that aren't excessively CPU bound and for systems where the process run times are reasonably consistent.
- In a priority/quantum round robin based systems, jobs with the same priority are given at lease some CPU time, but will relinquish the CPU to other equal priority processes when it's quantum ends and will wait for its turn to come around again. If a higher priority process needs CPU time, it can preempt lower priority processes. Various priority boosting methods can prevent complete starvation of low priority jobs on busy systems.