Câu hỏi phỏng vấn Software Architecture
Câu hỏi

What is the difference between Concurrency and Parallelism?

Câu trả lời

Concurrency and parallelism are two fundamental concepts in software architecture, often used to improve the efficiency and performance of applications, but they refer to different aspects of multitasking.

Concurrency

Concurrency involves managing multiple tasks at the same time. It is more about the structure of a program and how it handles multiple tasks. In a concurrent system, tasks start, run, and complete in overlapping time periods, but not necessarily simultaneously. The main goal of concurrency is to enable the system to handle multiple tasks or processes simultaneously, making efficient use of CPU time by dealing with tasks during waiting times or delays, such as I/O operations. This is achieved through mechanisms like threading, where tasks are interleaved on a single processor[2][3][4][5].

A key point about concurrency is that it doesn't necessarily mean tasks are physically running at the same time; rather, it creates the illusion of parallelism as tasks are switched in and out of the CPU. For example, on a single-core processor, a concurrent program might handle multiple tasks by switching between them, which may involve state saving and restoring, often managed by the operating system's scheduler[2][3][4][5].

Parallelism

Parallelism, on the other hand, refers to the simultaneous execution of multiple tasks or sub-tasks. This can only occur on systems with multiple processing units (e.g., multicore processors). In parallel computing, tasks are literally executed at the same time, speeding up the computing process significantly[2][3][4][5].

Parallelism is used to divide a task into sub-tasks that can be processed simultaneously, thus reducing the time required to complete the main task. This is particularly effective for tasks that can be easily broken do...

middle

middle

Gợi ý câu hỏi phỏng vấn

expert

What Is Shared Nothing Architecture? How Does It Scale?

senior

Defend the monolithic architecture.

senior

What is actor model in context of a programming language?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào