MULTI-TASKING vs MULTI-THREADING

Syed Zain Rashid
2 min readOct 9, 2020

Multi-tasking

In Early era when computers were invented, a user was allowed to submit only job or task at a time. But later with availability of high-speed processor, one can submit more than one task.

Multi-tasking means doing multiple tasks at a time.

  • In multitasking, CPU is provided to execute many tasks at a time easily.
  • It is an ability of an OS to execute more than one program simultaneously.
  • It’s a time sharing process. CPU switches from one program to another program so quickly to complete all other programs simultaneously.
  • Multi-tasking involves multi-processing.
  • In multi-tasking, processes shares different resources, each process is allocated separate resources that’s why it is also called heavyweight process.
  • Multi-tasking is slower as compared to multi-threading.
  • It is less efficient.

Examples:

Fig 1
Fig 2.

Multi-threading

In OS, an executed program’s code is run in a process, and the OS manages multiple processes at once. Within your program, you can also have independent parts that run simultaneously. The features that run these independent parts are called threads. Each task within the program is called a thread.

Threads are the capability of physical processor to perform task. Threads are present in core.

Splitting the program into multiple threads can improve the performance because program does multiple task at a time but it also adds some complexity like Race conditions,Deadlocks and Bugs.

  • In Multi-threading,many threads are created from a process through which computer power is increased.
  • CPU switching is involved in between the threads.
  • In multi-threading processes are allocated the same memory. Each process share same resources so it’s a light weight process.
  • Multi-threading is faster than multi-tasking
  • It is more efficient.
  • It is cost effective in case of context switching.
  • An ideal thread which is not working also gaining some additional resources.

Examples:

Fig 1.
Fig 2.

--

--

Syed Zain Rashid
0 Followers

Electronics Engineer | Data Center Engineer | DevOps Enthusiast