0% found this document useful (0 votes)
17 views2 pages

Lec 3

The document discusses the differences between multi-tasking and multi-threading. Multi-tasking involves executing multiple processes simultaneously by context switching between them. Multi-threading involves dividing a single process into multiple threads that can run concurrently by context switching between threads. Thread context switching is faster than process context switching since it does not require changing the memory address space.

Uploaded by

aaravjamela
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views2 pages

Lec 3

The document discusses the differences between multi-tasking and multi-threading. Multi-tasking involves executing multiple processes simultaneously by context switching between them. Multi-threading involves dividing a single process into multiple threads that can run concurrently by context switching between threads. Thread context switching is faster than process context switching since it does not require changing the memory address space.

Uploaded by

aaravjamela
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

LEC-3: Multi-Tasking vs Multi-Threading

Program: A Program is an executable file which contains a certain set of instructions written
to complete the specific job or operation on your computer.
• It’s a compiled code. Ready to be executed.
• Stored in Disk

Process: Program under execution. Resides in Computer’s primary memory (RAM).

Thread:
• Single sequence stream within a process.
• An independent path of execution in a process.
• Light-weight process.
• Used to achieve parallelism by dividing a process’s tasks which are independent path

p
of execution.
• E.g., Multiple tabs in a browser, text editor (When you are typing in an editor, spell-
checking, formatting of text and saving the text are done concurrently by multiple

el
threads.)

Multi-Tasking Multi-Threading
The execution of more than one task A process is divided into several different
eH
simultaneously is called as multitasking. sub-tasks called as threads, which has its
own path of execution. This concept is
called as multithreading.
Concept of more than 1 processes being Concept of more than 1 thread. Threads are
context switched. context switched.
No. of CPU 1. No. of CPU >= 1. (Better to have more than
1)
od

Isolation and memory protection exists. No isolation and memory protection,


OS must allocate separate memory and resources are shared among threads of that
resources to each program that CPU is process.
executing. OS allocates memory to a process; multiple
threads of that process share the same
memory and resources allocated to the
C

process.

Thread Scheduling:
Threads are scheduled for execution based on their priority. Even though threads are
executing within the runtime, all threads are assigned processor time slices by the operating
system.

Difference between Thread Context Switching and Process Context Switching:


Thread Context switching Process context switching
OS saves current state of thread & switches OS saves current state of process &
to another thread of same process. switches to another process by restoring its
state.
Doesn’t includes switching of memory Includes switching of memory address
address space. space.
(But Program counter, registers & stack are
included.)
Fast switching. Slow switching.
CPU’s cache state is preserved. CPU’s cache state is flushed.

p
el
eH
od
C

You might also like