Sie sind auf Seite 1von 2

12/22/2016

DifferencesBetweenReentrantVIs(Preallocate),ReentrantVIs(ShareClones),VITemplates,andDynamicVIsNationalInstruments

HelloJayson(Thisisnotme)

60ratings:

3.64outof5

Differences Between Reentrant VIs (Preallocate), Reentrant VIs (Share


Clones), VI Templates, and Dynamic VIs
Hardware:PXI/CompactPCI>>Controllers
Problem:
WhendoIusereentrantVIs,TemplateVIsandDynamicallycalledVIs?
Solution:
ReentrantVIs
UsedwhenyouwanttorunseveralinstancesofthesameVIsimultaneously.WhentheVIisnot
reentrantthereisonedataspacefortheVI.ThereforeonlyonecalleratatimecanberunningtheVI
andsoacallermayhaveto"waititsturn"tousetheVI.ThisisthedefaultoptionforaVI,butyoucan
setaVItobereentrantunderFileVIPropertiesExecution.
InLabVIEW8.5,theoptionofsharingacloneorpreallocatingwasintroduced.

ReentrantVIs(ShareClones)
Iftheoptiontoshareclonesbetweeninstancesisselected,theVIhasapoolofdataspaces(same
thingasapoolofclones).InitiallyonlytwoclonesarecreatedwhenthecallingVIbegins.Acallerwill
useoneofthesedataspaces,butitdoesn'tknowwhichone,anditmaybeadifferentinstanceon
subsequentcalls.Whentherearenotenoughdataspaces(clones)inthepoolforthenumberof
simultaneouscallers,newdataspaces(clones)arecreatedandaddedtothepool.Heretheword
"sharing"from"shareclonesbetweeninstances"meansthatthedataspacescanbeusedby
multiplecallersovertime.Ifthereare20callstothesubVI,butthosecallshappensuchthatatmost2
callsaregoingonatthesametime,thepoolwillhaveonly2dataspacesinitandtheywillbe
"shared"amongthe20calls.Sinceonlythenecessarynumberofclonesiscreatedaccordingtothe
currentneed,memoryuseisoptimized.
ReentrantVIs(Preallocate)
Ifyouusethepreallocatecloneforeachinstanceoption,eachcallerisgivenitsownprivatedata
space(andclone).Ifthereare20callstotheVI,20cloneswillbecreatedandaddedtothepoolwhen
thecallingVIbegins.Itmaybethatonly2areeverbusyatthesametimeifthecallingpatternislike
theonedescribedabove.IfitisimportantthateverycalltoagiveninstanceofthesubVIusethesame
clone(forexample,ifthesubVIneestoholddatafromcalltocall)thenusethistypeofreentrantVI.
SharedcloneswouldnotworkbecauseyouwouldneverknowwhichinstanceofthesubVIlastused
http://digital.ni.com/public.nsf/allkb/98847B4E4C715E6D86256C59006B57CC

1/2

12/22/2016

DifferencesBetweenReentrantVIs(Preallocate),ReentrantVIs(ShareClones),VITemplates,andDynamicVIsNationalInstruments

thecloneyouareabouttouse,andthestoredinformationwould"crosstalk"unpredictablybetween
thesubVIs.The"preallocating"meansthatforeverycall,wecreateadataspaceandcloneforthat
call.ThepreallocationhappensbeforetheVIruns.Ifyouwanttoopenmultiplefrontpanelsofthe
sameVI,reentrantSubVIoptionswillnothelp.ToopenmultipleinstancesofaVI,youhavetwo
options:
IftheVIyouwanttoopenmultipletimesisatoplevelVI,youcanduplicatethetoplevelVIondisktoa
tempdirectorywithauniquenameandopenthenewfileinstance.Itisnotnecessarytoduplicateany
subVIs,onlythetoplevelVI.YoucanthenusetheVIServertoopenandrunthecopies.
TemplateVIs
YoucanmakeamultiinstancepanelintoatemplateVI.Thenopenthefileeachtimefromthe
template.VItemplatesareVIswiththe.vitextension.YoucancreateanewVIfromatemplateunder
FileNewStartfromtemplate.ThiscreatesanewinstanceoftheVI,withitsownmemoryspace.
DynamicVIs
YoucanopenbothVIsandVItemplateswithVIServer.VIserverisusedtodynamicallyloadandruna
VI.WithsubVIs,thecodeandthedataspaceofthesubVIareloadedwhenthetoplevelVIisloaded.
WhenyoudynamicallyloadaVI,insteadofusingitasasubVI,itscodewillnotbeloadeduntilthe
subVIiscalledbytheVIserver.Thissavesmemoryandstartuptime.
RelatedLinks:
KnowledgeBase2YO91OHM:WhyDoIGetError1126whenOpeningaVIDynamicallywithLabVIEW
SubPanels?
LabVIEW8.5Help:CapabilitiesoftheVIServer
LabVIEW8.5Help:CreatingTemplateVIs
LabVIEW8.5Help:ExecutionPropertiesPage
Attachments:

ReportDate:10/21/2002
LastUpdated:08/21/2009
DocumentID:2QKDG7DW
YourFe e dback !

Poor|Excellent

DocumentQuality?

Yes No

Answ eredYourQuestion?

1 2 3 4 5

Documentneedswork?Pleasetelluswhy.

PleaseContactNIforallproductandsupportinquiries.

MyProfile|RSS|Privacy|Legal|ContactNI
2014NationalInstrumentsCorporation.Allrightsreserved.
|
EMailthisPage

http://digital.ni.com/public.nsf/allkb/98847B4E4C715E6D86256C59006B57CC

2/2

Das könnte Ihnen auch gefallen