• No results found

The Task distribution preprocessor (TDP)

N/A
N/A
Protected

Academic year: 2019

Share "The Task distribution preprocessor (TDP)"

Copied!
104
0
0

Loading.... (view fulltext now)

Full text

(1)

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

(2)

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~ur

Lun

Dr. Andrnf' KilcMn

Peter Anderson

(3)

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:

(4)

---"""""-+-'~-r-""""'-+---Abstract

This document

describes

a software processor used to generate portable and

efficient 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

is

targeted toward multiprocessor systems that provide facilities for sharing physical

memory between processes running on separate CPUs.

Portability

is achieved with the

use ofthe

highly

portable UNIX operating system and itscompanion

C

language. The C

language is used asboth theinput andoutputlanguage fortheprocessor. UseofC as an

object language gives portability to the generated multitask program.

Using

C as an

input

language,

simplifies the interface withmultitasking languages and code generators

as well as minimizing changes necessary when converting C

language

single task pro

grams tomultitask programs. Initial implementation oftheTask Distribution Preproces

sor will generate

C

codethatcan becompiled andrunonany UNIXsystemthatprovides

messagepassing facilities.

(5)

The Task

Distribution

Preprocessor

(TDP)

-n

Acknowledgements

My

thanks to Dr. Peter Lutz and Dr. Andrew Kitchen fortheir support andideas. I

also want to thank my wife

Anju

S.

McCanna,

for suggestions concerning the writing

styleofthe "Purpose" section intheintroductionto thisdocument.

Key

Words

and

Phrases

Key

Words in this document include:

Language, Parallel, Distribution,

Con

currency,

Multiprocessing, C,

Preprocessor.

Key

Phrases inthis document include:

Multiprogramming

Languages,

C Preproces

sors,

Multiprogramming

Platforms.
(6)

The Task Distribution Preprocessor

(TDP)

- iii -Tableof

Contents

Table of

Contents

1

INTRODUCTION

AND

BACKGROUND

1

1.1 Purpose 1

1.2 Previous Work 4

2

PROGRAMMING OPTIONS

18

2.1

Specifying

aTask 18

2.2

Specifying

Shared Data 18

2.3 Unshared

Memory

19

2.4 Stack

Memory

20

2.5

Library

Functions 20

2.6

Synchronizing

Tasks 21

2.7

Building

As A Single Task 24

2.8 Second Level

Modularity

Conflicts 24

2.9

Other Synchronization Constructs 27

3 PROCESSOR SPECIFICATION 29

(7)

The

Task

Distribution

Preprocessor

(TDP)

- iv

Tableof

Contents

3.1 TDP

Processing

Diagrams

29

3.2 TDP

Processing

Description

31

3.3 Processor Design 36

3.4

Achieving

Data Alignment 36

4 RUNTIME PLATFORM 43

4.1 Runtime Description 43

4.2 Runtime Diagrams

55

4.3 TDP Runtime

Library

58

5 VERIFICATION AND VALIDATION 60

6

CONCLUSIONS

62

6.1 Problems EncounteredandSolved 62

6.2 System Deficiencies 62

6.3 Suggestions for Future Extensions 62

6.3.1

Limiting

theTransferofData 62
(8)

The Task Distribution Preprocessor

(TDP)

Table

of

Contents

6.3.4

Exec()

Overhead

Reduction 65

6.3.5 Detectionof

Inefficient

RemoteCalls 67

6.3.6

Dynamic

Linkage

68

6.3.7

Full Code Duplication

69

6.4 Related

Thesis

Topics fortheFuture 70

6.4.1

Automatic

TaskGenerator

70

6.4.2 Portable

Multitasking

Languages 71

7 BIBLIOGRAPHY 73

APPENDIX A: Example Program- InputtoTDP 78

APPENDIX B: Example Program-

Output

ofTDP 81

APPENDIX

C:

Running

the Example Program 92

APPENDIXD: Walk-Through for Example Program 93

List ofFigures

Figure 3-1 ProgramLoad Module CreationwithoutTDP

29

Figure 3-2 Multiple Load Module Creation

Using

TDP

30

(9)

The

Task Distribution Preprocessor

(TDP)

-vi

Table

of

Contents

Figure

4-1

Communication

withtheFork Server

49

Figure 4-2 Creation

of

Child

Task 50

Figure 4-3 Tightly-Coupled Configuration 51

Figure 4-4 Child Task Termination 53

Figure 4-5

Loosely-Coupled

Run Time System 55
(10)

The Task Distribution Preprocessor

(TDP)

- 1

-1 INTRODUCTION AND

BACKGROUND

1.1 Purpose

The Task Distribution Preprocessor

