Sie sind auf Seite 1von 13

Distributed Computing ( Process

and Thread Management )


Submitted by Harshit (18mcmc42)
Topics

• What is a Distributed System?


• What is Program, Process and Thread?
• Single core Vs Multicore Operating System.
• How distributed computing is done using
Thread and Multicore Operating system.
• References.
What is Distributed System?
… is a collection of separate and independent software/hardware
components, called nodes, that are networked and work together
coherently by coordinating and communicating through message
passing or events, to fulfill one end goal.
Nodes could be unstructured or highly structured,
depending on the system requirement. And the complexities of the
system are hidden to the end user. Making the whole system
appear as a single computer to it users.
Program
Program is an executable file containing the set of instructions written
to perform a specific job on your computer. For
example, chrome.exe is an executable file containing the set of
instructions written so that we can view web pages. notepad.exe is an
executable file containing the set of instructions which help us to edit
and print the text files.
Programs are not stored on the primary memory in your
computer. They are stored on a disk or a secondary memory on your
computer. They are read into the primary memory and executed by the
kernel.
Process
Process is an executing instance of a
program. For example, When you
double click on a notepad icon on
your computer, a process is started
that will run the notepad program.
A process is sometimes referred
as active entity as it resides on the
primary memory and leaves the
memory if the system is rebooted.
Several processes may related to
same program. For example, you can
run multiple instances of a notepad
program. Each instance is referred as
a process.
Thread
Thread is the smallest executable unit of a process.
For example, when you run a notepad program,
operating system creates a process and starts the
execution of main thread of that process.

A process can have multiple threads. Each thread will


have their own task and own path of execution in a
process. For example, in a notepad program, one
thread will be taking user inputs and another thread
will be printing a document.

All threads of the same process share memory of that


process. As threads of the same process share the
same memory, communication between the threads
is fast.
Thread continue..
All threads of the same process share memory of that process. As threads of the same
process share the same memory, communication between the threads is fast.
Single core / Concurrency

In Operating Systems,
concurrency is defined as the
ability of a system to run two
or more programs in
overlapping time phases.
As you can see, at any given time, there is
only one process in execution. Therefore,
concurrency is only a generalized
approximation of real parallel execution.
This kind of situation can be found in
systems having a single-core processor
Parallel Execution or (Multi-Core)

In parallel execution, the tasks to be


performed by a process are broken down into
sub-parts, and multiple CPUs (or multiple
cores) process each sub-task at precisely the
same time.
• As we can see, at any given time, all
processes are in execution. In reality, it is
the sub-tasks of a process which are
executing in parallel, but for better
understanding, you can visualize them as
processes.
• Therefore, parallelism is the real way in
which multiple tasks can be processed at
the same time. This type of situation can be
found in systems having multicore
processors, which includes almost all
modern, commercial processors.
How distributed computing is done using
Thread and Multicore Operating system
Multiprocessors
» task environment located in shared memory
» threads can run in parallel on different CPUs
» just need to synchronize shared memory access
◆ Thread management
» static threads: number of threads is fixed
» dynamic threads: threads can be created and destroyed at run time
Continue..
The main purpose of multithreading is to provide simultaneous execution of
two or more parts of a program that can run concurrently. Threads are
independent. If an exception occurs in one thread, it doesn’t affect the others.
>> Some multithreaded applications would be:
1. Web Browsers - A web browser can download any number of files and web pages (multiple tabs)
at the same time and still lets you continue browsing. If a particular web page cannot be
downloaded, that is not going to stop the web browser from downloading other web pages.
2. Web Servers - A threaded web server handles each request with a new thread. There is a thread
pool and every time a new request comes in, it is assigned to a thread from the thread pool.
3. Computer Games - You have various objects like cars, humans, birds which are implemented as
separate threads. Also playing the background music at the same time as playing the game is an
example of multithreading.
4. Text Editors - When you are typing in an editor, spell-checking, formatting of text and saving the
text are done concurrently by multiple threads. The same applies for Word processors also.
5. IDE - IDEs like Android Studio run multiple threads at the same time. You can open multiple
programs at the same time. It also gives suggestions on the completion of a command which is a
separate thread.
Example
of Java
program
using
multi -
threading.
References
• http://shyleshblog.blogspot.com/p/chapter-1.html
• https://www.guru99.com/cpu-core-multicore-thread.html
• https://www.tutorialspoint.com/operating_system/os_multi_threadi
ng.htm
• https://www.quora.com/What-are-some-best-examples-of-
multithreaded-applications
• https://www.tutorialspoint.com/java/java_multithreading.htm