Programming Models – Sequential, Parallel, Concurrent, Distributed, Dataflow

Programming Models

Programming Models are basically frameworks or styles that help us decide how our program will run and how resources (like CPU, memory) will be managed.

1. Sequential Programming Model

What It Means:

Also called the Linear model. Here, program instructions run one after another in the exact order they are written.
Task B cannot start until Task A is finished.

Example:

Imagine you are cooking. First you cut vegetables (Task A), then fry them (Task B), and then serve (Task C). You cannot fry before cutting.

Key Point: It is single-threaded and the easiest to understand.

2. Parallel Programming Model

What It Means:

Multiple parts of the program run at the same time on different processors or cores.
Main goal is to increase speed.

Example:

On a construction site, many workers (processors/cores) are building walls, mixing cement, and painting at the same time.

Key Point: Good for tasks with lots of data where work can be divided.

3. Concurrent Programming Model

What It Means:

It looks like multiple tasks are running at the same time, even if only one processor is switching between tasks.
Processor quickly switches from Task A to B to C (context switching) creating an illusion of simultaneous execution.

Example:

On your phone, you can listen to music, browse, and download files at the same time. The processor switches fast between tasks.

Key Point: Focus is on managing tasks and reducing waiting time to keep the system responsive. Unlike parallel, it may use only one processor.

4. Distributed Programming Model

What It Means:

Program parts run on different machines connected via a network.
Like parallel programming, but processors are spread across multiple computers.

Example:

Think of Google Search. When you search, thousands of servers worldwide process your request simultaneously.

Key Point: Great for fault-tolerance (if one machine fails, others work) and scalability (handle many users).

5. Dataflow Programming Model

What It Means:

Execution does not follow instruction order but depends on data availability.
An operation runs only when its input data is ready. This is called "firing".

Example:

In Excel, if cell C has formula A+B, C updates only when A or B changes. Work happens only when data is available.

Key Point: Used in reactive systems and signal processing where data streams continuously arrive.

Model Focus / Execution Style Simple Definition
Sequential Order-dependent, one after another Finish one task, then start next
Parallel Speed / Multiple jobs at the same time on multiple cores Many tasks run together on different CPUs
Concurrent Responsiveness / Multiple tasks overlapping in time on one core Processor switches quickly between tasks
Distributed Fault-tolerance / Multiple tasks on networked machines Work is shared across the network
Dataflow Data-driven / Execution depends on data availability Tasks start only when data is ready

Comments

Popular posts from this blog

Data Abstraction

Data Structure Ka Parichay Aur Prakar (Introduction and Types of Data Structure)

Data Abstraction