(TDP)

is a programming system for multiple

process 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 use

of

tightly

coupledmultiprocessors, a major goalforthe TDPsystem, is thatmultiprocess

programs be able to run on any hardware platform running the UNLX operating system.

Portability

in

TDP,

will allow the use of inexpensive systems

during

multiprocessor

applicationdevelopment andallow easein portingtheseapplications tonewhardware.

Revision E Version 1

(11)

The Task

Distribution

Preprocessor

(TDP)

2

-Section

1.1 Purpose

The Task Distribution Preprocessor essentiallyprovidesparallel constructs to the C

language

[KER]

without changing the

language.

There is only oneTDP provided func

tion to synchronizeparallel code. Data sharing isprovided

by

putting all static datainto

shared memory.

Why

a task distribution preprocessor? What makesthe multitasking platform gen

erated

by

TDP differentor superiortoothermultitaskingplatforms? Themostimportant

difference

is

that the output (and

input)

toTDPis standard

C

code that canbe compiled

on any UNIX system. Withthe success of

UNIX,

both

industry

andacademia havereal

ized the importance of software portability [LAP]. It is

becoming

so important that

software 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

(12)

The Task Distribution Preprocessor

(TDP)

- 3

-Section

1.1 Purpose

run 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, then

what good is the portability?

Very

simply, TDP processed applications will be

developed (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 comes

that

tightly

coupled multiprocessor systems are commonplace, portability between the

makes 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 pro

grammers 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" their

RevisionE Version 1

(13)

The

Task

Distribution

Preprocessor

(TDP)

- 4

-Section

1.1 Purpose

source code

into

C code thatcanthenbeprocessed

by

TDP.

1.2 Previous Work

Much of TDP is

based

on the remote call concepts presented

by

Nelson

[NEL1,NEL2],

summarized

by

Hamilton

[HAM]

and implemented

by

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 samemechanism

be 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"
(14)

The Task Distribution Preprocessor

(TDP)

5

Section

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 subse

quent design assumes the absence of shared addresses. Our intuition is that

with our

hardware

the cost of a shared address space would exceed the addi

tionalbenefits."

[BIR]

In

fact,

most

implementations

ofRPC do not provide shared memory. With the

absence ofshared memory

facilities,

remote procedure calls arelimited to call-by-value

or

"copy-in/copy-out",

no addresses as arguments or in

data,

can be shared across the

RPC. This restriction may seem

inordinately limiting

but for some systems this limita

tion 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]

based

language

for heterogene

ousdistributedsystems.

The original goal ofTDP was to simply add shared address space for a Birrel &

Nelson - likeremote call implementation using standardUNLX andthe

C language.

The

implementation was to be similar, but more flexible than an

implementation

by

Glasser

RevisionE

Version

1
(15)

The

Task Distribution Preprocessor

(TDP)

-

6

-Section

1.2 Previous Work

[GLA1,GLA2]

that copied data referenced

by

pointer arguments. The goals were

expandedto

include

parallel or "asynchronous" remote calls and an efficient implemen

tation for tighdy-coupled multiprocessor environments when the importance of this

hardware

platform

became

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 when

a 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 inter

face with a run-time systemthatprovides remote execution. Without TDPprocessing, a

(16)

The Task

Distribution

Preprocessor

(TDP)

- 7

Section

1.2 Previous Work

programs 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 adoptedisthat

shared 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 & Fisher

discussing

Ada,

gives avery complete accountoftheissue:

"Shared Memory. Another issue

facing

process-model

languages

isthedicho

tomy

between shared-memory systems and message-based systems. If the

language 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,

that

approach virtually precludes extending the parallel processing scheme to

loosely

coupled networks, which lack shared memory. Message-based sys

tems, on the other

hand,

incur a substantial run timeperformancepenalty, but

are more general inthat

they

canbe usedinawiderrange of configurations.

RevisionE

Version

1
(17)

The

Task Distribution Preprocessor

(TDP)

- 8

-Section

1.2 Previous Work

Ada

rendezvous provides a

diplomatic

compromise between these two

environments. Multiple tasks can access shared variables, but in a restricted

way that allows for

loosely

coupled systems.

Updating

is guaranteed only at

synchronization 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 that

memory 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 a

very 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

(18)

The Task

Distribution

Preprocessor

(TDP)

-

9

-Section

1.2 Previous Work

"loose"

coupling

of processor groups. The

Butterfly

GP

1000

produced

by

BBN

Advanced

Computers

Inc. of

Cambridge

Massachusetts

is

a case in point [RUS].

Currently,

the

Butterfly

GP 1000 can have a maximum of 256 processors sharing the

same physical memory.

