Professional Documents
Culture Documents
Análisis Parallel and Distributed Programming With Pthreads and Rthreads
Análisis Parallel and Distributed Programming With Pthreads and Rthreads
Presentado por:
Luigi Davian Patiño Cardona
Cod: 1093539823
Presentado a:
Cesar Jaramillo Acevedo
Materia:
Sistemas Distribuidos
56 Distributed systems
• Single stream: In this case, a program uses only one thread to control its execution.
• Multiple flow: These are programs that use various contexts of execution to get your job done.
possible, this facilitates data entry into systems in real time, especially if this data comes from
different sources. In a multithreaded program you have the main thread of the program running,
who in turn it has other threads or parallel tasks running. A thread is defined as a single flow control
sequence within a program, in a program can have more than one control sequence or threads. A
thread it is a part of the program that runs independently of the rest.
Thread is the smallest unit of code that can be executed in a multitasking environment. The use of
threads allows the programmer to write more efficient programs, since threads allow optimizing
resources so important as better CPU performance by minimizing its downtime. inactivity. The use
of threads is very valuable in interactive network environments, since they allow to synchronize the
difference between the transmission speed of the network with the processing of the CPU. The
speed in the handling of the file system for reading and writing is slower compared to the speed of
processing of this data by the CPU, in this case the use of threads helps a lot. One of the important
reasons for the study of multithreaded scheduling is that it allows access to time resources Free of
CPU while performing other tasks. The figure schematically illustrates a one-wire program and a
two-wire program.
value_ptr must point to a data that exists after the end of the thread.
Overview of Rthreads
In operating systems, a thread or thread, thin process or thread is a sequence of very small,
chained tasks that can be executed by an operating system.
The destruction of old threads by new ones is a feature that does not allow an application to
multitask (concurrently). The different threads share a series of resources such as memory
space, open files, authentication status, etc. This technique allows you to simplify the design
of an application that must carry out different functions simultaneously.
A thread is simply a task that can be executed at the same time as another task.
Threads of execution that share the same resources, added to these resources, are collectively
known as a process. The fact that the execution threads of the same process share the
resources means that any of these threads can modify these resources. When one thread
modifies data in memory, the other threads access that data immediately.
What is specific to each thread is the program counter, the execution stack, and the state of
the CPU (including the value of the registers).
The process continues to run if at least one of its threads is active. When the process finishes,
all your threads have also ended. Likewise, now when all the execution threads end, the
process no longer exists, and all its resources are freed.
Some programming languages have design features expressly created to allow programmers
to deal with threads of execution (such as Java or Delphi). Others (the majority) are unaware
of the existence of threads and these must be created special library calls that depend on the
operating system in which these languages are being used (such as C and C ++).
Advantages of using threads
It takes less time to create a thread from an existing task than to create a new process.
· It takes less time to finish a thread than to finish a process.
· It takes less time to switch between two threads of the same task than to switch between
two processes (because resources do not change, for example)
· Communication (message passing for example) between threads of the same task is easier
than between different processes.
· When switching from one process to another, the operating system kernel has to intervene
for protection. When switching from one thread to another, since the resource allocation is
the same, there is no need for the operating system to intervene.