Rochester Institute of Technology
RIT Scholar Works
Theses
Thesis/Dissertation Collections
1989
The Task distribution preprocessor (TDP)
Frank McCanna
Follow this and additional works at:
http://scholarworks.rit.edu/theses
Recommended Citation
Approved b}':
Tilt' Rochestu
Inslltutr
of TKhnoloc.\'
School of
Computu
Scltn~
Tht' Task Distribution
P~procnsor
(TDP)
by
Fronl
McCOMO
A thesis, submined to
1nt
Faculty of tht School of Computer Science.
in
paniaJ fulfillment of tht requirements for tht degree of
Master of Scienet
in
Computer Science.
Dr.
P~urLun
Dr. Andrnf' KilcMn
Peter Anderson
TITLE OF THESIS:
The Task Distribution Preprocessor
I, Frank McCanna, hereby grant the Wallace Memorial Library, of RIT,
and all other persons or institutions, permission to reproduce the
material contained in this thesis document.
I make no restriction
against use of reproductions of all or part of this thesis for
commercial use or profit provided that proper credit is given to
the original author of the material.
Frank McCanna
Date:
---"""""-+-'~-r-""""'-+---Abstract
This document
describes
a software processor used to generate portable andefficient multiprocess programs that run on UNIX operating systems. The processor is
designed tobea convenient methodfor converting single process Cprograms into distri
buted multiprocess C programs. Another goal is to have the processor used as a
"back"end
or "platform" for multitasking languages andcode generators.Efficiency
istargeted toward multiprocessor systems that provide facilities for sharing physical
memory between processes running on separate CPUs.
Portability
is achieved with theuse ofthe
highly
portable UNIX operating system and itscompanionC
language. The Clanguage is used asboth theinput andoutputlanguage fortheprocessor. UseofC as an
object language gives portability to the generated multitask program.
Using
C as aninput
language,
simplifies the interface withmultitasking languages and code generatorsas well as minimizing changes necessary when converting C
language
single task programs tomultitask programs. Initial implementation oftheTask Distribution Preproces
sor will generate
C
codethatcan becompiled andrunonany UNIXsystemthatprovidesmessagepassing facilities.
The Task
Distribution
Preprocessor(TDP)
-nAcknowledgements
My
thanks to Dr. Peter Lutz and Dr. Andrew Kitchen fortheir support andideas. Ialso want to thank my wife
Anju
S.McCanna,
for suggestions concerning the writingstyleofthe "Purpose" section intheintroductionto thisdocument.
Key
Words
andPhrases
Key
Words in this document include:Language, Parallel, Distribution,
Concurrency,
Multiprocessing, C,
Preprocessor.Key
Phrases inthis document include:Multiprogramming
Languages,
C Preprocessors,
Multiprogramming
Platforms.The Task Distribution Preprocessor
(TDP)
- iii -TableofContents
Table of
Contents
1
INTRODUCTION
ANDBACKGROUND
11.1 Purpose 1
1.2 Previous Work 4
2
PROGRAMMING OPTIONS
18
2.1
Specifying
aTask 182.2
Specifying
Shared Data 182.3 Unshared
Memory
192.4 Stack
Memory
202.5
Library
Functions 202.6
Synchronizing
Tasks 212.7
Building
As A Single Task 242.8 Second Level
Modularity
Conflicts 242.9
Other Synchronization Constructs 273 PROCESSOR SPECIFICATION 29
The
TaskDistribution
Preprocessor(TDP)
- ivTableof
Contents
3.1 TDP
Processing
Diagrams
29
3.2 TDP
Processing
Description
313.3 Processor Design 36
3.4
Achieving
Data Alignment 364 RUNTIME PLATFORM 43
4.1 Runtime Description 43
4.2 Runtime Diagrams
55
4.3 TDP Runtime
Library
585 VERIFICATION AND VALIDATION 60
6
CONCLUSIONS
626.1 Problems EncounteredandSolved 62
6.2 System Deficiencies 62
6.3 Suggestions for Future Extensions 62
6.3.1
Limiting
theTransferofData 62The Task Distribution Preprocessor
(TDP)
Table
ofContents
6.3.4
Exec()
Overhead
Reduction 656.3.5 Detectionof
Inefficient
RemoteCalls 676.3.6
DynamicLinkage
686.3.7
Full Code Duplication69
6.4 Related
Thesis
Topics fortheFuture 706.4.1
Automatic
TaskGenerator70
6.4.2 Portable
Multitasking
Languages 717 BIBLIOGRAPHY 73
APPENDIX A: Example Program- InputtoTDP 78
APPENDIX B: Example Program-
Output
ofTDP 81APPENDIX
C:
Running
the Example Program 92APPENDIXD: Walk-Through for Example Program 93
List ofFigures
Figure 3-1 ProgramLoad Module CreationwithoutTDP
29
Figure 3-2 Multiple Load Module Creation
Using
TDP30
The
Task Distribution Preprocessor(TDP)
-viTable
ofContents
Figure
4-1Communication
withtheFork Server49
Figure 4-2 Creation
ofChild
Task 50Figure 4-3 Tightly-Coupled Configuration 51
Figure 4-4 Child Task Termination 53
Figure 4-5
Loosely-Coupled
Run Time System 55The Task Distribution Preprocessor
(TDP)
- 1-1 INTRODUCTION AND
BACKGROUND
1.1 Purpose
The Task Distribution Preprocessor
(TDP)
is a programming system for multipleprocess programs. TDP is designed to provide maximum efficiency and portability in
multipleprocess programs running on
tightly
coupled multiprocessorUNIX systems. A"tightly
coupled"multiprocessor systemis one whichprovides parallelism intheexecu
tion ofkernel code but maintains a single file system and controlling operating system
[BAC]. The efficiency ofthe TDP system also depends on amultiprocessor systemthat
allows thesharing of physicalmemory betweenuserprocesses.
Along
with efficient useof
tightly
coupledmultiprocessors, a major goalforthe TDPsystem, is thatmultiprocessprograms be able to run on any hardware platform running the UNLX operating system.
Portability
inTDP,
will allow the use of inexpensive systemsduring
multiprocessorapplicationdevelopment andallow easein portingtheseapplications tonewhardware.
Revision E Version 1
The Task
Distribution
Preprocessor(TDP)
2-Section
1.1 PurposeThe Task Distribution Preprocessor essentiallyprovidesparallel constructs to the C
language
[KER]
without changing thelanguage.
There is only oneTDP provided function to synchronizeparallel code. Data sharing isprovided
by
putting all static dataintoshared memory.
Why
a task distribution preprocessor? What makesthe multitasking platform generated
by
TDP differentor superiortoothermultitaskingplatforms? Themostimportantdifference
is
that the output (andinput)
toTDPis standardC
code that canbe compiledon any UNIX system. Withthe success of
UNIX,
bothindustry
andacademia haverealized the importance of software portability [LAP]. It is
becoming
so important thatsoftware development is very often done using UNLX and the C language for no other
reason than for portability. C is very often chosen over other portable high level
The Task Distribution Preprocessor
(TDP)
- 3-Section
1.1 Purposerun onthe newUNIXplatfonn. Oftenan application canbe running onanew platform
the same
day
aUNLX kernel isportedto theplatform[BOD].If efficiency can only be realizedwith
tightly
coupled multiprocessor systems, thenwhat good is the portability?
Very
simply, TDP processed applications will bedeveloped (formultiprocessor systems) onsingle CPUsystemsbecause single CPU sys
tems are cheaper. Software development for multiprocessor systems can proceed on
cheap reliable single CPU systems and then moved to target multiprocessor machines
when the software has been
thoroughly
debugged and verified. When the time comesthat
tightly
coupled multiprocessor systems are commonplace, portability between themakes and models ofthesemachines will alsobevery important.
Is portability and efficiency really so important that TDP be used instead of more
appropriate parallel programming languages? TDP can, of course, be used
by
C programmers to generate parallel programs, but TDP can also be effectively used as an
object
"language"
for other high level multitasking languages. Other high level
languages will
"inherit"
the portability and efficiency of TDP
by
"compiling" theirRevisionE Version 1
The
TaskDistribution
Preprocessor(TDP)
- 4-Section
1.1 Purposesource code
into
C code thatcanthenbeprocessedby
TDP.1.2 Previous Work
Much of TDP is
based
on the remote call concepts presentedby
Nelson[NEL1,NEL2],
summarizedby
Hamilton[HAM]
and implementedby
Birrel & Nelson[BIR]. Aremoteprocedurecallis best described inthewordsofBirrel& Nelson:
"The idea of remote procedure calls (hereinafter called
RPC)
is quitesimple.It is based on the observationthat procedure calls are a well-known and
well-understood mechanism for transfer of control and data within a program run
ningon a single computer.
Therefore,
itisproposedthat this samemechanismbe extendedtoprovide fortransferof control anddataacross acommunication
network."
[BIR]
Birrel & Nelson omitted two major features from their implementation that have been
addressed
by
TDP. The twofeatures are sharedmemoryand parallel or"asynchronous"The Task Distribution Preprocessor
(TDP)
5Section
1.2 Previous Work"In summary, a shared address space between participants in RPC might be
feasible,
but since we were not willing to undertake that research our subsequent design assumes the absence of shared addresses. Our intuition is that
with our
hardware
the cost of a shared address space would exceed the additionalbenefits."
[BIR]
In
fact,
mostimplementations
ofRPC do not provide shared memory. With theabsence ofshared memory
facilities,
remote procedure calls arelimited to call-by-valueor
"copy-in/copy-out",
no addresses as arguments or indata,
can be shared across theRPC. This restriction may seem
inordinately limiting
but for some systems this limitation provided a simplicity that was very attractive. The main attraction was for use of
this scheme for heterogeneous distributed systems. Falcone
[FAL]
found Birrel &Nelson'sschemetobe very appropriatefor his
Lisp
[LIS]
basedlanguage
for heterogeneousdistributedsystems.
The original goal ofTDP was to simply add shared address space for a Birrel &
Nelson - likeremote call implementation using standardUNLX andthe
C language.
Theimplementation was to be similar, but more flexible than an
implementation
by
GlasserRevisionE
Version
1The
Task Distribution Preprocessor(TDP)
-6
-Section
1.2 Previous Work[GLA1,GLA2]
that copied data referencedby
pointer arguments. The goals wereexpandedto
include
parallel or "asynchronous" remote calls and an efficient implementation for tighdy-coupled multiprocessor environments when the importance of this
hardware
platformbecame
apparent.LiketheBirrel& Nelson RPC system,TDPallows aprogramto alternately runas a
single process or multiple process program without changing the source code. Birrel &
Nelsonprovide this capability
by linking
in function "stubs" forremote functions whena program is built. The function stubis simply afake definitionforafunctionthat, when
called, will interface with a run-time system that provides for remote execution ofthe
real function. Withoutthe function stubs, theprogram can run as a single process. With
the stubs, the program is a multiple process distributed program. TDP provides this
capability
by
processing thesource code and replacing remote calls withcalls that interface with a run-time systemthatprovides remote execution. Without TDPprocessing, a
The Task
Distribution
Preprocessor(TDP)
- 7Section
1.2 Previous Workprograms to utilize the advantages of multiple threads of execution while retaining a
vehicle forsimplified
debugging
witha single process versionofaprogram.Forparallelism and synchronizationwithsharedmemory,TDPhas taken theimple
mentation restriction adopted
by
theAda language [REF]. The restriction adoptedisthatshared memory is onlyguaranteedtobeupdated at program synchronization points. This
restriction was adopted so that TDP could easily provide shared memory for either
loosely-coupled or tightly-coupled multiprocessors but retain high efficiency in a
tightly-coupled environment. A quote from an article
by
Mundie & Fisherdiscussing
Ada,
gives avery complete accountoftheissue:"Shared Memory. Another issue
facing
process-modellanguages
isthedichotomy
between shared-memory systems and message-based systems. If thelanguage assumes that the parallel processors share memory, then it is con
venient and efficient to usethat shared memory for interprocess synchroniza
tion andto allow multiple processes accesstosharedvariables.
However,
thatapproach virtually precludes extending the parallel processing scheme to
loosely
coupled networks, which lack shared memory. Message-based systems, on the other
hand,
incur a substantial run timeperformancepenalty, butare more general inthat
they
canbe usedinawiderrange of configurations.RevisionE
Version
1The
Task Distribution Preprocessor(TDP)
- 8-Section
1.2 Previous WorkAda
rendezvous provides adiplomatic
compromise between these twoenvironments. Multiple tasks can access shared variables, but in a restricted
way that allows for
loosely
coupled systems.Updating
is guaranteed only atsynchronization points, so that shared variables can in fact reside in separate
memorieswithcopies passedbackandforth only
during
rendezvous."
[MUN]
TDP takes a similar approach and uses shared physical memory if available and
aligned copies ofmemory in loosely-coupled environments.
Taking
thephilosophy thatmemory is only guaranteedtobe updatedat synchronization points allows the
flexibility
for efficient implementation ontightly-coupled machines without precluding implemen
tationonloosely-coupledmachines.
Compatibility
betweentightly-coupledandloosely-coupledenvironments alsohas avery important role for many multiprocessor systems. We often like to categorize a
machine as either tightly-coupled or loosely-coupled but in reality multiprocessor sys
The Task
Distribution
Preprocessor(TDP)
-9
-Section
1.2 Previous Work"loose"
coupling
of processor groups. TheButterfly
GP1000
producedby
BBNAdvanced
Computers
Inc. ofCambridge
Massachusetts
is
a case in point [RUS].Currently,
theButterfly
GP 1000 can have a maximum of 256 processors sharing thesame physical memory.
Building
a configuration comprising more than 256 processorsrequires thatportionsofthe system communicate via a communication network. A sys
tem made up of several
Butterfly
GP
1000 machines wouldhave
both tightly-coupledcomponents and a loosely-coupled component.
Ideally,
run time support for such aconfiguration would make crossing the loosely-coupled component invisible while still
allowing maximum efficiency in the tightly-coupled environment.
Favoring
thetightly-coupled environment for efficiency
is based
onthe assumptionthatwith more andmoreprocessors available in each tightly-coupled unit, therewill be fewerand fewer applica
tions that will require crossing a loosely-coupled
boundary
to access processing units.Because applications will primarily function usingthe tightly-coupled component ofthe
system,maximumefficiency
is
targetedtothatenvironment.Use of an unaltered
C
language as the source language forthe TDP system shouldbring
maximumportability andutility to thesystem.Hopefully,
using apopular and wellRevisionE Version 1
The Task Distribution Preprocessor
(TDP)
10-Section
1.2 Previous Worksupported
language like
C will allow TDP to be easilyinterfaced
to existing applications and code generators.
Going
with standard C as theinput
language,
a number ofparallel
implementations
oftheC language were exploredforpossibleuse as abasis forTDP.
The first parallel C
implementation
considered is "Refined C"implemented
by
Dietz & Klappholz [DIE2]. This
implementation
is based on concepts presented in anearlier paper
by
the same authorsdescribing
how any conventional sequential languagecan be "refined" to provide parallel constructs [DIE1]. Dietz & Klappholz correctly
identified
the three most difficult constructs to deal with in changing a sequentiallanguage intoaparallellanguage:
'
'References
toglobaldata: sincethecomplexityof certainanalysis techniquesrequires flow-analysis tobe localized to small regions ofaprogram, the
flow-analysis is forced to make the "safe" assumption that every function and sub
routine call might altereveryglobal variable.
The Task
Distribution
Preprocessor(TDP)
- 1 1Section
1.2 Previous WorkReferences to
indexed
data structures: since it can be difficult to determinewhich element(s) of a data structure an indexed reference can access, it may
again be necessary to assume that such a reference potentially touches the
entire
structure."
[DIE2]
Refined
C
introduces aconstmct called a partition to replace global memory and aconstruct called an environment to specify limited access to data. There are two major
reasons thatRefinedC wasnot chosen as a model. The first is thatelimination of global
memory and data structures as
they
are normally presented in C programs is a majorchange to the language.
Changing
Cdramatically
dilutes arguments for using it in thefirst place. Ifanon-standard source language is acceptable, thenusing a
highly
expressivedistributedprogramminglanguage like SR
[AND],
MML[BOA]
orLinda[AHU]
isa more desired approach. The second problem with Refined C is that partitions are
implemented withtheuse of an addedlayerofindirectionfor referencing memory. Dou
ble indirectionto fetchdataisa valid approachfor heterogeneous distributed systemsbut
is
unacceptably inefficient forprogramdistribution among homogeneoussystems.Revision E Version 1
The Task
Distribution
Preprocessor(TDP)
- 12-Section
1.2 Previous WorkThe
Concurrent
C language presentedby
Gehani & Roome[GEH]
was also discarded as a model becauseof extensive changesto the
C
language. This implementationalso had the added
disadvantage
of not providing shared memory facilities. In Concurrent
C,
shared memory is left for the C programmer to implement as described in aquotefromthearticle
describing
thelanguage:"Some final comments about sharedmemory are inorder. First and
foremost,
we wantedConcurrent Cto allow (and encourage)programmersto write port
able programs that will run efficiently on multiprocessors with or without
shared memory. This
is
why we choose a message-passing model, and whywehavenot addedany language constructsfor
dealing
withsharedmemoryorfor simulating shared variablesinanon-sharedmemory
environment."
[GEH]
Leaving
theimplementationof sharedmemoryentirelyto theprogrammer andencouraging
the use of a message passing model for shared memory is unacceptable for thetightly-coupledmultiprocessorenvironmentstargetedfor TDP.
The Task
Distribution
Preprocessor(TDP)
13-Section
1.2 Previous WorkAlthough monitor accessto sharedvariablesprovidestheabstractionnecessary formul
tipleprocess programs in
loosely-coupled
environments, thislanguage implementation isinefficient fortighdy-coupledsystems.
Always
accessingglobalmemory throughamonitorwill also
force
majorrestructuring in sequentialC
programs that are to beconvertedtomultiple process programs.
Aparallel implementationoftheC languagepresented
by
Sonnenschein[SON]
provides shared memory and synchronization with the use ofports and signals. Ports are
special global shared memory that is referenced like any other memory but cannot be
referenced until specifically assigned to a particular process. Signals are used to syn
chronize the assigning of ports and special functions assign() and release() are used to
gain or relinquish access to a port. Objections to this implementation are two fold. One
is that signals andports are implemented
by
adding reserved words to the C language.Although the change to the language is not as profound as Gehani & Roome 's Con
current
C
and Dietz & Klappholtz's RefinedC,
the language is changed to the degreethata standard
C
compiler could notbeusedtocompile thesource code. Theother problem is that there is no provision for more than one process to simultaneous access a
Revision E Version 1
The Task
Distribution
Preprocessor(TDP)
14-Section
1.2 Previous Workparticular port memory. Shared memory is always of a restricted nature, real-time
simultaneous accesstosharedmemory is expressly
forbidden.
Binding
[BIN]
presents a parallelimplementation
oftheC language that allowsthesharing ofall globalmemorywithoutrestriction. The C
language
is essentiallyunalteredsatisfying anothergoal for the TDPenvironment. In Binding'sparallel
C,
parallelism isonly simulated; all program tasksreside ina single UNIXprocess. Contextswitchesare
not
"preemptive";
a program mustexplicitly relinquish control ofthe CPUby
calling a"ContextSwitchO"
function. A similar implementation
by
Cormack[COR]
allowspreemptivescheduling butalso simulates parallelism insidea singleUNIXprocess. Both
Binding's and Cormack's implementations provide a model very close to what is pro
vided
by
"light"
processes or program
"threads"
[RUS]
providedby
manymultiprocessor operating systems. Programs using the
Binding
or Cormack implementations couldbe easily upgraded to utilize the
"light"
process primitives ofmany ofthese multipro
The Task Distribution
Preprocessor(TDP)
15
-Section
1.2 Previous Workimplementations
invisible
toanapplication, thatapplicationwill bemuch more portableacrossvarying processor configurations.
Currently,
very few UNIXimplementations
provide "light" processes;
therefore,
exclusive use ofthem,
wouldimpacttheportabilityofthe system severely. It is also hoped that the performance impact in the creation of
"heavy"
processes canbe
lessened
tobe very near theperformance impact forthecreation of a program "thread" or "light" process.
However,
because the development of"light"
processes in multiprocessor systems is very
important,
nothing in the design ofTDPwill preclude the use of threads in combination with TDPto achieve performance
andportability benefits in both
loosely
andtightly
coupled environments. The design ofTDPwillalso not preclude theuseofprogram"threads" toimplementtheTDPruntime
system if in the future threads become a standard feature of all UNLX and UNIX-like
operating systems and can provide parallelism and shared memory across
loosely-coupled anduncoupled networked distributedsystems.
Due to the special goals for TDP that could not be satisfied
by
any publishedversion of a parallel C
language,
TDP design went in acompletely new direction.Adding
reserved words to the language to specify parallel or remote functions reduces the
Revision E Version 1
The Task
Distribution
Preprocessor(TDP)
16-Section 1.2 Previous Work
portability ofthe source code and does not lendwellto conversion
between
single andmultiple process versions ofthe program.
Adding
reserved words would also eliminatethe possibility of
having
a single process version of a program, compiled withoutTDP,
using a standardC compiler.
Therefore,
to specify parallelism, TDPusesthe modularization feature ofthe C language. The feature of separate module compilation is used
by
TDPtodefinewhat source codewillreside in separatetasks. Asingle source file defines
aprogramtask thatwill runas a separateUNIXprocess.
Using
the C preprocessor's #includedirective,
program modularization can beachieved on several levels. Aprogram can use modularization forseparate compilation
and information
hiding
as usual,by
separating source code into separate files. To buildthe program using
TDP,
"task" source modules can be created that have nothing but#include directives that gather together source modules that comprise a task. These
"task"
source modules are the source modules input to TDP. Because TDP runsthe C
preprocessoronall source modulesbeforeprocessing, the
"task"
TheTask
Distribution
Preprocessor(TDP)
17
Section 1.2 Previous Work
Shared memory in TDP processed programs, requires no specification
by
the userbecause all static memory is shared. All static memory is also aligned sothat one copy
of static memory can be shared
by
all program processes without pointer conflicts.Because TDP design is expressly aimed at tightly-coupled multiprocessor environments,
thisradicaldesigncanbeused withthebenefitofhigh efficiency forthe targetplatform.
RevisionE Version 1
The Task
Distribution
Preprocessor(TDP)
18-Section 2
PROGRAMMING OPTIONS
2
PROGRAMMING OPTIONS
2.1
Specifying
aTask
Aprogrammerinforms TDP that certain
functions
are to bepart ofa separate programtask
by
puttingthedeclarations forthese functions ina separateC source file. TDPassumes that the code ineach C source file is code thatwill reside in a separate process
fortheprogram.
When converting single process C programs toTDP multiprocess programs, func
tions should be rearranged in the source files so those that can run in parallel are in
separate files. Because TDP runs the C preprocessoron all source files beforeprocess
The Task
Distribution Preprocessor
(TDP)
. 19.Section
2.2Specifying
Shared
Data2.2
Specifying
Shared Data
All static memory in aprogram except that which is declared in a
library
function,
willbe sharedbetweenprogramtasks.
Any
changestostaticmemorywill bereflectedinall tasks. Not sharing
library
function
static memory allows the proper execution ofmany standard UNLX
library
functions that are not designedto be re-entrant.Any
datadeclarations
precededby
the C reserved word"static",
will also be shared but only thetask thatdeclared itwillhaveaccessto thelabel
describing
thedata.String
data falls intothe same category as local static memory. All string data is shared betweentasks. Be
causelocal static memory andstring data is also aligned,pointers to thismemory can be
passedbetweentasks.
Revision E Version 1
The Task Distribution Preprocessor
(TDP)
-20
-Section 2.3 Unshared
Memory
2.3 Unshared
Memory
To declare memory that is not shared, a programmer must declare an automatic
variable or call malloc() or sbrk() to get
dynamically
allocated memory. Pointers tounsharedmemory cannotbesharedbetweenprogramtasks.
2.4 Stack
Memory
The stackmemory foreachtaskis notshared, any alterations to stack memorywill
not be reflected in other tasks.
Therefore,
pointers to automatic variables must not beThe Task
Distribution
Preprocessor(TDP)
21Section 2.5
Library
Functions2.5
Library
Functions
Library
functionsarelinked intoprogramtasksasthelast step in creating individualtask modules.
Every library
function
that is used in the entire program is linkedinto
EVERY task module whether a particulartask calls that function or not. This prevents
dataalignment problems caused
by
static memory declared inside alibrary
function. Ifonetasklinked ina
library
functionthatdeclaredstaticmemory, and another taskdidnotlink in that
function,
the static memory maydestroy
the memory alignment ofthe twotasks.
Static
memory declared inlibrary
functions is the only static memory in a TDPcreatedprogramthat is not shared. Not sharing
library
functionstatic memoryallowstheproper execution of many standard UNIX
library
functions that are not designed to bere-entrant.
Revision
EVersion
1The Task
Distribution
Preprocessor(TDP)
- 22-Section
2.6
Synchronizing
Tasks2.6
Synchronizing
Tasks
When the user calls afunction that is defined in another source
file,
he/she is starting
aparallel task. The remote functioncall will return a child task descriptor and thisdescriptor can be used to wait for the child task at any point in the execution of the
The Task
Distribution Preprocessor
(TDP)
. 23-Section 2.6
Synchronizing
Tasksfuncl()
{
int child_descr; intretval;
child_descr=
func2();
parallel code
retval=
TDPwait(child_descr);
}
funcl()
andfunc2()
are defined in separate source files andthe code betweenthe call tofunc2()
andTDPwait(),
is code thatwillbeexecuted inparallel withthecode in func2().Thereturn value of
func2()
isreturnedfrom TDPwait().TDPwait()
is identical to theab-sorb() function in the parallel
C
implementation presentedby
Cormack [COR]. Thechilddescriptor is avalue thatis uniqueto aparticular call andis different for every call
evenifmultiplecalls are made to thesamefunction.
If
by
the timeTDPwait()
is called, the child task has alreadyterminated,
thenTDPwait()
simply returns thevalue returnedby
theremote function. Ifthe child task isstill running when
TDPwaitQ
is called, the parenttask will be suspended until thechildRevision E Version 1
The Task
Distribution
Preprocessor(TDP)
24-Section 2.6
Synchronizing
Taskstask terminates. The call to
TDPwait()
can beanywhere intheparent task andit isnotnecessary to call
TDPwait()
at all.There is nothing
in the TDP platform that requiresthata parent taskwait for
its
children.Children
canterminatelong
aftertheirprogenitorshaveterminated.
2.7
Building
As
A
Single Task
An application that uses the
TDPwait()
function can be built and ran without TDPby
simply creating a function calledTDPwait()
that returns its argument. The returnvalue of a function would simply be passed through the
TDPwait()
function unaltered.This may be usefulifthereis a suspected
bug
intheparallelconstructs of a programorifit is
desiredto use a debugger that can only function on a single process version of theThe Task
Distribution Preprocessor
(TDP)
-25
-Section 2.8
Second
LevelModularity
Conflicts
2.8 Second Level
Modularity
Conflicts
It
is
expected that some programmerswill define TDPtasksby
simply creating filesthatinclude groups offiles for aprogramusingtheCpreprocessor#include directive. If
aprogram sourcefile is normally compiledseparately but isnowmergedwithother
files,
anumber ofconflicts can arise:
1)
Two source modules that are normally compiled separately may have a variable with the same name declared with the keyword "static" outside of a
functiondefinition (therefore giving itscopefortheentire source file). Ifthese
two source filesweremerged together,thevariable wouldbe multiply defined.
TDPsolvesthisproblem whenitrenames all variablesdeclared withthe "stat
ic"
keyword. Each declarationofthestatic variable wouldbe givena separate
newnamewhenmovedto theglobaldata
file,
thereby
resolving theconflict.Revision E Version 1
The Task Distribution Preprocessor
(TDP)
- 26-Section
2.8
Second
LevelModularity
Conflicts
2)
The scope of afunctionnamecanalsobe restrictedto a single source file usingthe "static" keyword when the function is declared. It is possible that two
source
files
may use the same "static" function name and ifthe two sourcefiles were merged the functionwouldbe multiply defined. TDP will generate
an errormessage and terminate processing ifthis problem occurs. It is up to
the programmer to choose a separate name for multiply defined functions in
thissituation.
3)
Each source module thatis normallycompiled separately willhave its own setof#include statementsforstructuredefinitions and manifest constants. Ifthese
source files are thenmerged withothers, many#include statements willbe du
plicated. TDP defines the manifest constant
"TDP"
sowhen there aremulti
ple #include statements
they
can be surroundedby
conditional preprocessordirectives:
The Task Distribution Preprocessor
(TDP)
- 27 -Section2.8Second
LevelModularity
Conflicts4)
A manifest constant canbe
given one value inone sourcefile
and a differentvalue in another. Ifthe two
files
are merged theremay be aconflict. Some Cpreprocessors allow redefinition of amanifest constant, but for those that do
not, aprogrammer shoulduse the#undefpreprocessordirective attheend ofa
sourcefile formanifestconstantsthatmay conflict.
R "
'nn F Version 1
TheTask Distribution
Preprocessor
(TDP)
28
-Section
2.9
Other Synchronization Constructs
2.9 Other
Synchronization
Constructs
TDPwait()
is the only TDP function provided to synchronize parallel tasks. If aprogrammer needs more elaborate communicationorsynchronization between tasks, the
entire UNIX C
library
is
at the programmer's disposal. Because TDPprocesses are trueUNIXprocesses, any UNIX system callthat can be usedto synchronize separate UNLX
processes canbeusedtosynchronize TDPtasks. TDPreservesfor its ownuse, only one
message queue identifier and one signal. BothTDP's message queue identifierand sig
nal numbercan bechanged
by
the usertoeliminate conflict with theiruse ina particularThe Task
Distribution
Preprocessor(TDP)
Section3
-29-PROCESSOR SPECIFICATION
3
PROCESSOR
SPECIFICATION
3.1 TDP
Processing
Diagrams
Figure
3-1 Program
Load Module Creation
withoutTDP
The Task
Distribution
Preprocessor(TDP)
Section 3.1
30-TDP
Processing
DiagramsFigure 3-2 Multiple Load Module
Creation
Using
TDP
TheTask Distribution Preprocessor
(TDP)
. 3 1Section 3.1 TDP
Processing
Diagrams
3.2 TDP
Processing
Description
TDP accepts as
input,
all the C source files that comprise a program. TDP willassume that each source file is to be a program task. A program task process will be
started whenever one of the functions defined in the
task,
is calledby
a function inanothertask.
TDP processes the source files in two passes. Before the first pass, all the source
code isprocessed
by
the Cpreprocessor (cpp). TDP processing inpass oneproceeds inthe
following
manner:o If TDP encounters afunction declaration in asource
file,
thefunction name and itsarguments are savedinalinked list for later reference. Thename ofthe fileandthe
numberofthefunction declaration isalso storedfor laterreference.
Revision
E Version 1The Task Distribution Preprocessor
(TDP)
32-Section 3.2 TDP
Processing
Descriptiono If TDP encounters a string constant, the string
is
saved in a linked list to be laterusedtoinitialize anarraythatwillcontain thedata forallstringsintheprogram.
o If the C reserved word "static" is encountered, TDP saves the declaration to be
usedlater in a globaldeclarationthatwillreplace thestatic variabledeclared.
When all theprogram's source files have beenread, TDPoutputs an array declara
tionthatwillreplace all thestring constants encountered intheprogram. The stringcon
stants in theprogram will be replaced
by
offsets into this string array. Declarations arealso generated for variables that will be used to replace the static variables in the pro
gram. Uniquenames are chosenforall static variables simply
by
appending thevalue ofa counterto aunique string. The declarations are all outputto the singleTDPgenerated
globaldata file.
TheTask Distribution Preprocessor
(TDP)
. 33-Section3.2 TDP
Processing
Descriptiono If aglobal declaration
is
encountered, itis
appended to the single data file for theprogram. Ifthe declaration
does
not have aninitializer,
it is givenone. Initializersare giventoprevent misalignmentthatwouldoccur when uninitialized static data is
put intheBSSsectionof memory.
o Ifalocal static variable declaration isencountered, a "#define oldname
newname"
is appended to the task output file. The "oldname" is the original identifiername
in the task input file and the "newname" is the replacement name given to the
static variable inpass one. When the end ofthe current block is encountered, (i.e
theendofthe scopeofthevariable) a "#undef
oldname"
is appended to theoutput
file.
o Ifastring constantis encountered, itis replaced withapointer offsetinto the string
array that was put into the global data file after pass 1. The correct offset into the
string array forthisstringconstant was calculatedinpass 1.
o When a function call is encountered, TDP looks to see ifthe function declaration
Revision E Version 1
The Task Distribution Preprocessor
(TDP)
- 34-Section 3.2 TDP
Processing
Descriptionwas encountered in pass 1. Ifthe
function
callis
notdefined
in theprogram, thefunction name is put inthe list of
library
routine calls fortheprogram. Ifthe function call was defined but in a different task, the function name is put in a list of
remotefunctioncallsforthe task. Theremotefunctioncall isreplacedinthesource
file
with a callto a special TDPfunctionthatinitiates
a remotecall using the original function call arguments andthe functionnumber. The functionnumberforthis
functionwas assignedinpass 1 whenthefunction declarationwas encountered. No
information
is
saved for functions that are called anddefined inthe sametask;
thiscode willjust make anormallocal call. The code for alocal call is just echoed to
theoutputfile.
o Ifthefunction main()is encountered ina source
file,
TDPrenamesthefunction andrecords the fact the current task is the startup task forthe program. At the end of
this
function,
TDPwill output acall to a specialTDPexit()
function that allows theThe Task
Distribution
Preprocessor(TDP)
. 35.Section 3.2 TDP
Processing
Descriptiono Allcode not mentioned above, iscopied
directly
fromthe theinput sourcefile
to thetaskoutput file.
Ina separate
file,
TDP generates adeclaration for a global structurethatcontainsallinformation aboutthe functions defined intheprogram. Thisstructure is initializedwith
the taskname, function name, functionpointer and thesize offunction arguments. The
functionnumber
is
anindex intothisarrayoffunction structures.TDP also generates a single global structurethatcontains allthenecessary runtime
information about the program and about each particular task. This structure also con
tains apointerto alinked listthatdescribes eachinstance ofafunction callfora particu
lartask.
Both the function list and the run time global structure are kept in private static
memory.
Every
task hasits
own copy ofthese structures,they
are not shared betweentasks.
Revision E Version 1
The Task
Distribution Preprocessor
(TDP)
36
-Section 3.2 TDP
Processing
Description3.3 Processor Design
The TDP parser/code generator has a main() function that contains two loops that
operate on all the
files
onthe command line. The firstloop
is pass one oftheprocessorandthesecondispasstwo.
The scanner used
by
TDPis created usingthe UNIXutility lex. It has thecapability
to scan all C declarations and calls a numberof specialfunctions for parsing and output. The samescanneris usedfor bothpassoneand passtwooftheprocessor.
TDP parsingand output routines manipulatetwolinked lists. One linked listisused
The Task
Distribution
Preprocessor(TDP)
37
-Section 3.4
Achieving
DataAlignment
3.4
Achieving
Data Alignment
Toprovide sharedmemory
functionality,
TDPaligns global memory inall tasks sothat it can be accurately copiedfromtask to task without relocating memoryreferences.
TDPputs all thestatic data declared in aprogram intoa single source fileandcreatesthe
load modules for each task in such away as to give the static data identical virtual ad
dresses inallthe loadmodules fortheprogram. Datacanbe
directly
copiedbetweenthetasksin theprogram because all tasks operate on identicalcopies ofthe data. More im
portantly, shared physical memory is feasible because pointer values stored in memory
arevalidforall processes intheprogram.
To accomplish memory alignment there are some general characteristics ofUNLX
linker/loaders
upon whichTDP relies. When aUNIXlinker/loaderallocatesmemory fora program load module, the addresses assigned to code and data objects are virtual
Revision E Version 1
The Task Distribution Preprocessor
(TDP)
3g
. Section3.4Achieving
Data Alignmentaddresses. When memory is accessed
by
aprogram at runtime,
thevirtual pointer to avariable
is
remappedtoa physicalmemory
address.TDPputs all static data
declarations
into asingleC source file for a program. Thissource file is compiled and the object module is linked into every program task. This
assures that all static
data
will be placed in a single block ofmemory space in all programs. This block of
"memory
space"or
"section",
is not guaranteed to start at thesame address in all theprogramtasks.
Typically
thelinker/loaderwill putthis datasection after the code section in virtual memory. The exact placement ofthe data section
variesfromsystemtosystembutwill alwayspartially dependonthesize ofthe code sec
tion. Thismeans
that,
althoughthe dataobjects are the samedistance fromeachotherineach
task,
the addresses are still different in everytaskdepending
onthesize ofthecodesectionforthat task. To achievedataalignment, thevirtual addresses ofthedatamustbe
shifted sothat the virtual address ofthestartofdataobjectsisthesame inalltasks. TDP
TheTask Distribution Preprocessor
(TDP)
39
.Section3.4
Achieving
Data Alignment
in the
data
section equal to thedifference between
thestarting
address ofthe modulewith that largest data section start address and the start address of the current load
module's
data
section. Thishole
inthedatasection shiftstheaddressesforthestaticdatainthe taskloadmodules sothat
they
allbeginatthesamelocation.The UNIX System V Release 3.0 Programmer's Guide givesacomplete description
ofhow to manipulate
load
modules using the Link Editor Command Language for thelinker/loader: Id. An iftle is afilewhichcontains LinkEditor Command Languagecom
mands to manipulate load modules. The
following
is the default ifile runby
Id whenexecuted on anIntel 80386 System V Release 3.X UNIXsystem:
RevisionE Version 1
TheTask
Distribution
Preprocessor(TDP)
. 49.Section 3.4
Achieving
Data Alignment
SECTIONS
.text
OxdO
:{ *(.init)
*(.text)
*(.fini) }
GROUP
BIND( NEXT(0x3ff000)
+((SIZEOF(.text)
+ADDR(.text))
%0x2000))
{
.data:
{ }
.bss :
{ }
Mostofthedetail in the code above is unimportantto this discussion but is included for
completeness. The meaning of each construct is explained in the UNIX System V
Programmer's Guide [UNI]. The
following
ifile is an example of one that was usedtobuild
one oftheload modules in aTDPprocessed program. Noticethatit is identical tothe
default
specification except for the increment value placed in the .data sectionTheTask
Distribution
Preprocessor(TDP)
. 41 .Section 3.4
Achieving
DataAlignment
SECTIONS
(
.textOxdO:
{ *(.init) *(.text) *(.fini) }
GROUP
BIND(
NEXT(0x3ff000)
+((SIZEOF(.text)
+ADDR(.text))
%
0x2000))
{
.data:
{
.+=0x318;
}
.bss :
{ }
Inthisparticular case, the "hole" inthe data section is 318
(hex)
bytes in length. Thisincrement
command will cause Id to start allocating data for declarations after skipping318
(hex)
bytes.By looking
atthis ifile we can surmise that there is aloadmodule forthis programthat has adata section with a start address that is 318
(hex)
largerthan thisload
module'sdatasection start address.Ifalink/loader onaparticular systemdoesnot provide a means for putting ahole in
Revision
E Version 1The Task DistributionPreprocessor
(TDP)
- 42-Section 3.4
Achieving
DataAlignmentthe data section, TDP will generate a
dummy
declaration
equal to the sizethat theholewouldbe. The declaration ismade sothatit isthefirst dataallocated
by
thelinker/loaderThe Task Distribution Preprocessor
(TDP)
-43
-Section 4
RUNTIME
PLATFORM4 RUNTIME
PLATFORM
Simply
aligning data is not all thereis
to the story, TDP must also provide anefficientmeans fortaskspawning and synchronization. A
library
of runtime routines islinked into all TDP processed program tasks. The TDP
library
serves to manage allaspects oftheTDPrun timeenvironment. The only visibleevidenceto the userthat this
library
isused,are calls that he/shemakesto theTDPwait()
functionthat allows aparenttask towaitforachildtask.
P . .
p Version 1
The Task
Distribution
Preprocessor(TDP)
. 44.Section 4. 1
Runtime Description
4.1
Runtime Description
TDPgenerates a programthat runsin the
following
manner:o To start a program, the user starts the fork server. The fork server does a
fork()
exec() to start the first
task,
then waits on amessage queue. A UNIXmessage issent to the fork server whenever a task calls a function in another task. Upon re
ceipt of the message, the fork server executes a
fork()
exec() according to thespecificationsinthe message.
Therefore,
thefork server istheprocess parent of allprogram processes.
0 Upon startupofthe firsttaskinthe system,anynecessary initialization isperformed
andtheprogram's originalmain()function(now renamed)is executed.
The
TaskDistribution
Preprocessor
(TDP)
-45
-Section
4.1 Runtime Descriptiono Ifa
library
function
iscalled, again, nothing unusual occurs; the task'scopy ofthe
function
is executedinthesame wayasina single processprogram.o If a program
function
is called that is defined in another task, thefollowing
sequenceisperformed:
1)
A special TDP function is called. TDP hasplaced a callin theprogram codethat appearsasfollows:
TDPcall(funcnum,arguments,
. . .);The funcnum is aconstantinteger representingthefunctionnumbercalculated
by
TDP. The arguments are the exact arguments placedby
the user for thisfunction call in the original source code.
During
preprocessing, TDP hasreplacedtheoriginaltextofthecall:
func(
with:
TDPcall(funcnum,
The TDPcallfunction is declaredusingthe variable parameter macros defined
by
the UNLX System V macro package varargs (see the UNIX System VProgrammer'sReferencemanual foracompletedescriptionofthesemacros):
RevisionE Version 1
The Task
Distribution
Preprocessor(TDP)
- 46-Section
4.1 Runtime DescriptionTDPcall(va_alist)
va_dcl
{
va_listpvar;
int
funcnum;
va_start(pvar);
funcnum=
va_arg(pvar);
The variable "funcnum" will be an index into the function list structure
placed
(by TDP)
intotheglobal data file.2)
TDPcall()
creates astringtobe sentina messageto theforkserver. The stringwill contain the target task name, the called function number, the instance
number ofthefunctioncall, thecurrentprocessidnumber, andthenameofthe
shareddata file.
The Task
Distribution
Preprocessor(TDP)
-47
-Section
4.1 Runtime Descriptiondescribing
all functions declared intheprogram. The function list'svalueforthe number of words for arguments
in
a particularfunction,
was determinedwhen the function declaration was parsed
during
program building. The following
code is executed inTDPcall()
to copy the function arguments into themessage
(Again,
a variable number of function arguments is extracted usingvarargs):
for
(i=0;
i<TDP.funclist[funcnum].numarg_words;
i++)
message.args[i] =
va_arg(pvar,int);
The variable
"TDP"
is the global structure that references all TDP run time
structures. The structure member
"funclist"
is the structure that contains
information
describing
each remote function. The structure member"numarg_words"
is the number ofmemory words needed to contain all the
function arguments for a particular function. The variable
"funcnum" was
assignedin step 1 withthe first argumenttoTDPcall(). The function va_arg()
is
the varargs macro that allowsextraction ofavariable number of argumentsinafunctioncall.
Revision E Version 1
The Task
Distribution
Preprocessor(TDP)
- 48-Section
4.1 Runtime Description4)
TDPcall()
copies all shared datato atemporary
fileor arranges forattachmentof shared physical memory, (attachment of shared physical memory is not
implemented in TDP Version 1.0).
TDPcall()
thensendsthemessage containing
the taskparameters andfunctionarguments to theforkserver.5)
After sending the UNIX message to the fork server,TDPcall()
returns achildprocessdescriptorto thecaller. Thechildprocessdescriptoris usedlateras an
argument to the
TDPwait()
function. The calltoTDPwait()
allows theparentThe Task
Distribution
Preprocessor(TDP)
Section
4. 1
-49-RuntimeDescription
6)
Upon receipt of a UNLX message, the fork server executes aforkQ
and theparentforkserver process waits again onthemessagequeue.
Figure 4-1 Communication
withthe
Fork Server
Task Name Function Number
Instance Number ParentTask's PID Shared
Memory
DescriptionFunctionArguments
forkQ
RevisionE
Section4
The Task
Distribution
Preprocessor(TDP)
Section
4. 150-Runtime Description
7)
The child oftheforkserversends a message containing thefunctionargumentstoitself (to a processwith itsownprocess id). Thechildfork serverthenexe
cutes anexecQ, passingthe string intheUNIXmessage to theexecQ function.
The child ofthe fork serverhas now "become" the childtask (sameprocess
id). The childtask's main()function receives thefunction arguments sent in a
messagebeforetheexec().
Figure
4-2 Creation
ofChild
Task
msgsndQ
Child Task
msgrcvQThe
Task Distribution
Preprocessor(TDP)
Section 4.1
51-Runtime Description
8)
The TDP generated main() function in the child task has access to the fourarguments passed on the command line. The
function
number, function callinstance number, and parent task's process id are the first three arguments.
The
temporary
file containing the shared data (orthe shared memorydescrip
tion)
is
the last argument. The child task copies in shared memory from thetemporary
file createdby
the parent task (or attaches to shared physicalmemory).
Figure
4-3
Tightly-Coupled Configuration
Revision E
Section
4
Version 1
The Task Distribution
Preprocessor(TDP)
- 52-Section
4. 1Runtime
Description9)
The task's main() function thenpushes thefunction's
arguments on the stackand callsthefunctionspecifiedinthe firstcommandlineargument. The length
of the arguments for this particular function is obtained from the TDP gen
erated function liststructure.
10)
After function execution, the main() routine calls a function that will copyshared memory to another
temporary
file for return to the parent task. Ifshared physical memory is used, the child task simply detaches from this
memory.
11)
Afterthe shareddata is copied backto atemporary
file,
themain() functionofthe child task sends a UNIXmessage to the parent task. The child task also
sends asignalto theparenttaskusing the
kill()
UNIXfunction. Theprocess idofthe parent task, necessary for sendingtheparent the message and signal, is
The Task Distribution Preprocessor
(TDP)
Section
4.1
-53-Runtime Description
nal. Ifnoverification comes, thechildtaskagain sends a signalto theparent.
The parent couldhave missed theoriginal signal forvarious reasons, the most
likely
being
thatitwasbusy
processingthereturn of anotherchildtask.Figure 4-4
Child
Task Termination
msgrcv()
Function Number
InstanceNumber
Child Task's PID Function'sReturnValue
msgsnd()
12)
All taskshave asignalhandling
functionassignedtohandle theterminationofchildtasks. When thechildtasksendstheparentthetermination signal, UNLX
will branch the parent task to the signal
handling
function. The signalhan-RevisionE Section 4
Version 1
The Task
Distribution
Preprocessor(TDP)
. 54.Section
4. 1Runtime Description
dling
function
in the parent task willlook
on the TDP message queuefor
messages with a type equal to
its
process id. TheUNIX
message explainswhichfunction has
terminated, its instance
number, theprocess id ofthechild
task,
thereturn value ofthefunction
and thename ofthetemporary
files
containing
the shared datatobe copied back to theparent. Theparenttasks sendsa signal backtothe child
(using
theprocess id inthemessage)notifying itthatthe message has been received.
Receiving
this response signal will cause thechildtoexit normally.
13)
The parent taskcompares the bytes inthe original shared data file sent to thechild
task,
and the altered shared data file returnedby
thechild. Ifabyte haschanged, it is copied back to the parent tasks address space. This processing
does not take place if shared physical memory is
being
used between tasks(attachment of shared physical memory is not implemented in TDP Version
The Task DistributionPreprocessor
(TDP)
- 55-Section4.1 Runtime Description
suspended in
TDPwait(),
waiting for this function call to return, theTDPwait()
functionreturns withthereturn value ofthe function. Iftheparenthasnot yet called
TDPwait()
forthiscallinstance,
thereturn value ofthefunction call is saved andwill be returned
by
TDPwait()
whenit is called forthiscallinstance.
. .
P Version 1
Revision n
RUNTIME PLATFORM
TheTask Distribution Preprocessor
(TDP)
Section 4.2-56-Runtime Diagrams
4.2
Runtime
Diagrams
The
following
diagram summarizes the processes and communicationinvolved in aremote functioncall whenphysical sharedmemory isnotpossible:
Figure 4-5 Loosely-Coupled Run Time System
msgrcvQ
FunctionNumber InstanceNumber Child Task's PID Function's Return Value
Shared
Data File Name Returned Data File NameTask Name Function Number
Instance Number Parent Task's PID Shared Data File Name
FunctionArguments
Parent Task
Child Task
msgsndO
kill()
msgrcvQmsgsnd()
TheTask DistributionPreprocessor
(TDP)
Section 4.2
-57 Runtime Diagrams
The
following
diagramsummarizestheprocesses and communication involvedinaremotefunctioncall whenit ispossibletosharephysicalmemory:
Figure 4-6
Tightly-Coupled
Run
Time
System
msgrcvQ
TaskName FunctionNumber
Instance Number Parent Task's PID Shared
Memory
DescriptionFunctionArguments
Function Number Instance Number
Child Task's PID
Function's ReturnValue
msgsndQ
msgsndQ
killQ
Function
Arguments
Revision E Section 4
Version 1
The Task
Distribution
Preprocessor(TDP)
. 5g .Section 4.2
Runtime Diagrams
4.3
TDP
Runtime
Library
The TDPruntime
library
is linked into
allprogramtasks. Thelibrary
providesall code necessary tomanage parallelism inthe
C
language. The onlyvisible interface to this
library
in the user's source code are calls toTDPwaitQ
to synchronizeparalleltasks.
The call to
TDPwaitQ
can be easily "stubbed out"by
the user when TDP isnot used to build the program. A sequential version ofthe user's program can be
built
by
just providingafunctioncalledTDPwaitQ
thatreturnsthe argumentpassedto it. In this manner, a programmer can easily switch back and forth between
sequential and parallelimplementationsofaprogram whennecessary for
debugging
purposes.
The Task
Distribution
Preprocessor(TDP)
.59
.Section4.3 TDP Runtime
Library
visible. A call to
TDPcallQ
is made wherever the program calls a remote procedure and
TDPusrexitQ
is called whereverthe userhasspecifieda call toexit(). Attheendofthe user'smain() function TDPwill also place acallto
TDPexitQ
whichwillproperly notifytheforkserver oftheterminationoftheuser's mainfunction.
As well as specific calls placed in the user's source code, TDPalso links in a
number of routines used
by
these calls. Each task is also provided amain() function thatplaystheexecutive roll in setting upthe stackforaprocedure call, execut
ing
acallrequest, and receiving andreturningshareddatatoa parenttask.Rpvic'on F Version 1
The Task
Distribution Preprocessor
(TDP)
. go-Section 5
VERIFICATION
AND VALIDATION
5 VERIFICATION AND
VALIDATION
The important elementsofTDPthatshouldbe testedare thecapabilities ofthe
scanner/parser andthe correctness oftheruntimeenvironment. The capabilities of
the parser can be tested
by
processing a program that contains all possible C datadeclaration syntax. Allpossible function declaration
types,
local static declarationsand function call syntax should also be tested. Code or data that is not used in a
runningprogrammustbevisuallyverified.
The run time environment can be tested on aprogram
by
program basis. Aprogram's results when run afterprocessing
by
TDP should be identical toresultsobtainedwhentheprogramisnot processed
by
TDP. The only exceptionto this, isthat parallelism in aprogram that affects output will only bevisible in aTDPpro
The Task DistributionPreprocessor
(TDP)
- 61-Section 5 VERIFICATIONAND VALIDATION
tasks. Parallelism is demonstrated
by
therandominterleaving
oftheoutput.Version 1 Revision E