๐Ÿ”ฅ Lohri โ€ข ๐Ÿช Makar Sankranti โ€ข ๐Ÿ‡ฎ๐Ÿ‡ณ Republic Day | Offers | Upto 70% OFF + Extra 26% OFF โ€” One Coupon for All Courses โ†’ BHARAT26 ( Limited Period Celebration Offer ) << Explore Professional Courses >>

Multitasking, Multiprocessing & Multithreading  


Multitasking

  • Multitasking refers to the ability of an operating system to execute multiple tasks (processes or programs) seemingly at the same time.
  • It improves system utilization by sharing CPU time among processes and making the system more responsive.
  • Real-World Examples:
    • Listening to music in VLC while typing in Microsoft Word.
    • Downloading a file while browsing the internet in Chrome.
    • Video call while sharing your screen and chatting.
    • Mobile OS running WhatsApp, YouTube, and Camera apps together.
  • Multitasking can be achieved in two main ways:
    • Multiprocessing (using multiple CPUs/cores)
    • Multithreading (using multiple threads in a single process).

Multiprocessing

  • Multiprocessing refers to the ability of a computer system to execute multiple processes simultaneously using multiple CPUs or cores.
  • It improves system performance by parallel execution of independent processes, especially for CPU-intensive tasks.
  • Real-World Examples:
    • Modern processors like Intel i3, i5, or i7 have multiple cores, allowing multiple processes to run simultaneously. For example, an i3 with 2โ€“4 cores can run 2โ€“4 processes in parallel, while an i5 or i7 can handle even more processes concurrently.
      • Running multiple applications like VLC, Word and Chrome simultaneously on a multi-core processor.
      • Scientific simulations or big data processing that split tasks across multiple processors.

Multithreading

  • Multithreading refers to the ability of a single process to execute multiple threads concurrently within the same program.
  • It improves application performance by allowing simultaneous execution of tasks within the same process, sharing memory efficiently.
  • Real-World Examples:
    • Web servers handling multiple client requests simultaneously using threads.
    • Banking applications processing multiple transactions concurrently without waiting for each task to finish.
    • Games and animation software updating graphics, audio, and input handling using separate threads for smooth performance.
    • Downloading multiple files in parallel in an application like a download manager.
  • Multithreading helps in concurrent execution but requires careful handling to avoid race conditions, deadlocks and synchronization issues.