Building

a configuration comprising more than 256 processors

requires thatportionsofthe system communicate via a communication network. A sys

tem made up of several

Butterfly

GP

1000 machines would

have

both tightly-coupled

components and a loosely-coupled component.

Ideally,

run time support for such a

configuration would make crossing the loosely-coupled component invisible while still

allowing maximum efficiency in the tightly-coupled environment.

Favoring

the

tightly-coupled environment for efficiency

is based

onthe assumptionthatwith more andmore

processors 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 should

bring

maximumportability andutility to thesystem.

Hopefully,

using apopular and well

RevisionE Version 1

(19)

The Task Distribution Preprocessor

(TDP)

10

-Section

1.2 Previous Work

supported

language like

C will allow TDP to be easily

interfaced

to existing applica

tions and code generators.

Going

with standard C as the

input

language,

a number of

parallel

implementations

oftheC language were exploredforpossibleuse as abasis for

TDP.

The first parallel C

implementation

considered is "Refined C"

implemented

by

Dietz & Klappholz [DIE2]. This

implementation

is based on concepts presented in an

earlier paper

by

the same authors

describing

how any conventional sequential language

can be "refined" to provide parallel constructs [DIE1]. Dietz & Klappholz correctly

identified

the three most difficult constructs to deal with in changing a sequential

language intoaparallellanguage:

'

'References

toglobaldata: sincethecomplexityof certainanalysis techniques

requires 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.

(20)

The Task

Distribution

Preprocessor

(TDP)

- 1 1

Section

1.2 Previous Work

References to

indexed

data structures: since it can be difficult to determine

which 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 a

construct 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 major

change to the language.

Changing

C

dramatically

dilutes arguments for using it in the

first place. Ifanon-standard source language is acceptable, thenusing a

highly

expres

sivedistributedprogramminglanguage like SR

[AND],

MML

[BOA]

orLinda

[AHU]

is

a 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

(21)

The Task

Distribution

Preprocessor

(TDP)

- 12

-Section

1.2 Previous Work

The

Concurrent

C language presented

by

Gehani & Roome

[GEH]

was also dis

carded as a model becauseof extensive changesto the

C

language. This implementation

also had the added

disadvantage

of not providing shared memory facilities. In Con

current

C,

shared memory is left for the C programmer to implement as described in a

quotefromthearticle

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 why

wehavenot addedany language constructsfor

dealing

withsharedmemoryor

for simulating shared variablesinanon-sharedmemory

environment."

[GEH]

Leaving

theimplementationof sharedmemoryentirelyto theprogrammer andencourag

ing

the use of a message passing model for shared memory is unacceptable for the

tightly-coupledmultiprocessorenvironmentstargetedfor TDP.

(22)

The Task

Distribution

Preprocessor

(TDP)

13

-Section

1.2 Previous Work

Although monitor accessto sharedvariablesprovidestheabstractionnecessary formul

tipleprocess programs in

loosely-coupled

environments, thislanguage implementation is

inefficient fortighdy-coupledsystems.

Always

accessingglobalmemory throughamon

itorwill also

force

majorrestructuring in sequential

C

programs that are to beconverted

tomultiple process programs.

Aparallel implementationoftheC languagepresented

by

Sonnenschein

[SON]

pro

vides 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 Refined

C,

the language is changed to the degree

thata standard

C

compiler could notbeusedtocompile thesource code. Theother prob

lem is that there is no provision for more than one process to simultaneous access a

Revision E Version 1

(23)

The Task

Distribution

Preprocessor

(TDP)

14

-Section

1.2 Previous Work

particular port memory. Shared memory is always of a restricted nature, real-time

simultaneous accesstosharedmemory is expressly

forbidden.

Binding

[BIN]

presents a parallel

implementation

oftheC language that allowsthe

sharing ofall globalmemorywithoutrestriction. The C

language

is essentiallyunaltered

satisfying anothergoal for the TDPenvironment. In Binding'sparallel

C,

parallelism is

only simulated; all program tasksreside ina single UNIXprocess. Contextswitchesare

not

"preemptive";

a program mustexplicitly relinquish control ofthe CPU

by

calling a

"ContextSwitchO"

function. A similar implementation

by

Cormack

[COR]

allows

preemptivescheduling 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]

provided

by

manymultiproces

sor operating systems. Programs using the

Binding

or Cormack implementations could

be easily upgraded to utilize the

"light"

process primitives ofmany ofthese multipro

(24)

The Task Distribution

Preprocessor

(TDP)

15

-Section

1.2 Previous Work

implementations

invisible

toanapplication, thatapplicationwill bemuch more portable

acrossvarying processor configurations.

