Threads in Distributed Computing


Komal Sali | Foram Rajgaur
Apr 30, 2025 9:32 am
Technology
Distributed Computing
Computer Science & Engineering

Threads in Distributed Computing

Thread is a small unit of execution within a process. When a program runs, it's called process and that process can have one or more threads executing in parallel.

Threads in distributed system enables parallelism and efficient multitasking across distributed nodes in the system. They play a crucial role in improving the performance and responsiveness of the system by allowing multiple tasks to execute concurrently, both within single process and across the distributed systems.

Why Threads are important?

  1. Parellelism: Threads allow multiple parts of a task to run simultaneously, improving the performance in multi-core and multi-node environments.

  2. Shared Resources: Threads share same memory and resources, making them lightweight than process.

  3. Concurrency: Threads allows multiple operations to be performed concurrently, such as handling multiple client requests in a server.

  4. Communication and Connection: Threads often handle inter-process communication, synchronisation, and distributed task execution.

Working of Threads in Distributed System

Thread is a flow of execution through the process code, with its program counter, system register and stack. A thread is called lightweight process. It improves the performance of the application through parellelism.

Each thread belongs to exactly one process and no thread can exist outside a process.

Threading models

Single threaded processes contain the execution of instructions in a single sequence. In other words, one command is processed at a time.

The opposite of single threaded processes are multithreaded processes. These processes allow the execution of multiple parts of a program at the same time. These are lightweight processes available within the process.

How threads and process work step by step

Here's what happens when you open an application on the computer:

  • The program starts out as a text file of programming code.

  • The program is compiled or interpreted into binary form.

  • The program is loaded into memory.

  • The program becomes one or more running processes. Processes are typically independent of one another.

  • Threads exist as the subset of a process.

  • Threads can communicate with each other more easily than processes can.

  • Threads are more vulnerable to problems caused by other threads in the same process.

Comparison between Process and Thread

Aspect Processes Threads
Definition Independent programs with their own memory space. Lightweight, smaller units of a process, share memory.
Creation Overhead Higher overhead due to separate memory space. Lower overhead as they share the same memory space.
Isolation Processes are isolated from each other. Threads share the same memory space.
Resource Allocation Each process has its own set of system resources. Threads share resources within the same process.
Independence Processes are more independent of each other. Threads are dependent on each other within a process.
Failure Impact A failure in one process does not directly affect others. A failure in one thread can affect others in the same process.
Synchronization Less need for synchronization, as processes are isolated. Requires careful synchronization due to shared resources.
Example Use Cases Running multiple independent applications. Multithreading within a single application for parallelism.
Memory Usage Typically consumes more memory. Consumes less memory compared to processes.

Advantages of Threads

  • Faster Execution: Threads run concurrently, which improves performance and responsiveness.

  • Efficient Resource Sharing: Threads share the same memory space, reducing memory usage.

  • Lower Overhead: Creating and managing threads is less expensive than full processes.

  • Improved Application Performance: Particularly useful in multi-core systems where threads can run in parallel.

Disadvantages of Threads

  • Complex Synchronization: Shared resources need careful synchronization to avoid race conditions and bugs.

  • Risk of Deadlocks: Improper handling can lead to deadlocks where threads wait indefinitely.

  • Failure Spread: An error in one thread can affect the entire process.

  • Platform Dependency: Thread behavior may vary across operating systems.

Use Case of Thread: Client-Server Paradigm

Client Server: File server

client-server

  • One thread listens on a network socket for clients

  • When a client connects, a new thread is spawned to handle the request. This permits several clients to connect to the file server at one time because each request is handled by a separate thread of execution.

  • To send the file data, two threads can be used the first can read from the file on disk and the second can write the read buffers to the socket.

Presentation Link

Canva Design

References

Connect with me:

Komal Sali

Foram Rajgaur

 

Distributed Computing Index Page


Enjoyed? Share this article with your friends. 


For updates, news, fun and games follow us on - 

Instagram - BuzzWorthy_O

Twitter - BuzzWorthy_O

Threads - BuzzWorthy_O

Facebook - BuzzWorthy Official


Got queries? Feel free to contact us via - 

Gmail - buzzworthy.sv@gmail.com 

BuzzWorthy - Contact Us Page 

 

-- Buzzzz 🌸🐝 --