Table of contents
Concurrency
Concurrency and parallelism are two important concepts in operating systems, and they are often confused with each other. While both terms are related to executing multiple tasks at the same time, they have distinct differences. In this post, we will explain the difference between concurrency and parallelism in OS, and provide some detailed examples.
Concurrency refers to the ability of an operating system to manage multiple tasks or processes at the same time, but not necessarily simultaneously. Concurrency does not require the use of multiple CPU cores or processors. Instead, it uses a technique called time-sharing to allocate a small amount of time to each task, so that it appears that they are all running at the same time. This is also known as multitasking.
Example
For example, when you are typing in a word processor, the OS is also running background tasks such as printing, checking for updates, and running antivirus scans. Even though you cannot see these tasks running, the OS is still managing them concurrently.
Parallelism
Parallelism, on the other hand, refers to the ability of an operating system to execute multiple tasks or processes simultaneously, using multiple CPU cores or processors. Parallelism requires hardware that can run multiple threads or processes simultaneously. When an OS executes multiple tasks in parallel, each task has access to its own CPU core or processor, and they can all execute at the same time.
Example
For example, if you are running a large scientific computation, parallelism can be used to divide the computation into smaller parts that can be executed simultaneously on multiple processors, resulting in a significant speedup.
Summary
To summarize, concurrency and parallelism are both related to executing multiple tasks at the same time, but they differ in the way they achieve this goal. Concurrency is achieved through time-sharing and can run on a single processor, while parallelism requires multiple processors or cores to execute tasks simultaneously.