process based multitasking – Programmerbay https://programmerbay.com A Tech Bay for Tech Savvy Sun, 11 Oct 2020 08:04:46 +0000 en-US hourly 1 https://wordpress.org/?v=6.5.5 https://programmerbay.com/wp-content/uploads/2019/09/cropped-without-transparent-32x32.jpg process based multitasking – Programmerbay https://programmerbay.com 32 32 Difference Between Process Based Multitasking and Thread Based Multitasking https://programmerbay.com/difference-between-process-based-multitasking-and-thread-based-multitasking/ https://programmerbay.com/difference-between-process-based-multitasking-and-thread-based-multitasking/#respond Sat, 25 Jan 2020 17:45:03 +0000 https://programmerbay.com/?p=5933 Java has multithreading programming feature which is nothing but a form of multitasking. Multitasking enables a system to perform multiple tasks simultaneously.

The main aim of this concept is to reduce the response time and increase the throughput of a processor.

It is done by allocating a small slice of CPU time to each process and switching back and forth among these concurrently running processes, to create the illusion of parallel execution.

Multitasking can be classified into two types :

  • Process-based multitasking
  • Thread-based multitasking

multithreading and multitasking

Difference between Process-based multitasking and Thread based multitasking?

Basis Process Based MultitaskingThread Based Multitasking
DefinitionExecuting two or more programs concurrentlyExecuting two or more threads simultaneously
Smallest UnitProgramThread
OverheadHighLow
Address spaceEvery program has its own address spaceEvery thread shares a same address space
Context switching CostHighLow
Interprocess communicationlimited and expensiveInexpensive
Also KnownHeavyweight processLighweight process
Best suitableOS levelProgrammatic level
ExampleExecuting MP3 player, text editor, and Browsing concurrentlyPrinting documents as well keep editing on a text editor

Key Differences

Definition:

Process-based multitasking enables a system to execute two or more programs concurrently, whereas Thread based multitasking enables a program to carry out two or more tasks in form of threads simultaneously.

Smallest unit:

In process-based multitasking, a program is the smallest unit that can be executed independently

In thread-based multitasking, a thread is the smallest unit that can be executed independently

Overhead:

Process-based multitasking puts more overhead than thread-based multitasking.
A thread is a lightweight process, therefore thread-based multitasking puts less overhead than process-based multitasking.

Address space:

A process performs heavy tasks and takes up a separate address space
A thread performs light tasks and shares the same address space with other threads belong to the same program

Communication:

Interprocess communication is limited and expensive in Process-based multitasking, whereas
Interthread communication is inexpensive in thread-based multitasking.

Context switching;

In the case of process-based multitasking, context switching from one process to another costs high.

In case of a thread, context switching from one thread to another cost low.

Example:

Using process-based multitasking, multiple programs such as MP3 player, text editor, and Browsing are together executed parallelly.

Using thread-based multitasking, multiple tasks of a single program such as compiler in which compiling and opening another file at the same time can be done together with the help of two threads.

Process

A process is a program in execution. Each process has its own address space, program counter, data section, stack and register set.

Thread

A Thread is an independent dispatchable code that has a unique path of execution. Each thread has its own Program counter, stack and register set despite all share same address space.

]]>
https://programmerbay.com/difference-between-process-based-multitasking-and-thread-based-multitasking/feed/ 0