Multitasking Operating System - Animation - Simple Example - Easy Explanation
Multitasking Operating System - Animation - Simple Example - Easy Explanation
Explanation
Multitasking operating system is the logical extension of multi programming
multitasking is based on same concept of multi programming but with some
improvements.
Simplify definition
When you are using multiple programs all these programs or processes are loaded into
the main memory.
now processes are assigned specific quantum of time let's say time quantum is 6
nanoseconds so CPU will execute first process for 6 nanoseconds then move to next
process which also will be executed for 6 nanoseconds then the third one and so on after
the last one again the first will be executed for 6 nanoseconds.
Time Quantum
time quantum is the period of time for which a process is allowed to run.
The multitasking operating system does the switching so fast that it feels like all
processes are running parallel and because it is so fast we users are able to work on
multiple programs conveniently.
Example
Consider you are a school teacher and you have to take oral examination of students by
asking them four questions each you decide that I will ask each student only two
questions at a time you start with the first student ask him two questions there are two
more questions left but you move to the second student ask the second student two
questions and move on to the third again ask the third student two questions and move
forward you go on to the last student and ask two questions now again start with the first
student ask him third and fourth question as you have decided that two questions at a
time you move to second student and ask third and fourth then move on to third and go
on to the last one now each student's questions are completed same as this teacher takes
oral exam of students multitasking OS executes processes using specific time quantum.
I. first process to the CPU CPU executes the process for five nanoseconds and stops
execution for process one
II. now process one has ten nanoseconds of execution left then the operating system
assigns second process to the CPU CPU executes sit for five nanoseconds and
stops execution
III. now the process to has five nanoseconds of execution left then the operating
system assigns third process to the CPU CPU execute sit for five nanoseconds
and stops execution
IV. now the process three has 15 nanoseconds of execution left then the operating
system again assigns first process to the CPU CPU execute sit for five
nanoseconds and stops execution
V. now the process one has five nanoseconds of execution left then the operating
system assigns second process to the CPU CPU executes sit for five nanoseconds
and stops execution
VI. now the process two has completed its execution as it was executed for ten
nanoseconds now it will be removed from the memory then the operating system
assigns their process
VII. to the CPU CPU execute sit for five nanoseconds and stops execution
VIII. now the process three has ten nanoseconds of execution left then the operating
system again assigns first process to the CPU CPU execute sit for five
nanoseconds and stops execution
IX. now the process one completes its execution completely forc15 nanoseconds now
it will be removed from the memory then the operating system assigns third
process to the CPU
X. CPU execute sit for five nanoseconds and stops execution
XI. now the process three has five nanoseconds of execution left then the operating
system again assigns third process to the CPU as no other process is present in
memory CPU execute sit for 5 nanoseconds and stops execution
XII. now the process 3 also completes at execution which was of 20 nanoseconds and
it will also get removed from the memory
this is how processes are executed in the multitasking ortime-sharing operating system it
is different from multi programming operating.