New multithreaded code for calculating longitudinal collective instabilities using computers with multiprocessors Page: 3 of 15
This report is part of the collection entitled: Office of Scientific & Technical Information Technical Reports and was provided to UNT Digital Library by the UNT Libraries Government Documents Department.
Extracted Text
The following text was automatically extracted from the image on this page using optical character recognition software:
THREADS
A thread is defined as a sequence of instructions to be executed within a programme.
Most programmes are single threaded code which consists of one thread of execution which
starts in main(). Before the invention of threads, the UNIX way of doing things in parallel
is to use the fork/exec model. This model spawned several processes each a thread of
execution which can then be run in parallel. However, each new process that is created
by fork/exec require the operating system to make a child process from its parent process
by copying over the instruction, user-data and system-data segments of the parent and
then executing the child process as well as the parent process. This method is expensive
because of the overhead required for each process creation. Furthermore, communication
between parent and child need external channels like pipes, sockets, memory maps (mmaps)
etc. because resources held by parent and child are private and neither parent or child can
peek into each others resources without using these mechanisms. The fork/exec model can
therefore be thought of as many processes each having its own thread of execution.
Contrast this with a multithreaded programme where there is one process with many
threads of execution. This means that different parts of the same code can be executing
in parallel. The advantages over fork/exec are immediate : all threads share the same
resources and the overhead of creating a new process is eliminated. The downside is that
because all threads share the same resources, there must be software mechanisms, like locks
and semaphores, which preserve the integrity of the data and prevent race and deadlock
conditions. For example, suppose there are two threads A and B which use a piece of shared
data. At some point in the process, thread A updates the data, so thread A must prevent
thread B from reading the data before thread A completes the update, i.e. prevention of a
race condition. Furthermore, if a situation arises where thread A cannot finish the update
unless thread B reads the data then we have a deadlock condition. This means that our
3
Upcoming Pages
Here’s what’s next.
Search Inside
This report can be searched. Note: Results may vary based on the legibility of text within the document.
Tools / Downloads
Get a copy of this page or view the extracted text.
Citing and Sharing
Basic information for referencing this web page. We also provide extended guidance on usage rights, references, copying or embedding.
Reference the current page of this Report.
Tan, Cheng-Yang. New multithreaded code for calculating longitudinal collective instabilities using computers with multiprocessors, report, January 30, 2001; Batavia, Illinois. (https://digital.library.unt.edu/ark:/67531/metadc715219/m1/3/: accessed April 24, 2024), University of North Texas Libraries, UNT Digital Library, https://digital.library.unt.edu; crediting UNT Libraries Government Documents Department.