thread and TSVs locks

Dear experts threads,

are there side effects if I use the macro "GetPointerTo" and "ReleasePointerTo" inside a thread lock, which is in the code located between CmtGetLock and CmtReleaseLock?

Phrased differently, what type of sequence is best if I need to edit a TSV in a piece of code that should be accessible only from a single thread at a time:

1)

CmtGetLock

...

CmtReleaseLock

GetPointerTo

...

ReleasePointerTo

CmtGetLock

...

CmtReleaseLock

OR

2)

CmtGetLock

...

GetPointerTo

...

ReleasePointerTo

...

CmtReleaseLock

Thank you!

Wolfgang

Hi, Wolfgang.

GetPointerTo... will block until the thread that holds the pointer releases, then the CmtGetLock() and CmtReleaseLock() calls are not necessary, unless they protect some other variables, in which case sequence 2) is the way to go.

Remember that if you use multiple thread safe variables or multiple locks thread, and you need to use more than one at any time, each thread must obtain and release pointers / locking in the same order. This avoids the possibility of blocking. In addition, each thread must release the resource as soon as possible.

Example (using thread locking):

If (!.) CmtGetLock (lock1))

{

If (!.) CmtGetLock (lock2)) / / Get QL2 only when you hold lock1

{

...

CmtReleaseLock (lock2);  Always communicated QL2 before lock1

}

CmtReleaseLock (lock1);

}

Kind regards

Colin.

Tags: NI Software

