Thread thread function ID vs ID

Hello

I'm afraid I don't really understand the difference between a thread ID and an ID of service of thread or formulated differently, what is the purpose of the thread ID and why both are needed?

For example, use CmtScheduleThreadPoolFunction returns a thread ID function, which is used later to get a thread ID.

Function calls such as PostDeferredCallToThread, the identifier of the thread is necessary, which can be obtained only for the thread underway through CmtGetCurrentThreadID, in the contrary case, to know the ID of thread function to get the thread what ID... seems a bit complicated

-Why can't I use the function thread ID only?

Thank you in advance for the explanation...

Wolfgang

I think the analogy works, but use of "thread-ID function" Wolfgang is a bit mixed upward:

employee == thread (has a thread ID)

task is function thread (a thread ID of function)

The thread pool maintains a lot of idle threads that are sitting around waiting for work (walking on the intended function). When a thread finishes its task, it is not destroyed; It just goes back in a State of inactivity waiting for more work. For this reason, it makes sense that the thread ID persists. On the other hand, if the same function is scheduled to run repeatedly, every time that it runs, it will have a new ID of thread function. A thread function ID represents a particular instance of a service running on a ThreadPool thread.

A. Mert

National Instruments

Tags: NI Software

Similar Questions

  • SetCtrlVal used during the Thread function works causes memory leaks

    I am writing a program that works if... Or not work if... - see the next lines... :-)...

    The program includes a section, mostly GUI - and User Interaction.

    The other part is a DLL. In the DLL we readings on an external consultant controller RS232. Sometimes the controller card needs (called how much) time and this time must pass then the result can be read card controller... and so on...

    Blocking is not GUI-user-program for the expectation of the return value of the DLL functions (which need a few seconds to be finished) I start a thread in the DLL with

    CmtScheduleThreadPoolFunction (DEFAULT_THREAD_POOL_HANDLE, THREAD_FunctionX, & tmpTFP, NULL);

    with "tmpTFP" as an instance of type "TYPE_THREAD_FUNCTION_PARAMETERS":

    typedef struct
    {
    //
    int IntVal1;                // 1. Integer-Wert
    int IntVal2;                // 2. Integer-Wert
    int IntVal3;                // 3. Integer-Wert
    int IntVal4;                // 4. Integer-Wert
    int IntVal5;                // 5. Integer-Wert
    //
    int IntBuffer1 [32];            // 1. Integer-buffer (aktuell genugt einer)
    //
    Double DblVal1;                // 1. Double-value
    Double DblVal2;                // 2. Double-value
    Double DblVal3;                // 3. Double-value
    Double DblVal4;                // 4. Double-value
    Double DblVal5;                // 5. Double-value
    //
    char CharVal1;                // 1. (Single)- Tank-Wert
    char CharVal2;                // 2. (Single)- Tank-Wert
    char CharVal3;                // 3. (Single)- Tank-Wert
    char CharVal4;                // 4. (Single)- Tank-Wert
    char CharVal5;                // 5. (Single)- Tank-Wert
    //
    char CharBuffer1 [1024];        // 1. Char buffer (akutell einer genugt)
    //
    } TYPE_THREAD_FUNCTION_PARAMETERS;

    In the GUI-user program - I get fast by default-return value of the thread start function.

    Then I asked the DLL (some global state variables are used for this) when it is finished.

    According to the map-controller (RS232) contacted the waiting time depends on the 'mood' of the controller card.

    In the DLL-mark of the GUI-user-program routine now everything works fine - without using "SetCtrlVal!"

    In my GUI, there is a text box of the info/comment for messages. If I do a few outputs user using 'SetCtrlVal' I always errors, caused by the false "TYPE_THREAD_FUNCTION_PARAMETERS"-values in the service of thread. "» If I set a breakpoint at the beginning thread-function I see mostly erroneous values in my transfer structure variables. If I put a breakpoint in the thread-function-calling 'CmtScheduleThreadPoolFunction (...)"and at the beginning of the thread values are (mostly) correct!

    I tried several and different things - but:

    If I ONLY (!)  Commenting on the (!) of a line with "SetCtrlVal", the program works, all States are asked out of the DLL.

    If I replace the "SetCtrlVal" with a written record-file function clean everything works fine and after completing the program I can look at the log file and see all the user information. BUT with 'SetCtrlVal' instead or set or (...) it does not work.

    My description is maybe not entirely clear, but believe me: only ONE line the «SetCtrlVal "line - should be commented out to let the program run properly!»

    Because if the line "SetCtrlVal"is program-user-GUI, after the call to the thread in the DLL, the DLL-memory seems to be corrupted by the call "SetCtrlVal" in the user-GUI program.»

    Best regards

    F.

    There may be a problem in your structure that your variable is set.

    You said that, after the address of the variable in the thread function the appellant one ends. Now, as you can read help each value passed in parameter threadFunctionData of the layed function must point to an area of memory that persist when the fuction is running: If your variable is defined at the level of the functions it is not valid when the thread runs since the appellant finished and released its local memory.

    Your approach with a global variable is a valid alternative, but if it is the solution, you will find data passed to the thread function must be valid for all his life.

  • Please tell us how to remove the 'message thread function' in the column 'Object' of my Inbox.

    Hello!
    For some reason, the column of the object on the Inbox of my e-mail account now has the topics of conversation. I have no idea how the son got there - and you would appreciate the help in eliminating these threads.
    Thanks a lot for your help.

    In the main menu bar:
    View (Alt - V) - sort by - Unthreaded

  • Thread: Function conflict, reference static VI

    Hello community,

    Sorry if this has already been answered before, but I spent an hour looking. I try to learn a little more about using subVIs to clean up my code.

    I'm trying to connect a static VI reference of a Gaussian function I made to the non-linear curve Fit.vi, but I get a cut wire that says "feature conflict".

    When I create constants for the release of my Gaussian VI and the entrance to the Fit.vi curve nonlinear, they are clearly different classes.

    Could someone show me how to change my Gaussian VI to match the class correctly? I would be very happy.

    Thank you

    -Patrick

    Your Subvi model needs a connector model that is identical to the model. Start with the model mentioned in the help and change only the code, not existing controls and indicators. Simply leave it unplug unused terminals, do not delete.

  • On the hyper-threading technology

    Hello. I rather heard a lot of the inefficiency of the Hyper-Threadyng, especially that it is a useless load of each carrot with two operations. Efficiency can be no more than 30% and not always. Should I turn off this function or not? If I have to, I need to know how. After all, there are not these settings in the BIOS of my laptop (HP Envy 15 j-001er).

    P.S. This thread has been moved to storage > General for laptops - pavilions, Presario. -Forum moderator hp

    > There is not these settings in the BIOS of my laptop

    Then you can not turn it off.

    But don't you worry.

    If the performance with Hyper-Threading disabled technology is 100%, then with Hyper-Threading active technology, the heart of processor can achieve a level of performance which is between 100 and 130%, depending on the characteristics of the workload.

    In the first generations of Intel processor with Hyper-Threading functionality, some workloads could cause a Hyper-Threading performance drops to<100%, however="" that="" was="" fixed="" in="" the="" prescott="" architecture.="" the="" prescott="" architecture="" was="" released="" in="" 2004="" -="" that="" is,="" 10="" years="" ago.="" modern="" intel="" processors="" with="" hyper-threading="" enabled="" should="" always="" perform="" at="" least="" as="" well="" as="" with="" hyper-threading="">

  • I7 Intel hyper-threading processor (only every second core is used)

    Dear users,

    the "CPU Information.vi" gives me the following result (see "CPU Information.png"). When I run a Labview vi, only four cores are used (see "CPU usage.png"). I believe that my processor has 4 physical cores and hyper-threading functionality: http://ark.intel.com/products/48500/Intel-Core-i7-880-Processor-8M-Cache-3_06-GHz

    Do you have an idea how use also other virtual hearts as well, please?

    Kind regards

    M


  • Two threads in a Panel

    Hello
    I am developing a vision with CVI application that loads the files. VBAI after login... the application interface has two positions (left and right)... I want the two buttons START calls the same function CVICALLBACK (Inspection)... and this function call the function ThreadFunction and its parameter's thread (thread number)...
    I said two tables of the elements to control the two threads and I worked on these tables in the treatment ThreadFunction function...
    Now, I didn't understand how I spend the number of thread for the CVICALLBACK inspection function, in fact, when I click START on left position inspection begins on the left, where it starts on the right, also, if I click on the two positions, she sailed on two positions...
    Thank you for your help, it's urgent

    #include 
    #include 
    #include 
    #include 
    #include 
    #include "toolbox.h"
    #include "nivision.h"
    #include "VBAIInterfaceC.h"
    #include "ann.h"
    
    static int panelHandle;
    static CmtTLVHandle tlvHandle = 0;
    static volatile int exiting = 0;
    
    static int Tab_serial_num[2]={PANEL_SERIAL_NUM,PANEL_SERIAL_NUM2};
    static int Tab_inspec_name[2]={PANEL_INSPECTION_NAME,PANEL_INSPECTION_NAME2};
    static int Tab_inspec_butt[2]={PANEL_INSPECT_BUTTON,PANEL_INSPECT_BUTTON2};
    static int Tab_ecr_acc_stat[2]={PANEL_ECR_ACC_STAT,PANEL_ECR_ACC_STAT2};
    static int Tab_led_metro_stat[2]={PANEL_LED_METRO_STAT,PANEL_LED_METRO_STAT2};
    static int Tab_led_vert_stat[2]={PANEL_LED_CPL_VERT_STAT,PANEL_LED_CPL_VERT_STAT2};
    static int Tab_led_rouge_stat[2]={PANEL_LED_CPL_ROUGE_STAT,PANEL_LED_CPL_ROUGE_STAT2};
    static int Tab_led_jaune_stat[2]={PANEL_LED_CPL_JAUNE_STAT,PANEL_LED_CPL_JAUNE_STAT2};
    static int Tab_lcd_off_stat[2]={PANEL_LCD_OFF_STAT,PANEL_LCD_OFF_STAT2};
    static int Tab_lcd_on_stat[2]={PANEL_LCD_ON_STAT,PANEL_LCD_ON_STAT2};
    static int Tab_main_window[2]={PANEL_MAIN_WINDOW,PANEL_MAIN_WINDOW2};
    static int Tab_test_stat[2]={PANEL_TEST_STATUS,PANEL_TEST_STATUS2};
    static int Tab_text_error[2]={PANEL_ERROR_TEXT,PANEL_ERROR_TEXT2};
    
    void DisplayError(VBAIError error);
    void ButtonStatDisplay(void);
    void IndicatorStat(int ind, bool32 stat ) ;
    static int CVICALLBACK ThreadFunction (int thread) ;
    
    /*static int SetupApplication (void);
    static int ShutdownApplication (void);*/
    
    int main (int argc, char *argv[])
    {   
    
        if (InitCVIRTE (0, argv, 0) == 0)
            return -1;  /* out of memory */
        if ((panelHandle = LoadPanel (0, "ann.uir", PANEL)) < 0)
            return -1;
    
    ...;
    
        ...;
    
        DisplayPanel (panelHandle);
        RunUserInterface ();
        DiscardPanel (panelHandle);
    
    if (stepResults != NULL)
        free (stepResults);
        vbaiCloseConnection (session, 1)  ;
    
        return 0;
    }
    
    void DisplayError(VBAIError error)
    {
        ...;
    
    void IndicatorStat(int ind, bool32 stat )
    {
        ...;
    }
    
    int CVICALLBACK INSPECTION (int panel, int control, int event,
            void *callbackData, int eventData1, int eventData2)
    {
        VBAIError error = VBAIErrorSuccess;
    
        switch (event)
        {
            case EVENT_COMMIT:
    
                !!!!!!!!! The problem !!!!!!!!!!                       
    
            break;
    
        }
        if (error)
            DisplayError(error);
        return 0;
    }
    
    static int CVICALLBACK ThreadFunction (int thread)
    {   
    
    ....;
    
            while(!exiting){
    
                    SetCtrlAttribute(panelHandle,Tab_inspec_name[thread],ATTR_DIMMED,0);
    
                         ;
    
                            switch(i) {
                            case 0: IndicatorStat(Tab_ecr_acc_stat[thread],inspectionStatus);
                                     break;
    
                            case 1: IndicatorStat(Tab_led_metro_stat[thread],inspectionStatus);
                                    break;
    
                            case 2: IndicatorStat(Tab_led_vert_stat[thread],inspectionStatus);
                                    break;
    
                            case 3: IndicatorStat(Tab_led_rouge_stat[thread],inspectionStatus);
                                    break;
                                   ;
    
                            case 4: IndicatorStat(Tab_led_jaune_stat[thread],inspectionStatus);
    
                                   break;
    
                            case 5:IndicatorStat(Tab_lcd_off_stat[thread],inspectionStatus);
    
                                   break;
    
                            case 6: IndicatorStat(Tab_lcd_on_stat[thread],inspectionStatus);
    
                                   break;
    
                         }
    
                         Delay(0.5);
                         ...;
    ...;
    ...;
    

    Hi schweini,.

    Your thread function prototype doesn't seem correct.

    His entry should be a void pointer, not an integer.

    To switch to the thread of your button on which it started, you can use this setting.

    But you will need to pass a pointer to a valid variable.

    In your feed, you will get the value of the data pointer dereferencing.

    Here's a code sample (nickname).

    See if it makes sense.

    //in your Start callback
    static int start; //static is crucial here
    
    switch (event)
    {
      case EVENT_COMMIT:
        start = (control == PANEL_START_1 ? 1 : 2);
        CmtScheduleThreadPoolFunction (pool, ThreadFunction, &start, &funcId);
      break;
    }
    
    //in your thread function
    int CVICALLBACK ThreadFunction (void *data)
    {
      int which_side;
    
      which_side = *((int*)data);
    
      while (!exiting)
      {
        if (which_side == 1)
        {..}
        else
        {..}
      }
    }
    
  • Threads and passing parameters to it

    Hello everyone,

    now I play with sons and I am wondering how to change the setting to the thread function.

    I created a thread function is

    void CVICALLBACK (char id [], char value []) doThread

    {

    do something

    }

    and I want to call the thread like this

    CmtScheduleThreadPoolFunction (DEFAULT_THREAD_HANDLE, doThread(FIX_ARG1,FIX_ARG2), NULL, & threadID);

    But somehow, it does not work. How can I pass strings to the thread function?

    Thank you all...

    Common to pass data to a thread is to pick everything up in a structure, and then past the address of this structure to the function that installs the thread. Then tapped him, cast the parameter passed to a pointer of type structure, and you can then reference the data. As:

    typedef struct {}

    int executed;

    Short flag;

    char string [32];

    } structThread, * pstructThread;

    ...

    structThread tData;

    ...

    tData.run = 1;

    CmtScheduleThreadPoolFunction (..., & tData,...)

    ...

    int MyThread (void * param) {}

    pstructThread td = param (pstructThread);

    so that {(td-> run)

    ...

    }

    return 0;

    }

    JR

  • Thread synchronization

    Hi all

    I don't really know how to work the Blackberry UI thread!

    I have the function run a thread in which I make my travel manager. After the move is completed I want to set the focus on the Manager, but is not update:

    first call this function

    later, calling animateProfile() - thread function

    and finally call animCompleted() (who must be the focus on manager)

    public void performAction() {}
    If (null == profileClick) {}
    If (null! = listener) {}
    listener.performAction ();
    }
    initProfile();
    animateProfile();
    animCompleted();
    } else {}
    Reset();
    }
    }

    private synchronized void animateProfile() {}
    Blade wire = new Thread() {}
    public void run() {}
    int count = 0;
    int height = profileClick.getPreferredHeight () + 4;
    While (count< height)="">
    profileClick.moveScreen (0, count);
    Invalidate();
    try {}
    Thread.Sleep (10);
    } catch (InterruptedException e) {}
    e.printStackTrace ();
    }
    Count += 8;
    }
    animCompleted = true;
    }
    };
    Slide.Start ();
    }

    private void animCompleted() {}
    If {(animCompleted)
    profileClick.setFocus ();
    }
    }

    Any help?

    Greetings.

    As arkadyz says, in your call to animCompleted() is run, if the variable animCompleted Boolean is false, that it does not lead us to know.

    Your call to animCompleted() must be made since your overloaded runs your slide wire internal class method. In addition, you must call it in such way that the thread of events that changes the user interface and any other foreign thread.

    To achieve this, you must do something like this:

    private synchronized void animateProfile() {
            Thread slide = new Thread() {
                public void run() {
                    int count = 0;
                    int height = profileClick.getPreferredHeight() + 4;
                    while (count < height) {
                        synchronized (UiApplication.getEventLock()) {
                            profileClick.moveScreen(0, count);
                            invalidate();
                        }
                        try {
                            Thread.sleep(10);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                        count += 8;
                    }
                    UiApplication.getUiApplication().invokeLater(new Runnable(){
                        public void run() {
                            profileClick.setFocus();
                        }
    
                    });
                }
            };
            slide.start();
    }
    

    Let me know how helpful it is for you, please. Good luck.

  • How to disable the functionality of the hyper-threading technology

    How to disable the functionality of the hyper-threading technology

    Hello

    I put t know what BIOS you have, but generally you can activate or deactivate this option in the BIOS.

  • Why using the driver NOR-DAQmx ANSI C functions in a thread causes a deadlock?

    Firstly, apologies if this is bad advice, but it seemed the closest fit.

    I use MSVC 2008 Express with the library in ANSI C NI DAQmx for some analog output with a box USB-6009. I create a thread to handle the signal generation is based on fixed time. My main thread running the user interface. I found that I get intermittent blockages in release, so that libraries mode NOR are responsible (in the second thread) and I use MSVCRT features (on the main thread). My test code is attached as "deadlock2.cpp".

    I used WinDbg to try to find the cause of the deadlock. Traces of the battery of my two sons are attached as t1_stack.txt and t2_stack.txt.

    It seems that the MSVCRT localtime() function uses a lock when it is called for the first time and then went to lock the Windows DLL loader lock. At the same time libraries NOR (or less libraries mxs) are responsible for locking the charger DLL is being held. The mxsutils library uses getcwd() which seems to try to block something the MSVCRT and therefore my two sons are now deadlocked.

    I can probably work around this by calling the localtime() and the NOR-DAQmx functions before I spawn my second thread so that the DLLs are already loaded in the process. However, I have no guarantee of this to continue working if something changes in the future, and if there are any locks going on finally having the DllMain() calls for a thread hanging may still cause a deadlock. If my results are correct, is it likely that NEITHER would fix the dll for not trying to make something complex in their DllMain()?

    According to NI Measurement and Automation Explorer, I'm under DAQmx libraries v9.3.5f2. I download the latest version now to try, but it will take time.

    Hi dmcminn,

    Thank you for the comprehensive and detailed bug report. I was able to reproduce the problem with NOR-DAQmx 9.6 using the code you posted. I reported it to the R & D team suitable as CAR #366538.

    I agree with your analysis of the problem. Getcwd() so the first call to __tzset() acquired _ENV_LOCK, which Microsoft has documented as the "lock for environment variables. __tzset() also called GetTimeZoneInformation(), which can load additional libraries, that you have demonstrated.

    Here are a couple more possible solutions, but they are not great:

    • Link to the static version of the CRT (/ MT instead of /MD). This would bind a separate copy of the lock of the CRT table in your program, and DAQmx would continue to use the lock to MSVCR90.dll table. They use more of the same _ENV_LOCK.
    • Build using a different version of Microsoft Visual C++ (for example 2005 or 2010). MSVCR80.dll MSVCR90.dll and MSVCR100.dll own separate copies of the lock of the CRT table.

    Whatever it is, it does not eliminate the fact that mxsutils called the CRT while now the loader lock, and this function CRT acquires another lock.

    Furthermore, the forum Multifunction DAQ is a better place to ask questions DAQmx.

    Brad

  • Is it safe call a function of two different thread at the same time?

    For example,.

    Thread1()

    {

    status = my_function();

    }

    Thread2()

    {

    status = my_function();

    }

    int my_function()

    {

    foo;

    return the result;

    }

    I want to call thread1 and thread2 ma_fonction at the same time.

    Call functions simultaneously, in itself and is not a problem at all. Each thread has its own stack of appeal.

    However, you carefully examine the foo part. If you access resources overall (such as hardware devices, global variables or static local variables), or if you make calls to non thread-safe libraries, then you will have to lock the bits of sensitive code with thread locks, ensuring as well as only one thread can access this code at any time.

    Luis

  • What the handles, threads, and processes means or function, they are performing?

    My son will ask me a question and I could not answer (it is perhaps a good thing because I think he will try to enter and change something he doesn't know) so I thought that I felt I'd better try to find out. He and I are eager to know what the handles, son and process average or functions, they do. They are in the performance tab in Windows Task Manager.


    Thank you

    Hello

    A process handle is an integer value that identifies a Windows process. The Win32 API call a HANDFUL.

    When you start a program, this program runs as a "process". It's something that runs in its own protected area, with its own memory. Other processes cannot touch this memory.

    A few times, the program needs to do several things at once in a way of multitasking, similar to how the multitasking process. For example, a spreadsheet can recalculate the cells you enter data. He * could * start another process, but they can't (easily) share the memory, he would need to if recalculate cells!

    Must be a different sort of process that is not quite as separated. It is a "thread".

    Process: the number of applications that are running at some point in the computer.

    Hope this information helps.

  • How does GF determines number of threads of execution of the function.

    Hello

    Depending on the topic, I am interested to know how GF determines the number of threads to yield to the execution of the function on a JAVA virtual machine.

    Also, is there a way to override this property?

    We use GF 6.6.4

    Thank you very much

    David Brimley

    Hi David,

    The number of threads of FE is determined by max (UC * 4, 16)-processors being, essentially, of hearts in this example. You can increase your threads of FE by setting the DistributionManager.MAX_FE_THREADS system property.

    -Jens

  • Thread and ThreadStart functions stop in Labwindows

    Hello

    I'm trying to access a card PCI Express, which uses the ThreadStart functions and ThreadStop driver. When I compile

    my code, LabWindows generate an error "missing" prototype I looked at the source code for the driver and the following line is

    in the header file:

    #if! (defined (WIN32): defined (WIN16)) | defined (WinCE). defined (_MT)
    DWORD DLLCALLCONV ThreadStart(HANDLE *phThread, HANDLER_FUNC pFunc, void *pData);
    Sub DLLCALLCONV ThreadStop (HANDLE hThread);

    #endif

    I use Windows XP Professional, so I guess I wouldn't declare and define functions of theses. If I remove

    the condition, LabWindows may find prototypes, but the same problem occurs for other functions and as I am

    will probably update the driver, I will not comment the code inside the driver.

    If anyone has had the same problem or knows the solution? (maybe an option of the compiler...)

    Thank you

    Cyril

    Oh boy, I think you're screwed! _beginthreadex() belongs to the C from Visual C++ runtime library. his name starts with a '_', which means that it is an extension to the runtime soldier: it is clearly not transferable and will never compile with any other than Visual C++ C runtime library.

    Now you can use Visual C++ to compile your code, or ask the original developer to stop using the TERM private extensions and stick to the standard C and standard system calls. I personally would opt for the second option.

    (in any case, I want to say that CreateThread() is not only for Windows CE: this is a standard Windows API call available on all Windows since Windows 95 systems (maybe even before). don't be fooled by the Windows SDK documentation that separates documentation for Windows CE and Windows standard.) Unfortunately, some rather old SDK documentation shows the first Windows CE functions (especially when you are looking for in the index) people fooling into thinking that these functions are only for THIS: all functions available on Windows CE is also also available for standard WIndows OSes with more options and a more profound documentation.)

Maybe you are looking for