Currently,

very few UNIX

implementations

pro

vide "light" processes;

therefore,

exclusive use of

them,

wouldimpacttheportabilityof

the system severely. It is also hoped that the performance impact in the creation of

"heavy"

processes canbe

lessened

tobe very near theperformance impact forthecrea

tion of a program "thread" or "light" process.

However,

because the development of

"light"

processes in multiprocessor systems is very

important,

nothing in the design of

TDPwill preclude the use of threads in combination with TDPto achieve performance

andportability benefits in both

loosely

and

tightly

coupled environments. The design of

TDPwillalso 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 publishedver

sion 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

(25)

The Task

Distribution

Preprocessor

(TDP)

16

-Section 1.2 Previous Work

portability ofthe source code and does not lendwellto conversion

between

single and

multiple process versions ofthe program.

Adding

reserved words would also eliminate

the possibility of

having

a single process version of a program, compiled without

TDP,

using a standardC compiler.

Therefore,

to specify parallelism, TDPusesthe modulari

zation 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 #include

directive,

program modularization can be

achieved on several levels. Aprogram can use modularization forseparate compilation

and information

hiding

as usual,

by

separating source code into separate files. To build

the 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"

(26)

TheTask

Distribution

Preprocessor

(TDP)

17

Section 1.2 Previous Work

Shared memory in TDP processed programs, requires no specification

by

the user

because 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

(27)

The Task

Distribution

Preprocessor

(TDP)

18

-Section 2

PROGRAMMING OPTIONS

2

PROGRAMMING OPTIONS

2.1

Specifying

a

Task

Aprogrammerinforms TDP that certain

functions

are to bepart ofa separate pro

gramtask

by

puttingthedeclarations forthese functions ina separateC source file. TDP

assumes 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

(28)

The Task

Distribution Preprocessor

(TDP)

. 19.

Section

2.2

Specifying

Shared

Data

2.2

Specifying

Shared Data

All static memory in aprogram except that which is declared in a

library

function,

willbe sharedbetweenprogramtasks.

Any

changestostaticmemorywill bereflectedin

all tasks. Not sharing

library

function

static memory allows the proper execution of

many standard UNLX

library

functions that are not designedto be re-entrant.

Any

data

declarations

preceded

by

the C reserved word

"static",

will also be shared but only the

task thatdeclared itwillhaveaccessto thelabel

describing

thedata.

String

data falls into

the 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

(29)

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 to

unsharedmemory 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 be
(30)

The Task

Distribution

Preprocessor

(TDP)

21

Section 2.5

Library

Functions

2.5

Library

Functions

Library

functionsarelinked intoprogramtasksasthelast step in creating individual

task modules.

Every library

function

that is used in the entire program is linked

into

EVERY task module whether a particulartask calls that function or not. This prevents

dataalignment problems caused

by

static memory declared inside a

library

function. If

onetasklinked ina

library

functionthatdeclaredstaticmemory, and another taskdidnot

link in that

function,

the static memory may

destroy

the memory alignment ofthe two

tasks.

Static

memory declared in

library

functions is the only static memory in a TDP

createdprogramthat is not shared. Not sharing

library

functionstatic memoryallowsthe

proper execution of many standard UNIX

library

functions that are not designed to be

re-entrant.

Revision

E

Version

1
(31)

The Task

Distribution

Preprocessor

(TDP)

- 22

-Section

2.6

Synchronizing

Tasks

2.6

Synchronizing

Tasks

When the user calls afunction that is defined in another source

file,

he/she is start

ing

aparallel task. The remote functioncall will return a child task descriptor and this

descriptor can be used to wait for the child task at any point in the execution of the

(32)

The Task

Distribution Preprocessor

(TDP)

. 23

-Section 2.6

Synchronizing

Tasks

funcl()

{

int child_descr; intretval;

child_descr=

func2();

parallel code

retval=

TDPwait(child_descr);

}

funcl()

and

func2()

are defined in separate source files andthe code betweenthe call to

func2()

and

TDPwait(),

is code thatwillbeexecuted inparallel withthecode in func2().

Thereturn value of

func2()

isreturnedfrom TDPwait().

TDPwait()

is identical to the

ab-sorb() function in the parallel

C

implementation presented

by

Cormack [COR]. The

childdescriptor is avalue thatis uniqueto aparticular call andis different for every call

evenifmultiplecalls are made to thesamefunction.

If

by

the time

TDPwait()

is called, the child task has already

terminated,

then

TDPwait()

simply returns thevalue returned

by

theremote function. Ifthe child task is

still running when

TDPwaitQ

is called, the parenttask will be suspended until thechild

Revision E Version 1

(33)

