Fundamentals 12 min read

Understanding Processes, Threads, Concurrency, and Process Pools

This article explains the concepts of processes and threads, their differences and interactions, the states of a process, the distinctions between serial, concurrent, and parallel execution, and the purpose and operation of process pools in modern computing environments.

Laravel Tech Community
Laravel Tech Community
Laravel Tech Community
Understanding Processes, Threads, Concurrency, and Process Pools

1. Process

What is a process?

When we run a program, the running instance is called a process.

In other words, executing a program creates a process.

Key point

A process requests a block of memory, places data into that memory, and is the smallest unit of resource management.

A process is a container for threads.

Difference between program and process

A program is a static collection of data and instructions that can be stored long‑term.

A process is the dynamic execution of a program; it has a lifecycle and disappears when the program terminates.

Process interaction

Processes communicate via TCP/IP ports.

2. Thread

What is a thread?

A thread is the smallest unit that the operating system can schedule for execution.

It resides inside a process and is the actual execution unit of that process.

Each thread represents a single sequential flow of control; a process can have multiple concurrent threads, each performing different tasks.

Key point

A thread is a pipeline within a process that executes code without requesting additional resources; it is the smallest executable unit of a program.

Thread interaction

Multiple threads share the same memory space and communicate through that shared memory.

3. Relationship between processes and threads

Example

Opening a chat application creates a process; opening features such as “Space”, “Scan”, or “Settings” creates threads within that process.

Thus, a process contains threads, and threads are a subset of a process.

Process is a container for threads

Factory assembly‑line analogy (images omitted for brevity).

4. Summary

Process : an application that is running in the system; the smallest unit of resource allocation .

Thread : the basic unit of CPU time allocation, or an independent execution flow within a process; the smallest unit of program execution .

A process allocates a large memory region, while a thread only needs a small stack.

Every program has at least one process, and every process has at least one thread.

Threads can create and terminate other threads; multiple threads in the same process can run concurrently.

2. Parallel, Concurrent, Serial

Concurrent : multiple tasks appear to run at the same time (pseudo‑parallelism).

Implemented on a single‑core CPU using time‑slicing (multitasking).

Parallel : multiple tasks truly run simultaneously, requiring multiple cores.

Parallelism requires multi‑core hardware; otherwise only concurrency (pseudo‑parallelism) is possible.

Serial : one task runs to completion before the next starts.

3. Three States of a Running Task

A process continuously changes its execution state during its lifetime.

The three states are: Ready, Running, Blocked.

1. Ready State

All necessary resources except the CPU have been allocated; the process will run as soon as it obtains the CPU.

Multiple ready processes are placed in a ready queue.

2. Running State

The process has obtained CPU time and its program is executing.

On a single‑core system only one process is running; on multi‑core systems several can run simultaneously.

3. Blocked State (Sleep)

A running process is waiting for an event (e.g., I/O, higher‑priority task) and loses the CPU.

Reasons for blocking include waiting for I/O or preemption by a higher‑priority task.

4. Transitions Between States

A process may move repeatedly among Ready, Running, and Blocked states.

Ready → Running

When the scheduler assigns a CPU time slice to a ready process, it becomes running.

Running → Ready

If a running process exhausts its time slice, it returns to the ready state.

Running → Blocked

If the process must wait for I/O or is preempted by a higher‑priority task, it becomes blocked.

Blocked → Ready

When the awaited event completes, the blocked process returns to the ready queue.

4. Two Ways to Submit Tasks

1. Synchronous

The sender waits for a response before sending the next message.

Two programs are tightly coupled; one thread blocks until the other finishes.

2. Asynchronous

The sender does not wait for a response and proceeds to send the next message.

Threads operate independently of each other.

Examples

Synchronous

Someone calls you to eat; you respond immediately and go together. If you don’t hear, they keep calling until you acknowledge.

Phone calls are analogous to synchronous communication – both parties must be engaged.

Asynchronous

You are asked to eat, you go later; the caller may continue with other tasks. Sending a message is like asynchronous communication – you can talk to another person without waiting.

5. Process Pool

1. What is a process pool?

A process pool consists of resource processes and management processes that work together.

2. Why use a process pool?

When thousands of tasks arrive during peak load, creating a new process for each task would be costly in time and resources, and the OS cannot run all of them simultaneously.

A process pool limits the number of active processes, reusing idle ones to handle new tasks, thereby reducing overhead and achieving concurrency.

3. Concept of a process pool

Define a fixed‑size pool and pre‑create that many processes.

When a task arrives, a free process from the pool handles it.

After completion, the process returns to the pool instead of terminating.

If all pool processes are busy, incoming tasks wait until a process becomes free.

The pool size limits the maximum number of concurrently running processes, simplifying scheduling and improving efficiency.

4. Resource processes

Pre‑created idle processes that perform actual work when assigned by the management process.

5. Management processes

Responsible for creating resource processes, dispatching tasks to idle resources, and reclaiming processes after work is done.

concurrencyThreadOperating SystemprocessParallelismprocess pool
Laravel Tech Community
Written by

Laravel Tech Community

Specializing in Laravel development, we continuously publish fresh content and grow alongside the elegant, stable Laravel framework.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.