Why is the Tick Count function slow when used with a .dll but fine with normal lab view code?

when using the Tick Count millisecond timer with a .dll I've written in C, I'm getting some odd timing issues.
When I code the function I want (I'll explain it below in case it helps) in LV and run it as a subVI, feeding it the Tick count as an argument, the function runs quickly, but not quite as quickly as I would like. When I feed this same subVI just an integer constant rather than the Tick Count, it takes about the same amount of time, maybe a tiny bit more on average.
When I bring in my function from a .dll, however, I start to run into problems. When I feed my function an integer constant, it is much faster than my subVI written in LV. When I feel my .dll the Tick Count, however, it slows down tremendously. I'm including a table with the times below:
             |  Clock   |   Constant   |
SubVi:   | 450ms  |  465ms       |
.dll         | 4900ms|  75ms         |
This is running the function 100,000 times. The function basically shifts the contents of a 2-dimensional array one place. For this function, it probably won't be a huge deal for me, but I plan on moving some of my other code out of LV and into C to speed it up, so I'd really like to figure this out.
Thanks,
Aaron

Hi Aaron,
Thanks for posting the code -- that made things a lot clearer for me. I believe I know what's going on here, and the good news is that it's easy to correct! (You shouldn't apologize for this though, as even an experienced LabVIEW programmer could run into a similar situation.) Let me explain...
When you set your Call Library Function Node to run in the UI Thread you're telling LabVIEW that your DLL is not Thread-safe -- this means that under no circumstances should the DLL be called from more than one place at a time. Since LabVIEW itself is inherently multithreaded the way to work with a "thread-unsafe" DLL is to run it in a dedicated thread -- in this case, the UI thread. This safety comes at a price, however, as your program will have to constantly thread-swap to call the DLL and then execute block diagram code. This thread-swapping can come with a performance hit, which is what you're seeing in your application.
The reason your "MSTick fine behavior.vi" works is that it isn't swapping threads with each iteration of the for loop -- same with the "MSTick bad behavior.vi" without the Tick Count function. When you introduce the Tick Count Function in the for loop, LabVIEW now has to swap threads every single iteration -- this is where your performance issues originate. In fact, you could reproduce the same behavior with any function (not just TIck Count) or any DLL. You could even make your "MSTick fine behavior.vi" misbehave by placing a control property node in the for loop. (Property nodes are also executed in the UI thread).
So what's the solution? If your DLL is thread-safe, configure the call library function node to be "reentrant." You should see a pretty drastic reduction in the amount of time it takes your code to execute. In general, you can tell if your DLL is thread-safe when:
The code is thread safe when it does not store any global data, such as global variables, files on disk, and so on.
The code is thread safe when it does not access any hardware. In other words, the code does not contain register-level programming.
The code is thread safe when it does not make any calls to any functions, shared libraries, or drivers that are not thread safe.
The code is thread safe when it uses semaphores or mutexes to protect access to global resources.
The code is thread safe when it is called by only one non-reentrant VI.
There are also a few documents on the website that you may want to take a look at, if you want some more details on this:
Configuring the Call Library Function Node
An Overview of Accessing DLLs or Shared Libraries from LabVIEW
VI Execution Speed
I hope this helps clear-up some confusion -- best of luck with your application!
Charlie S.
Visit ni.com/gettingstarted for step-by-step help in setting up your system

Similar Messages

  • Why is the word count function inaccurate in tables?

    Why, when using tables in pages the word count function gives a total that is double the amount of words in the table? This has been a problem with Pages for sometime now. Additionally, is there a quick way of highlighting all the words in the table to give a word count total, similar to highlighting a paragraph, sentence or just a few words?

    Pages v5.2.2 (and probably 5.5) will total all the words in the body of a document (including those in a table) accurately in my experience. Since the Pages v5 family does not permit non-contiguous text selection, your only other way to count just words within the table is from the Statistics component of the free WordService Services package. Just select the table, and then from the Services menu, choose Statistics. The word count matches the table contents.
    Unfortunately, the AppleScript dictionary  for the Pages v5 family excludes any means to address words or characters within cells. The fact that Pages is counting words in the table, is due to native programming, and not AppleScript.

  • Why is the MPE so much better when using Vista?

    I get more realtime playback using Windows Vista than When using Windows 7 with HDV. I can get better GPU and CPU playback both when using Vista for HDV. Why is that? Im using a GT 240 and it kicks *** with Vista. I use a second LCD TV monitor as an NTSC monitor for the realtime previews. I do get some realtime with Windows 7 but only about half as much as with Vista. Something is better about Vista for HDV clips but Idon't know what. I have done several fresh installs and updates. What gives? Any thoughts.

    I have done fresh OS installs and Windows updates. The GT 240 was added the same way. For HDV the Vista OS is better. For AVCHD they are about the same.  I think it is a bug. It works better using Windows 7 if I don't output to the LCD TV monitor. Do any of you use HDV and preview on a NTSC monitor?

  • Why cant the controlfile be in sync, when using backup controlfile

    hi all,
    i understand a few point ...from a dba friend of mine..
    you need a resetlog to sync the datafile headers and the controlfiles
    1) you need a resetlog when doing incomplete recovery
    2) you can recovery completely using a backup controlfile provided you have all the necessary archived logs and online redo logs.
    3) but in order not to do resetlog after 2) , you must re-create the controlfile
    my questions are
    q1) are the following point above true ?
    *q2)  why cant oracle update the controlfile when recovering using the backup controlfile ? in that case, i do not need to recreate a controlfile , isnt it ?
    Rgds,
    Noob

    user12050668 wrote:
    hi hermant,
    q1) why would i need to open the database with resetlog ?
    Yes. i am using a backup controlfile, but i have all the archived and online redologs till point of failure ?
    The purpose of a resetlog is to sync the controlfile and datafile headers , isnt it ? but i do not need to sync, as i have all the latest applied
    am i right ?
    If you use RECOVER DATABASE USING BACKUP CONTROLFILE in this case control file type is *"BACKUP"* but not *"CURRENT"* due to even you have all archivelogs and online logs you have to open database RESETLOGS statement.Actually after applying all archive and online redo logs ALTER DATABASE OPEN RESETLOGS internally sync and "Say" to control files "RECOVER FINISHED".Because CF type is BACKUP.
    q2) You need to OPEN RESETLOGS. You can choose to create controlfile OR not create controlfile (i.e. open with the backup controlfile that was used for the RECOVER).
    If you do a CREATE CONTROLFILE it has to be CREATE CONTROLFILE RESETLOGS, followed by ALTER DATABASE OPEN RESETLOGS.
    in what circumstances, would i need to re-create the controlfile when i can still use the backup controlfile ? as in any case, i would still need to resetlog.
    Rgds,
    NoobIf you have backup controlfile then do not need recreate control files.And you need use backup control file.If you lost all backup of control files and copies then or you want change database name then you can use RECREATE CONTROL FILE again.

  • Using OSX 10.9.4.  Why does the Finder Menu bar disappear when using Chrome?

    I've used Chrome for a couple years, and all of a sudden the Dock and the Finder Menu bar are not accessible when using Chrome.  They are present in every other app, as usual.  Please help me to get the Finder Menu and Dock active when using Chrome.  Thank you.

    Chrome may somehow be set to run in full-screen mode. I don't use Chrome so can't check its settings options, but try hitting ESC when Chrome is doing this and see if you get the menubar and Dock to reappear.
    OS X Mavericks: Take apps full screen

  • Why is the select Count too slow

    I am doing the following select count and calling it from my JSP to get the total number of records... why is it so slow...
    select count(*)
    from
    (select distinct o.receive_id, o.name, o.address
    from order o, item i
    where o.id = i.id
    and o.status = 2 and i.status = 0)

    If the data in the table that you are referring to in the query gets refreshed very often and your high water mark on your table not reset, then this query always runs longer. While deleting data in the table, use 'TRUNCATE' rather than 'DELETE' in your data queries. that would help reset the high water mark and your count() queries will run very very fast.

  • Why is the Camera app so slow when switching modes?

    When I switch modes between still-photo and video (or back) in the Camera application, there is a 2-3 second pause while the "iris" appears and disappears. Ok, that's not very long, but when you are in a rush to capture "that moment" it can be all the difference between "great" and "rats!".
    I get that an app can take a few seconds to load, but switching camera modes should be nearly instantaneous, shouldnt it? Do other people see the same delay, or is it just me? Are there any known tweaks to improve this delay?
    On an iPhone 4 with latest iOS.
    --Tim

    I don't know why Apple doesn't fix this problem or even acknowledge it. I have had this problem since 1.1.2. Upgrading through 1.1.3, 1.1.4 and on the 2.1 has not helped. My SMS loading time varies between 3 and 10 seconds. I maintain all my SMS messages deleted (which I should not have to do). Due to lack of support from Apple I purchased a Nokia phone for my son. At least basic phone features work like they should.

  • Why does SRS-X3 have intermittent sound when used as speakerphone? Works fine w/Pandora - same cell

    Recently purchased an SRS-X3, primarily for use as a speaker phone.  When linked with my cell phone and using Pandora, the sound is great.  But, if I try to use it as a speaker phone, the sound breaks into intermittent bits that sound like regular intervals of sound and silence and makes the conversation coming in unintelligible.  The sound going out to the other person on the phone does not seem to have this limitation (although I can't say this for sure, because it's hard to conduct this test when you can't hear a darn thing coming in.)
    Any suggestions?  I can't find anything in the experience base that refers to this phenomenon. 

    The Vine video has video/mp4, so MP4 support needs to be present and working on your computer to make this work.<br />
    I needed to bring up the controls via the right-click context menu (Show Controls) and adjust the volume as the volume appeared to be set to zero to get sound.
    You can try these steps in case of issues with web pages:
    Reload web page(s) and bypass the cache to refresh possibly outdated or corrupted files.
    *Hold down the Shift key and left-click the Reload button
    *Press "Ctrl + F5" or press "Ctrl + Shift + R" (Windows,Linux)
    *Press "Command + Shift + R" (Mac)
    Clear the cache and cookies only from websites that cause problems.
    "Clear the Cache":
    *Firefox/Tools > Options > Advanced > Network > Cached Web Content: "Clear Now"
    "Remove Cookies" from sites causing problems:
    *Firefox/Tools > Options > Privacy > Cookies: "Show Cookies"
    Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions (Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance).
    *Do NOT click the Reset button on the Safe Mode start window.
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes
    Note that your System Details List shows that you have a user.js file in the profile folder to initialize some prefs on each start of Firefox.
    The user.js file is only present if you or other software has created it, so normally it wouldn't be there.
    you can check its content with a plain text editor if you didn't create this file yourself.
    The user.js file is read each time you start Firefox and initializes preferences to the value specified in this file, so preferences set via user.js can only be changed temporarily for the current session.
    *http://kb.mozillazine.org/Preferences_not_saved

  • PO PDF errors when using custom RTF Template, but works with custom xsl

    Hi,
    I have done following set up steps for PO PDF
    Setup / Organizations / Purchasing Options / Control TAB / set 'PO Output Format' = 'PDF'
    setup / purchasing / document types / select "Standard Purchase Order" / Set the Document Type Layout to your new template.
    But with the RTF template the PO Output for communication completes with error. However when I use custom XSL-FO style sheet, it works.
    Can anyone help me how I can make my RTF work? When click on the preview of the template, it shows the PDF output though. Am I missing any other set up steps? Your help is greatly appreciated.
    Thanks,
    Sharmila

    I think the only way to have control over the html output is to enclose the tags or any information within a borderless table and align the text and table as necessary...
    Thanks,
    Bipuser

  • Impact of Function Modules when used in upgraded versions

    Hello Experts,
              I wan to know the Impact of Function Modules when used in upgraded versions. How the function module works irrespective of changes done to it in the latest verisons
    Thanks in Advance

    Hi,
    If the function modules is released, it should not have any impact. However if not released, use them with caution as SAP does not support non-released function modules.
    Cheers.
    ...Reward if useful.

  • When does the tick count start

    I see that the tick counter rolls over at 2^32 ms, that's 49 days.  So if the counter started when Labview or the VI starts, I would never care about the rollover. 
    So when does it start?  Can I control when it starts?     I need a resolution less than 1 sec, so the second timers don't help me.
    Also do other funtions or VIs continue to operate when a Wait (ms) function is running?

    The tick count does not begin when you open LabVIEW or the VI. The on-line help says that the base time is undefined. There is however, no problem with you taking the tick count when you first start the VI and using that later in the VI. It's also untrue that the other time functions in LabVIEW only have 1 second resolution. They have the same millisecond resolution as tick count. If you have code in parallel with the Wait (ms) function, they will exeucte in parallel.
    Also, in the future, post questions of this nature to the LabVIEW board. This board is for the NI counter/timer boards.

  • Why is the word count different when I use word count from the tools menu to the number at the bottom of my mac word document

    Why is the word count different when I use word count from the tools menu to the number at the bottom of my mac word document

    This forum is for Apple's defunct office suite 'AppleWorks' - since the word count is not in the places you mention I assume you are talking about Microsoft Word? Though it's just possible someone in this forum might also use Word and know the answer, you would stand a higher chance of getting an answer in Microsoft's own forums. You could also try asking in the forum applicable to your operating system - Lion, Mavericks or whatever - on the reasonably chance of finding someone familiar with Word.

  • Why does the page not move smothe when i scroll?

    Why does the page not move smothe when i scroll?
    Sometimes it even move slower then i Scroll?
    I use a Mac and i have tried to reinstall the program.

    Start Firefox in [[Safe Mode]] to check if one of the add-ons is causing the problem (switch to the DEFAULT theme: Tools > Add-ons > Appearance/Themes).
    * Don't make any changes on the Safe mode start window.
    In Firefox 4 [http://kb.mozillazine.org/Safe_mode Safe mode] disables extensions and disables hardware acceleration.
    * Tools > Options > Advanced > General > Browsing: "Use hardware acceleration when available"
    See:
    * [[Troubleshooting extensions and themes]]

  • Why is the iphone search function spotlight limited in time?

    why is the iphone search function spotlight limited in time? I can only find entries that are less than a year old,but I would like to search older entries in my calender, which goes back to 2002. Anyone has a solution for this?

    Are you sure that your calendar still contains entries from that long ago? Generally when you sync the iPhone through iTunes, it will only sync entries from a specific time frame. It may be there older entries have been archived and do not exist on the iPhone anymore. Other than that, I don't see any setting that allows modification to the time frame for Spotlight search.

  • How long does a tick last for the Tick Count (ms) VI in LabVIEW?

    I'm trying to compare the timing performance between a VI implemented in LabVIEW and another VI implemented in LabVIEW FPGA module. If I use the Tick Count in both VIs (every one in their own module), I want to know how long does a tick last in LabVIEW standard (in the computer)?
    Thanks

    vitrion wrote:
    I have this doubt because I read that a tick lasts 55ms in the following source:
    http://books.google.com.mx/books?id=en1GKs2huTcC&pg=PA33&dq=tick+count+(ms)+labview+55+milliseconds&...
    My tick count provides me better results than the hardware results, which is impossible because this is the same algorithm. If I consider the 55ms time, then the FPGA is really faster.
                              Hardware          Software with                  Software with
                                  (ms)        1 ms Tick Count (ms)     55ms Tick Count (ms)
    Algorithm 1          49.48                   1.5552                               84.535
    Algorithm 2         0.8875                  0.032                                 1.87
    Algorithm 3         0.1756                  0.0241                               1.43
    Algorithm 4          0.27                     0.27                                   1.32
    What's your opinion?
    Thanks again
    I think you are misunderstanding what the value of a "tick" is.  From what I gathered from reading your link (which I couldn't get to from your post, but accidentally ran into on a search) a tick of the OS clock."  Curiously, though - why 55ms?  That was mentioned as the tick of a Win95/98 OS!
    I guess you can say that the it returns the value of the next "tick" of the OS clock and returns that value in ms.  So, the value of a tick varies from OS to OS.  In Windows 95/98, for example, you can only look at the OS clock every 55ms or so, but it still returns a value that represents ms.
    Bill
    (Mid-Level minion.)
    My support system ensures that I don't look totally incompetent.
    Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.

Maybe you are looking for

  • Error 1310 while installing itunes, config.msi folder missing, Vista home edition.

    I get the following error when installing itunes 10.5.3 on my Windows Vista 32Bit premium home edition: Error 1310. Error writing to file: C:\Config.Msi\4361d.rbf. Verify that you have access to that directory. I cannot find the folder mentioned abov

  • Linking two queries

    I am having trouble linking two queries in my data table. The first query finds the maximum of a certain set of information, has the breakorder set at asending and orders them by a set of numbers in that query. A coordinate (ie. x and y) field is bas

  • Can I center the text in vertical direction in JTextArea

    for example , if the JTextArea is 50 pixels high, and the text 's height is 20 pixels, then how can I center the text in vertical direction in this JTextArea which means there is a extra space whose height is 15 pixels over and under the text?

  • Jesiinclude example written bx Srikanth

    i could compile/start the example inside Oracle Jdeveloper 9.0.4 without any problems ! after the deployment to Oracle 9.0.3 AS the first page will be displayed followed by the ERROR Message: 500 Internal Server Error java.lang.NoSuchMethodError     

  • Smart Zoom in Safari 7/Mavericks?

    After the upgrade to Mavericks Smart Zoom seems not to work in Safari.  Is there a way to re-enable the convenient zooming in of a web page by double tapping my magic mouse?