The Task

Distribution

Preprocessor

(TDP)

24

-Section 2.6

Synchronizing

Tasks

task terminates. The call to

TDPwait()

can beanywhere intheparent task andit isnot

necessary to call

TDPwait()

at all.

There is nothing

in the TDP platform that requires

thata parent taskwait for

its

children.

Children

canterminate

long

aftertheirprogenitors

haveterminated.

2.7

Building

As

A

Single Task

An application that uses the

TDPwait()

function can be built and ran without TDP

by

simply creating a function called

TDPwait()

that returns its argument. The return

value of a function would simply be passed through the

TDPwait()

function unaltered.

This may be usefulifthereis a suspected

bug

intheparallelconstructs of a programorif

it is

desiredto use a debugger that can only function on a single process version of the
(34)

The Task

Distribution Preprocessor

(TDP)

-

25

-Section 2.8

Second

Level

Modularity

Conflicts

2.8 Second Level

Modularity

Conflicts

It

is

expected that some programmerswill define TDPtasks

by

simply creating files

thatinclude 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 vari

able 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

(35)

The Task Distribution Preprocessor

(TDP)

- 26

-Section

2.8

Second

Level

Modularity

Conflicts

2)

The scope of afunctionnamecanalsobe restrictedto a single source file using

the "static" keyword when the function is declared. It is possible that two

source

files

may use the same "static" function name and ifthe two source

files 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 set

of#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 surrounded

by

conditional preprocessor

directives:

(36)

The Task Distribution Preprocessor

(TDP)

- 27 -Section2.8

Second

Level

Modularity

Conflicts

4)

A manifest constant can

be

given one value inone source

file

and a different

value in another. Ifthe two

files

are merged theremay be aconflict. Some C

preprocessors 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

(37)

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 a

programmer needs more elaborate communicationorsynchronization between tasks, the

entire UNIX C

library

is

at the programmer's disposal. Because TDPprocesses are true

UNIXprocesses, 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 particular
(38)

The Task

Distribution

Preprocessor

(TDP)

Section

3

-29-PROCESSOR SPECIFICATION

3

PROCESSOR

SPECIFICATION

3.1 TDP

Processing

Diagrams

Figure

3-1 Program

Load Module Creation

without

TDP

(39)

The Task

Distribution

Preprocessor

(TDP)

Section 3.1

30-TDP

Processing

Diagrams

Figure 3-2 Multiple Load Module

Creation

Using

TDP

(40)

TheTask Distribution Preprocessor

(TDP)

. 3 1

Section 3.1 TDP

Processing

Diagrams

3.2 TDP

Processing

Description

TDP accepts as

input,

all the C source files that comprise a program. TDP will

assume 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 called

by

a function in

anothertask.

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 in

the

following

manner:

o If TDP encounters afunction declaration in asource

file,

thefunction name and its

arguments are savedinalinked list for later reference. Thename ofthe fileandthe

numberofthefunction declaration isalso storedfor laterreference.

Revision

E Version 1
(41)

The Task Distribution Preprocessor

(TDP)

32

-Section 3.2 TDP

Processing

Description

o If TDP encounters a string constant, the string

is

saved in a linked list to be later

usedtoinitialize 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 are

also 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 of

a counterto aunique string. The declarations are all outputto the singleTDPgenerated

globaldata file.

(42)

TheTask Distribution Preprocessor

(TDP)

. 33

-Section3.2 TDP

Processing

Description

o If aglobal declaration

is

encountered, it

is

appended to the single data file for the

program. Ifthe declaration

does

not have an

initializer,

it is givenone. Initializers

are 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

(43)

The Task Distribution Preprocessor

(TDP)

- 34

-Section 3.2 TDP

Processing

Description

was encountered in pass 1. Ifthe

function

call

is

not

defined

in theprogram, the

function name is put inthe list of

library

routine calls fortheprogram. Ifthe func

tion 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 TDPfunctionthat

initiates

a remotecall using the origi

nal function call arguments andthe functionnumber. The functionnumberforthis

functionwas assignedinpass 1 whenthefunction declarationwas encountered. No

information

is

saved for functions that are called anddefined inthe same

task;

this

code willjust make anormallocal call. The code for alocal call is just echoed to

theoutputfile.

o Ifthefunction main()is encountered ina source

file,

TDPrenamesthefunction and

records the fact the current task is the startup task forthe program. At the end of

this

function,

TDPwill output acall to a special

TDPexit()

function that allows the
(44)

The Task

Distribution

Preprocessor

(TDP)

. 35.

Section 3.2 TDP

Processing

Description

o Allcode not mentioned above, iscopied

directly

fromthe theinput source

file

