190 likes | 559 Views
Inside LabVIEW. Steve Rogers LabVIEW Software Engineer Wed, 10:15a, 12:45p, and 3:30p Mulberry (10B). Inside LabVIEW – Topics. Virtual instrument organization How VIs are compiled LabVIEWs Execution system Single-threaded LabVIEW Multithreaded LabVIEW LabVIEW RTs remote execution system
E N D
Inside LabVIEW Steve Rogers LabVIEW Software Engineer Wed, 10:15a, 12:45p, and 3:30p Mulberry (10B)
Inside LabVIEW – Topics • Virtual instrument organization • How VIs are compiled • LabVIEWs Execution system • Single-threaded LabVIEW • Multithreaded LabVIEW • LabVIEW RTs remote execution system • What happens when indicators display • What happens when a subVI is called
The Parts of a VI Always present in memory Loaded when used VI Front Panel Block Diagram Data Space Compiled Code
VIs are compiled An Example Diagram
VIs are compiled – “Clumps” • Top for loop • Update indicator • Schedule Clump 0 • Sleep... Clump 1 Clump 0 Clump 2 • Bottom for loop • Updated indicator • Schedule Clump 0 • Sleep... • Start of diagram • Read controls • Read constants • Schedule Clumps 1 & 2 (for loops) • Sleep... • Completion of diagram • Execute divide nodes • Display indicators • Exit VI
The Execution System QElement DS PC QElement DS PC QElement DS PC QElement DS PC QElement DSPC “curElem” “RunQ” head tail prioritized ebp (ds register) VI Code VI Data Space instruction instruction instruction
Exec() is a Loop Sleeps on runQ when multithreaded curElem = Dequeue(runQ) ebp = curElem DS res = call curElem PC if(res) curElem PC = res Enqueue(runQ, curElem) curElem = NULL “Rotates” the runQ cooperative multitasking Cooperatively returns when in UI thread
Single-Threaded LabVIEW Computer Thread Co-Routines User Interface Loop Exec( )
Multithreaded LabVIEW Thread Thread Thread Thread Exec( ) Exec( ) Exec( ) Exec( ) Computer Messages Thread UI Loop co-routines Exec()
LabVIEW RT – Target System Thread Thread Thread Thread Exec( ) Exec( ) Exec( ) Exec( ) RT Computer Messages Thread Communication Loop Co-routines Exec() TCP/IP
LabVIEW RT – Development System Thread Thread Thread Thread Exec() Exec() Exec() Exec() Host LabVIEW RT Computer LabVIEW RT Target Computer TCP/IP Thread Thread User Interface Loop Communication to target possibly Exec() -shared memory -Ethernet -other Communication to host or client Exec()
LabVIEW RT – Deployed System Thread Thread Thread Thread Thread Thread Thread Thread Exec() Exec() Exec() Exec() Exec() Exec() Exec() Exec() Client LabVIEW Computer LabVIEW RT Target Computer TCP/IP -Shared memory -Ethernet -Other Thread Thread UI Loop and Comm- unications Exec() Communication to host or client Exec()
Display to an Indicator (Single Thread) Execution Data Operate/ Display Data Running code copies execution data to the operate/display, and calls the display function for the indicator.
Display to an Indicator (Multithread) Execution Thread UI Thread Execution Data Operate/ Display Data Running code acquires mutex. Copies execution data to transfer data, releases mutex, and posts message to UI thread. UI thread receives message, acquires mutex, copies transfer data to operate/ display data, releases mutex, and displays indicator. Transfer Data: Mutex “dirty flag” “update flag” Message queue
SubVI Calls (SubVI Not Busy) “top level” QElement DS PC QElement DS PC paramPtr Params param0 param1 Caller Data Space Callee Data Space Mutex curElem: NULL waitQ: empty Execution System – curElem
SubVI Calls (SubVI Running Caller) “top level” QElement DS PC QElement DS PC paramPtr Params param0 param1 Caller data space Callee data space Mutex curElem waitQ: empty Execution System – curElem
SubVI Calls (SubVI is Busy) “top level” QElement DS PC QElement DS PC paramPtr Params param0 param1 Caller data space Callee data space other caller Mutex curElem waitQ Execution System – curElem