Similar Questions

  • Update of the screen, threading and synchronization

    I have a game I developed that uses multiple threads to process. The game does not focus on the user by itself and seems to be accelerating when there are more items on the screen and slows down when there is less. I have four threads in use. Three of them are used to update the main (UI) thread and run continuously; two update a class watch stop custom, and the third simply disabled the screen to force a refresh. All three of the threads use locks objects synchronized; That's why I think it slows down when nothing is on the screen, because they constantly block. I do not have variables that are constantly updated by the thread and read survival gear each iteration; which I was I use locks. I use the IDE 4.7 and the simulator of the storm. Profiling code over a minute 3 period shows that almost 60% of the execution time is during one of the locked rows (block I'm of course). I was wondering what I should use locks because only the UI thread updates one of the three? If so, is there a better way. Code can be provided if necessary.

    BUDOKAI-is that they have a book of text on the famine of lock?

    http://Java.Sun.com/docs/books/tutorial/essential/concurrency/starvelive.html

    [ed, I would also like to make out this seems to be a tight loop so that it also uses time spinning CPU]

    during the liberation that briefly up to 2 locks]

    While (true) {}
    synchronized (runLock) {}
    If {(race)
    synchronized (pauseLock) {}

  • My iTunes and AppStore locked permanently

    I create a id Apple 15 days ago and use to download apps two-step verification before two days I also activated my iTunes and AppStore Locke permanently at apple, I called 2 times known as my call to the Senior Adviser, then she told me your iTunes and AppStore Locke yo permanently can no longer use creat a new I download the round Apple about 200 the first day , she told me that our system detecting any unusual activity so your itume and AppStore locked permanently I also spent $ 50, what can I put now all help

    They told you why they had locked the account, which has been the "unusual activity"? Unless they agree to unblock the account, or possibly transfer the balance to a different account, there is no much you can do

  • If I take my iphone jailbroken 5s and icloud lock'd get another?

    If I take my iphone jailbroken 5s and icloud lock'd get another?

    Jailbreaking annuls all guarantees and loses all rights to maintenance and assistance.

  • Friends hahaha... I'm unable to re - activate my iPhone 5 years after updating to the latest version of OS i forgot my Apple ID. I know the password ID Apple and iPhone lock code. Also its my fingerprint reading. Unfortunately the option "Find my iPhone"

    Friends hahaha... I'm unable to re - activate my iPhone 5 years after updating to the latest version of OS i forgot my Apple ID. I know the password ID Apple and iPhone lock code. Also its my fingerprint reading. Unfortunately, option "Find my iPhone" is active... Could someone advise me please how can I reactivate my iPhone in this scenario?

    https://iforgot.Apple.com/password/verify/appleid#! & section = appleid

  • Windows 10 - FN button and touchpad lock/unlock button problem Satellite L675-11J

    Hello
    I have a Toshiba Satellite L675-11J and 10, lock/unlock FN key touchpad button do not work after upgrading to windows.
    Help, please!
    Best regards

    Fn keys require special Toshiba software that controls this feature for laptop.

    But Windows 10 drivers are not published for this series of Satellite L675 because is not win 10 supported.

    From my point of few, this means you can use Notepad as part of Win 10 but without the keys FN function.

  • Satellite C660 - keyboard does not work but the Num and caps lock shift are on

    I have a Satellite C660 which was working fine this morning. When I came home from work and he turned, the keyboard does not work and therefore can not enter my login information.
    The Num and caps lock shift are turned on.

    Any ideas on how to solve this problem?

    Hello

    You are able to disable the CapsLock and NumLock?
    You can access the BIOS by pressing F2 by turning on the device?

    If this does not work, I would recommend checking an external USB keyboard.
    If the USB keyboard would be functions, then this means that the internal keyboard is defective and must be replaced.

  • Satellite P500 (PSPE8A-01R002) - number pad and num lock does not

    Number pad and num lock on my P500 PSPE8A-01R002 does not work after the upgrade to Windows 7.

    Any help will be appreciated.

    Hi AndrewF,

    Have you noticed the same problem on a preinstalled OS from Toshiba?
    As far as I know Satellite P500 are always delivered with Windows 7 OS provided with your P500?

    Anyway, in your case I would try updating the BIOS. You can get the latest version on the Toshiba site.

  • Threading and reuse of the node to call using reference of buffers (of the required adhesive tape)

    I tried to get the following information in the public domain for years and now that I have the answers, I'll share with those who might be interested.

    Caveat!

    Wrap your head in tape before reading just for the sake of security.

    My two questions were;

    (1) may LV re - use tampons of VI calling when you use VI serve call by reference?

    (2) is used when the use of call by reference UI thread?

    1 when you call a VI using the call through the reference node, the data in the pane of the copied or is node connector - this online as it would be with a Subvi properly implemented?

    Short answer: it's somewhere between the two.

    Long answer:

    The compiler does not know what will be called VI, but there a hint:

    the reference connected to the node of the call by reference. He uses to get the 'Prototype' for the call. Therefore, for optimal performance, use a prototype that has the same 'characteristics placeness' as it is called VI. That said, users don't know what are the "characteristics of the placeness.

    Before getting into the details, I will say that the overhead of these copies should not matter much unless it's a large data structure (a table with lots of items.) or a cluster/class with many fields or containing large networks etc..

    Example 1:

    If the prototype does not change the data, then the compiler assumes that the crux of the call by reference will not alter the data. However, at runtime, a check is made to see if the real called VI will modify the data. If Yes, then a copy is made and past so that the original data can be modified.

    Example 2:

    If the prototype contains an entry that is wired through an exit so that both input and output terminals can use the same buffer memory, but running an audit determines that the real called entry and exit VI do not share a buffer, then a copy will be made from output of the actual call to the original screws (combined input and output) buffer.

    I should also mention that, even with this behavior "are trying to get along with the prototype", it is not always possible to obtain good performance as a Subvi ordinary call. For example, if you have a situation where the prototype does not change the data and passes it through to an exit and then the compiler must assume that the data is changed (because, as in example 2, there are screws that may change even if the called real VI is not).

    And there are a few caveats:

    (1) this behavior "using a prototype" was new for 2009. Before that, we used a method more naïve data of passage that took all the entries will be changed and no outputs don't share a buffer with an entry.

    (2) this behavior can be changed in future versions, if we find additional optimizations.

    (3) this behavior is the same that we use for the dynamic distribution live (when you use the classes in LV)

    (4) If you want to create a VI can be used as a prototype, you can use the features of the Structure in Place to control the "characteristics of the placeness', namely the element nodes in and out of the border, the function"Mark as modifier"border nodes (note the pencil icon on the item), and the node always one copy.

    (5) the prototype is only the first reference ever connected to the node of the call by reference. So if you make a new prototype VI, you can just make a reference out of it plug into the crux of the call by reference. I suggest to remove the node from the call by reference and file a new.

    (6) for remote calls, we still "making copies" by transmitting data over a network.

    I hope that this helps, if you want information/clarification, so feel free to ask.

    2 - is the call made by the reference to run in the user interface thread node? If the call is made by a remote machine via ethernet, thread that host (the computer that makes the call by reference) runs on and thread that executes the target (the machine that contains the file VI) on?

    In the case of premises, the appeal made by the reference node does not require the user interface thread and may work in some thread the VI wants to run in.

    When you call a remote VI, the appeal made by the reference node uses the UI thread (detailed below) on both the client and the server.

    The client uses the UI thread to send the request to the server and there still when the response comes back. The user interface thread is not blocked during the time between the two.

    The server receives the TCP message in the UI thread, and then starts the call to the UI thread. The server also uses the user interface thread to send the response to the client. The user interface thread is not blocked on the server during execution of the VI.

    I hope that people find it when they need it!

    Ben


  • Why peope post Questions that are not really questions and are locked from future responses?

    Why peope post Questions that are not really questions and are locked from future responses?

    These positions are known as sticky messages, Faustin - Sticky post' a sticky or sticky post is a type from which a topic in a forum online that is "pinned" near the top of the forum index, enhance its visibility and prevent it to be buried by newer messages. "  "

  • Caps lock and num lock keys lights don't light up

    Hello

    My caps lock and num lock keys lights don't light up when I turn the plugs or NumLock on, I recently contacted Microsoft Tech support, they told me to contact my HP manufacturing and it's a laptop, they did ' t really gives me a lot of support, so I'm here without you people asking how to solve this problem.

    Thank you
    Marco

    Hello Marco818,

    Thank you for your message.  Microsoft was right to put you in touch with the manufacturer of your.  The keyboard will fall under the material, so only they can fix or diagnose what the problem.  It could be something as simple as a bad supply or burnt cable bulb.  Anyway, that falls under HP support.

    See you soon

  • White screen on Boot and CAPS lock and NUM lock LED blinking on HP Pavilion dv - 6 portable 1210sa

    Hello

    I'm on HP Pavilion dv6 - 1210sa laptop with Windows vista Home Premium (service Pack2). It's the operating system, which is that the laptop came with when I bought in 2010 and later service pack 2 was installed using windows update. I can confirm that my laptop is up-to-date with updates of windows and hp installed periodically. My problem is the following:

    Everytime I turn on my laptop, I can hear the noise from the cooling fan and the led power and feather touch volume buttons and a wi - fi light up. However, the screen remains blank and the CAPS lock and NUM lock Dungeon LED flashing with three second gap between two flashes. They Flash together and blink only once in a single cycle. It keeps flashing even after leaving it for 10 minutes. I have to perform the hard reset several times before I can get it started. This problem started a few months ago with the frequency of the problem more and more. It has now reached a point where I encounter this problem on every start and even after the awakening of the laptop computer from standby or hibernation.

    I know that the flashing of the LEDs is typical diagnoses, but I was unable to understand the real problem. I know the screen works because I tested using an external monitor to work. It should not be the battery (even if it's crap to maintain charge) I tried to restart the laptop with just AC adapter connected (and battery removed) after having done a hard reset and still, the situation did not improve.

    Could someone please tell me what is the problem and what are my options? Think you that formatting my c: / and re - install the OS will solve the problem?

    Thank you.

    Please come back to me

    As long as you keep your files backed up on the outside, it is to you how you want to proceed. First question, however, is you are in warranty or not? If you are in warranty, Yes, call telephone support and will take care to have it sent repair.

    If you are no longer in warranty, however, that the repair can be expensive. You could certainly call for an exact quote, but according to the availability of the room, it might be around $200 and for an out of warranty repair. Money would probably be much more effective if they are presented to a new computer.

    HP Total Care 1-800-474-6836

    BUT, if you're still able to get the it to power (after trying it several times) and you're OK with the disadvantage, it would be nice to hold off on buying a new computer until it failed completely. I hate this word like that but I want to be realistic with you. I'm sorry that you are having this problem. As I said though, your files are the priority. Keep all your documents and photos and other precious files saved on an external hard drive or flash drive. Let me know if you have any other questions

  • Thread and class with no thread

    Hi everyone , hope you can help me with this...

    I have two classes, extends a Thread and the other extends screen. My problem is that the screen needs all the information that the thread has had, but I do not know how to make the screen show upward when the thread is finished, or wait until this thread stops to see its information.

    Thanks in advance

    At the end of your thread, you can push the screen with:

    synchronized (UiApplication.getEventLock) {}

    UiApplication.getUiApplication () .pushScreen (yourMainScreen);

    }

  • problem with thread and try {} - catch () {}

    Hello

    My problem is that in the second thread of my request, there is a method (at the beginning) that connects with the server. If the connection is impossible-i try to reconnect two times. the problem is that the connection must by in a try-catch block. and when I can't connect for the first time, the program will the something something trying to reconnect. and the problem is that once my progam enters this something, the thread is dead!

    Do you have any suggestions, what can I do with it?

    concerning

    I reorganized my request. whenever I see that the thread is killed (with an exception of capture) I wait 2 seconds and start the thread. and it works like a "reconnect".

    Thank you for your time and suggestions!

    Kind regards

  • threads and processes

    What is the difference between threads and processes?

    Hi Shams,

    Process of

    A process, in simple terms, is a running program. One or more threads run in the context of the process.

    Each process provides the resources needed to run a program. A process has a virtual address space, executable code, open the handles to system objects, a security context, a process environment variables, unique identifier, a class of priority, minimum and maximum working set size and at least a thread of execution. Each process is started with a single thread, often called the main thread, but can create additional threads in any of his sons.

    Thread

    A thread is the basic unit to which the operating system allocates time processor. A thread can execute any part of the process code, including parts being run by another thread.

    A thread is the entity within a process that can be scheduled for execution. All threads in a process of shared system resources and the virtual address space. In addition, each thread manages handlers exceptions, a scheduling priority, threads local storage, a single thread identifier and a set of structures, that the system uses to save the thread context until it is scheduled.

    If you have additional questions, feel free to post. We are here to help you.

Maybe you are looking for