to the

taskoutput file.

Ina separate

file,

TDP generates adeclaration for a global structurethatcontainsall

information 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 has

its

own copy ofthese structures,

they

are not shared between

tasks.

Revision E Version 1

(45)

The Task

Distribution Preprocessor

(TDP)

36

-Section 3.2 TDP

Processing

Description

3.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 first

loop

is pass one oftheprocessor

andthesecondispasstwo.

The scanner used

by

TDPis created usingthe UNIXutility lex. It has thecapabil

ity

to scan all C declarations and calls a numberof specialfunctions for parsing and out

put. The samescanneris usedfor bothpassoneand passtwooftheprocessor.

TDP parsingand output routines manipulatetwolinked lists. One linked listisused

(46)

The Task

Distribution

Preprocessor

(TDP)

37

-Section 3.4

Achieving

Data

Alignment

3.4

Achieving

Data Alignment

Toprovide sharedmemory

functionality,

TDPaligns global memory inall tasks so

that 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

copiedbetweenthe

tasksin 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 for

a program load module, the addresses assigned to code and data objects are virtual

Revision E Version 1

(47)

The Task Distribution Preprocessor

(TDP)

3g

. Section3.4

Achieving

Data Alignment

addresses. When memory is accessed

by

aprogram at run

time,

thevirtual pointer to a

variable

is

remappedtoa physical

memory

address.

TDPputs all static data

declarations

into asingleC source file for a program. This

source 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 pro

grams. This block of

"memory

space"

or

"section",

is not guaranteed to start at the

same address in all theprogramtasks.

Typically

thelinker/loaderwill putthis datasec

tion 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 fromeachotherin

each

task,

the addresses are still different in everytask

depending

onthesize ofthecode

sectionforthat task. To achievedataalignment, thevirtual addresses ofthedatamustbe

shifted sothat the virtual address ofthestartofdataobjectsisthesame inalltasks. TDP

(48)

TheTask Distribution Preprocessor

(TDP)

39

.

Section3.4

Achieving

Data Alignment

in the

data

section equal to the

difference between

the

starting

address ofthe module

with that largest data section start address and the start address of the current load

module's

data

section. This

hole

inthedatasection shiftstheaddressesforthestaticdata

inthe 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 the

linker/loader: Id. An iftle is afilewhichcontains LinkEditor Command Languagecom

mands to manipulate load modules. The

following

is the default ifile run

by

Id when

executed on anIntel 80386 System V Release 3.X UNIXsystem:

RevisionE Version 1

(49)

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 usedto

build

one oftheload modules in aTDPprocessed program. Noticethatit is identical to

the

default

specification except for the increment value placed in the .data section
(50)

TheTask

Distribution

Preprocessor

(TDP)

. 41 .

Section 3.4

Achieving

Data

Alignment

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. This

increment

command will cause Id to start allocating data for declarations after skipping

318

(hex)

bytes.

By looking

atthis ifile we can surmise that there is aloadmodule for

this programthat has adata section with a start address that is 318

(hex)

largerthan this

load

module'sdatasection start address.

Ifalink/loader onaparticular systemdoesnot provide a means for putting ahole in

Revision

E Version 1
(51)

The Task DistributionPreprocessor

(TDP)

- 42

-Section 3.4

Achieving

DataAlignment

the data section, TDP will generate a

dummy

declaration

equal to the sizethat thehole

wouldbe. The declaration ismade sothatit isthefirst dataallocated

by

thelinker/loader
(52)

The Task Distribution Preprocessor

(TDP)

-

43

-Section 4

RUNTIME

PLATFORM

4 RUNTIME

PLATFORM

Simply

aligning data is not all there

is

to the story, TDP must also provide an

efficientmeans fortaskspawning and synchronization. A

library

of runtime routines is

linked into all TDP processed program tasks. The TDP

library

serves to manage all

aspects oftheTDPrun timeenvironment. The only visibleevidenceto the userthat this

library

isused,are calls that he/shemakesto the

TDPwait()

functionthat allows aparent

task towaitforachildtask.

P . .

p Version 1

(53)

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 is

sent 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 the

specificationsinthe message.

Therefore,

thefork server istheprocess parent of all

program processes.

0 Upon startupofthe firsttaskinthe system,anynecessary initialization isperformed

andtheprogram's originalmain()function(now renamed)is executed.

(54)

The

Task

Distribution

Preprocessor

(TDP)

-

45

-Section

4.1 Runtime Description

o Ifa

library

function

is

called, 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, the

following

sequenceisperformed:

1)

A special TDP function is called. TDP hasplaced a callin theprogram code

that appearsasfollows:

TDPcall(funcnum,arguments,

. . .);

The funcnum is aconstantinteger representingthefunctionnumbercalculated

by

TDP. The arguments are the exact arguments placed

by

the user for this

function call in the original source code.

During

preprocessing, TDP has

replacedtheoriginaltextofthecall:

func(

with:

TDPcall(funcnum,

The TDPcallfunction is declaredusingthe variable parameter macros defined

by

the UNLX System V macro package varargs (see the UNIX System V

Programmer'sReferencemanual foracompletedescriptionofthesemacros):

RevisionE Version 1

(55)

The Task

Distribution

Preprocessor

(TDP)

- 46

-Section

4.1 Runtime Description

TDPcall(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 string

will contain the target task name, the called function number, the instance

number ofthefunctioncall, thecurrentprocessidnumber, andthenameofthe

shareddata file.

(56)

The Task

Distribution

Preprocessor

(TDP)

-

47

-Section

4.1 Runtime Description

describing

all functions declared intheprogram. The function list'svaluefor

the number of words for arguments

in

a particular

function,

was determined

when the function declaration was parsed

during

program building. The fol

lowing

code is executed in

TDPcall()

to copy the function arguments into the

message

(Again,

a variable number of function arguments is extracted using

varargs):

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 arguments

inafunctioncall.

Revision E Version 1

(57)

The Task

Distribution

Preprocessor

(TDP)

- 48

-Section

4.1 Runtime Description

4)

TDPcall()

copies all shared datato a

temporary

fileor arranges forattachment

of shared physical memory, (attachment of shared physical memory is not

implemented in TDP Version 1.0).

TDPcall()

thensendsthemessage contain

ing

the taskparameters andfunctionarguments to theforkserver.

5)

After sending the UNIX message to the fork server,

TDPcall()

returns achild

processdescriptorto thecaller. Thechildprocessdescriptoris usedlateras an

argument to the

TDPwait()

function. The callto

TDPwait()

allows theparent
(58)

The Task

Distribution

Preprocessor

(TDP)

Section

4. 1

-49-RuntimeDescription

6)

Upon receipt of a UNLX message, the fork server executes a

forkQ

and the

parentforkserver process waits again onthemessagequeue.

Figure 4-1 Communication

with

the

Fork Server

Task Name Function Number

Instance Number ParentTask's PID Shared

Memory

Description

FunctionArguments

forkQ

RevisionE

Section4

(59)

The Task

Distribution

Preprocessor

(TDP)

Section

4. 1

50-Runtime Description

7)

The child oftheforkserversends a message containing thefunctionarguments

toitself (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

of

Child

Task

msgsndQ

Child Task

msgrcvQ
(60)

The

Task Distribution

Preprocessor

(TDP)

Section 4.1

51-Runtime Description

8)

The TDP generated main() function in the child task has access to the four

arguments passed on the command line. The

function

number, function call

instance number, and parent task's process id are the first three arguments.

The

temporary

file containing the shared data (orthe shared memory

descrip

tion)

is

the last argument. The child task copies in shared memory from the

temporary

file created

by

the parent task (or attaches to shared physical

memory).

Figure

4-3

Tightly-Coupled Configuration

Revision E

Section

4

Version 1

(61)

The Task Distribution

Preprocessor

(TDP)

- 52

-Section

4. 1

Runtime

Description

9)

The task's main() function thenpushes the

function's

arguments on the stack

and 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 copy

shared memory to another

temporary

file for return to the parent task. If

shared physical memory is used, the child task simply detaches from this

memory.

11)

Afterthe shareddata is copied backto a

temporary

file,

themain() functionof

the child task sends a UNIXmessage to the parent task. The child task also

sends asignalto theparenttaskusing the

kill()

UNIXfunction. Theprocess id

ofthe parent task, necessary for sendingtheparent the message and signal, is

(62)

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

thatitwas

busy

processingthereturn of anotherchildtask.

Figure 4-4

Child

Task Termination

msgrcv()

Function Number

InstanceNumber

Child Task's PID Function'sReturnValue

msgsnd()

12)

All taskshave asignal

handling

functionassignedtohandle theterminationof

childtasks. When thechildtasksendstheparentthetermination signal, UNLX

will branch the parent task to the signal

handling

function. The signal

han-RevisionE Section 4

Version 1

(63)

The Task

Distribution

Preprocessor

(TDP)

. 54.

Section

4. 1

Runtime Description

dling

function

in the parent task will

look

on the TDP message queue

for

messages with a type equal to

its

process id. The

UNIX

message explains

whichfunction has

terminated, its instance

number, theprocess id ofthechild

task,

thereturn value ofthe

function

and thename ofthe

temporary

files

con

taining

the shared datatobe copied back to theparent. Theparenttasks sends

a signal backtothe child

(using

theprocess id inthemessage)notifying itthat

the message has been received.

Receiving

this response signal will cause the

childtoexit normally.

13)

The parent taskcompares the bytes inthe original shared data file sent to the

child

task,

and the altered shared data file returned

by

thechild. Ifabyte has

changed, 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

(64)

The Task DistributionPreprocessor

(TDP)

- 55

-Section4.1 Runtime Description

suspended in

TDPwait(),

waiting for this function call to return, the

TDPwait()

functionreturns withthereturn value ofthe function. Iftheparent

hasnot yet called

TDPwait()

forthiscall

instance,

thereturn value ofthefunc

tion call is saved andwill be returned

by

TDPwait()

whenit is called forthis

callinstance.

. .

P Version 1

Revision n

RUNTIME PLATFORM

(65)

TheTask Distribution Preprocessor

(TDP)

Section 4.2

-56-Runtime Diagrams

4.2

Runtime

Diagrams

The

following

diagram summarizes the processes and communicationinvolved in a

remote 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 Name

Task Name Function Number

Instance Number Parent Task's PID Shared Data File Name

FunctionArguments

Parent Task

Child Task

msgsndO

kill()

msgrcvQ

msgsnd()

(66)

TheTask DistributionPreprocessor

(TDP)

Section 4.2

-57 Runtime Diagrams

The

following

diagramsummarizestheprocesses and communication involved

inaremotefunctioncall whenit ispossibletosharephysicalmemory:

Figure 4-6

Tightly-Coupled

Run

Time

System

msgrcvQ

TaskName FunctionNumber

Instance Number Parent Task's PID Shared

Memory

Description

FunctionArguments

Function Number Instance Number

Child Task's PID

Function's ReturnValue

msgsndQ

msgsndQ

killQ

Function

Arguments

Revision E Section 4

Version 1

(67)

The Task

Distribution

Preprocessor

(TDP)

. 5g .

Section 4.2

Runtime Diagrams

4.3

TDP

Runtime

Library

The TDPruntime

library

is linked into

allprogramtasks. The

library

provides

all code necessary tomanage parallelism inthe

C

language. The onlyvisible inter

face to this

library

in the user's source code are calls to

TDPwaitQ

to synchronize

paralleltasks.

The call to

TDPwaitQ

can be easily "stubbed out"

by

the user when TDP is

not used to build the program. A sequential version ofthe user's program can be

built

by

just providingafunctioncalled

TDPwaitQ

thatreturnsthe argumentpassed

to it. In this manner, a programmer can easily switch back and forth between

sequential and parallelimplementationsofaprogram whennecessary for

debugging

purposes.

(68)

The Task

Distribution

Preprocessor

(TDP)

.

59

.

Section4.3 TDP Runtime

Library

visible. A call to

TDPcallQ

is made wherever the program calls a remote pro

cedure and

TDPusrexitQ

is called whereverthe userhasspecifieda call toexit(). At

theendofthe user'smain() function TDPwill also place acallto

TDPexitQ

which

willproperly 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() func

tion thatplaystheexecutive roll in setting upthe stackforaprocedure call, execut

ing

acallrequest, and receiving andreturningshareddatatoa parenttask.

Rpvic'on F Version 1

(69)

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 data

declaration syntax. Allpossible function declaration

types,

local static declarations

and 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. A

program's results when run afterprocessing

by

TDP should be identical toresults

obtainedwhentheprogramisnot processed

by

TDP. The only exceptionto this, is

that parallelism in aprogram that affects output will only bevisible in aTDPpro

(70)

The Task DistributionPreprocessor

(TDP)

- 61

-Section 5 VERIFICATIONAND VALIDATION

tasks. Parallelism is demonstrated

by

therandom

interleaving

oftheoutput.

Version 1 Revision E

(71)

References

Related documents

Ayll?n et al EURASIP Journal on Advances in Signal Processing 2013, 2013 187 http //asp eurasipjournals com/content/2013/1/187 RESEARCH Open Access Rate constrained source separation

1 is to offer a solution to Trace Back through our application module Cloud Trace Back (CTB) to find the source of DDoS attacks, and introduce the use of a back propagation

The VSC (voltage source converter) can be operated as: 1) It injects power that is generated from RES (Renewable Energy Sources) to the grid, and 2) shunt APF (Active

The functions of solid waste management encompass (1) waste generation, (2) waste handling and separation, storage and processing at the source (3) collection, (4) separation

In the present paper we prove that the curvature radius plays also the main role in the description of the gravitational field generated by a charged pulsating source..