MultiThread Problem

My applet constructs and starts 2 identical Threads.
While running, my debuging utility tells me that one of them quits running at some point. Moving the mouse, it makes it to continue to run. At some other point again, one of the Threads stops running and remains stopped. The other Thread runs fine though.
I eliminated a runtime error as a reason for one of the Threads to stop, because I deliberately instantiated the same thread twice to test it. Still one of them quits for no reason.
Wny does the one Thread give up?
Thanks,
Chris.

My software is a huge utility software which runs in a thread. Recently I instantiated the same thread twice (in general the input variables are allowed to vary from thread to thread, else there would be no point in having 2 identical threads).
This weird behavior came about though: One of the threads quits during runtime while the other still goes strong. Even when the 2 threads are identical. Therefore, I eliminated any runtime error, except perhaps possible out-of-memory error, OR deadlock. I am going to have to build a custom debugging utility to troubleshoot this one. In general the thread instantiates its own objects so this eliminates deadlock since no variables are shared, but certain variables are static which i have to investigate further. Finally, the thread objects are entirely independent from each other since there is no communication between them. They are simply 2 instances of my thread object.
class myThread extends Thread
class myApplet extends Applet
init()
arrayOfThreads[0] = new myThread(..variables..)
arrayOfThreads[1] = new myThread(..variables...)
I would appreciate any comment.
Chris.

Similar Messages

  • Trying to create multithreading problems when opening file dialog

    Warning: Newbie to Labview...
    I have a problem in a rather complicated VI where bringing up the open file dialog halts some background operations.
    I would really like to reproduce this behaviour for various reasons, but am unable to. I've created a simple VI with a for-loop where the index feeds a sine converter which in turn feeds a tank indicator. This produces an oscillating behaviour. To this VI I've added a file dialog control.
    Regardless of the multithreading setup, I'm unable to get the oscillating of the tank indicator to stop when the dialog is open. Is there something I can do to get this behaviour? I realize it's unusual to try to break things, but it is rather important for me.
    Tha
    nk you,
    Nigel

    Hi,
    The for loop (all loops by the way) is halted until everything in it is
    finished.
    Try this:
    + Make a while loop
    + wire TRUE to the stop criterium.
    + Put an indicator on the 'I'.
    + Put a MS Wait in it (e.g. 80 ms), to prevent 100% processor time.
    Run it, and the indicator will increase fast.
    Now put any dialog in the while loop. E.g. a message box.
    The indicator will increase everytime you press 'OK'.
    Note: stop by pressing CTRL+. and clicking 'OK' several times.
    Regards,
    Wiebe.
    "N Cook" wrote in message
    news:[email protected]..
    > Warning: Newbie to Labview...
    >
    > I have a problem in a rather complicated VI where bringing up the open
    > file dialog halts some background operations.
    >
    > I would real
    ly like to reproduce this behaviour for various reasons,
    > but am unable to. I've created a simple VI with a for-loop where the
    > index feeds a sine converter which in turn feeds a tank indicator.
    > This produces an oscillating behaviour. To this VI I've added a file
    > dialog control.
    >
    > Regardless of the multithreading setup, I'm unable to get the
    > oscillating of the tank indicator to stop when the dialog is open. Is
    > there something I can do to get this behaviour? I realize it's unusual
    > to try to break things, but it is rather important for me.
    >
    > Thank you,
    > Nigel

  • Helping , Observable's multithread problem, thread is losting ?

    i am practicing an example of Observable and Observer pattern. But one problem were occured as following:
    the programe will print out a 10*10 grid , and using observer pattern to change every grid 's color.
    The fill rule is that : 1. randomly to choose a beging grid,
    2. notify the four grid (left ,right , upper, below of the choosed grid) to change their's grid color.
    The problem is when using multithread to notify grid , not all of the grid will be changed color, but if using single thread to notify grid, then all of the grid will be notified, and color changed.
    the switch of the multithread and single thread is the P.java 's 62-66 line, and 67-71 line, the source is following, anyone can help to analysing the source, and found exactly where is reason of not all of the grids could be notified , very thanks.
    the starup class is the Guess10.java.
    the source :
    package guess10:
    package guess10;
    import java.util.*;
    import guess10.gui.*;
    * <p>Title: </p>
    * <p>Description: </p>
    * <p>Copyright: Copyright (c) 2005</p>
    * <p>Company: </p>
    * @author not attributable
    * @version 1.0
    public class P
        implements Observer {
      public P() {
      public P(int x, int y) {
        this.x = x;
        this.y = y;
      public static void main(String[] args) {
        P p1 = new P();
      int x;
      int y;
      public void open() {
    //    System.out.println("open " + this);
      public void update() {
    //    System.out.println("update " + this);
    //    System.out.println("[" + x + "," + y+"]");
        F.instance.getGrid(x, y).action();
      public void open(Observable ob) {
        open();
    //    System.out.println(this);
        ob.deleteObserver(this);
      public void update(final Observable ob) {
        update();
        ( (PObservable) ob).change();
    //    ob.notifyObservers(new Point[]{new Point(x+1,y)});
    //    ob.notifyObservers(new Point[]{new Point(x,y+1)});
    //    ob.notifyObservers(new Point[]{new Point(x+1,y+1)});
    //    ob.notifyObservers(new Point[]{new Point(x-1,y-1),new Point(x+1,y-1),
    //    new Point(x+1,y+1),new Point(x-1,y+1)});
          final Point[] p = new Point[] {
              new Point(x - 1, y), new Point(x, y - 1),
              new Point(x + 1, y), new Point(x, y + 1)
         new Thread(new java.lang.Runnable() {
            public void run() {
                ob.notifyObservers(p);
          },"" + x +"," + y ).start();
    //      new java.lang.Runnable() {
    //        public void run() {
    //          ob.notifyObservers(p);
    //      }.run();
      public void update(Observable observable, Object object) {
    //    System.out.println(this+" " +Thread.currentThread().getName());
        Point[] p = (Point[]) object;
        for (int i = 0; i < p.length; i++) {
            if (this.x == p.x && this.y == p[i].y) {
    if ( ( (PObservable) observable).exist(this)) {
    open(observable);
    update(observable);
    public static int count = 0;
    public String toString() {
    return "x = " + x + " y = " + y;
    // now not used
    private Object lock = new Object();
    package guess10;
    import java.util.*;
    * <p>Title: </p>
    * <p>Description: </p>
    * <p>Copyright: Copyright (c) 2005</p>
    * <p>Company: </p>
    * @author not attributable
    * @version 1.0
    public class PLayout {
    private BitSet xb = new BitSet();
    private BitSet yb = new BitSet();
    PObservable o = new PObservable();
    public PLayout() {
    public static void main(String[] args) {
    PLayout PLayout1 = new PLayout();
    * create 100 p object, and store into Observable object
    public void init() {
    for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
    P p = new P(i, j);
    o.addObserver(p);
    // todo : need to subclass for the Observable ??
    // otherwise , how to set changed to true ?
    public void start(int x, int y) {
    o.change();
    o.notifyObservers(new Point[] {new Point(x, y)});
    package guess10;
    import java.util.*;
    * <p>Title: </p>
    * <p>Description: </p>
    * <p>Copyright: Copyright (c) 2005</p>
    * <p>Company: </p>
    * @author not attributable
    * @version 1.0
    public class PObservable
    extends Observable {
    public PObservable() {
    super();
    public static void main(String[] args) {
    PObservable PObservable1 = new PObservable();
    public synchronized void change() {
    this.setChanged();
    public synchronized boolean exist(P p) {
    return v.contains(p);
    private Vector v = new Vector();
    public synchronized void addObserver(Observer o) {
    super.addObserver(o);
    v.add(o);
    public synchronized void deleteObserver(Observer o) {
    super.deleteObserver(o);
    v.remove(o);
    package guess10;
    * <p>Title: </p>
    * <p>Description: </p>
    * <p>Copyright: Copyright (c) 2005</p>
    * <p>Company: </p>
    * @author not attributable
    * @version 1.0
    public class Point {
    public Point() {
    public Point(int x, int y) {
    this.x = x;
    this.y = y;
    public static void main(String[] args) {
    Point point1 = new Point();
    int x;
    int y;
    package guess10;
    * <p>Title: </p>
    * <p>Description: </p>
    * <p>Copyright: Copyright (c) 2005</p>
    * <p>Company: </p>
    * @author not attributable
    * @version 1.0
    public class Guess10 {
    public Guess10() {
    public static void main(String[] args) {
    Guess10 guess101 = new Guess10();
    guess101.start();
    public void start() {
    PLayout pl = new PLayout();
    pl.init();
    int x = 0;
    int y = 0;
    java.util.Random random = new java.util.Random(System.currentTimeMillis());
    x = random.nextInt(10);
    y = random.nextInt(10);
    pl.start(x, y);
    // try {
    // x = System.in.read();
    // y = System.in.read();
    // catch (IOException ex) {
    // ex.printStackTrace();
    // if(!isDigit(x) | !isDigit(y)) {
    // System.out.println("Not correct number! " + x + " " + y);
    // System.exit(1);
    // pl.start(x-'0',y-'0');
    static boolean isDigit(int ch) {
    return ( (ch - '0') | ('9' - ch)) >= 0;
    package guess10;
    import java.io.*;
    * <p>Title: </p>
    * <p>Description: </p>
    * <p>Copyright: Copyright (c) 2005</p>
    * <p>Company: </p>
    * @author not attributable
    * @version 1.0
    public class Out {
    public Out() {
    public static void main(String[] args) {
    Out out1 = new Out();
    public static final PrintStream out = System.out;
    public static void print(PLayout playout) {
    the package guess10.gui
    package guess10.gui;
    import java.awt.*;
    import javax.swing.*;
    * <p>Title: </p>
    * <p>Description: </p>
    * <p>Copyright: Copyright (c) 2005</p>
    * <p>Company: </p>
    * @author not attributable
    * @version 1.0
    public class F
    extends JFrame {
    public static F instance = new F();
    public F() {
    super("O G");
    init();
    setVisible(true);
    private Grid[] ps = new Grid[100];
    public Grid getGrid(int x, int y) {
    return ps[x * 10 + y];
    public void init() {
    Container con = this.getContentPane();
    con.setLayout(new java.awt.GridLayout(10, 10));
    for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
    con.add(ps[i * 10 + j] = new Grid());
    setSize(400, 400);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    public static void main(String[] args) {
    F f1 = new F();
    f1.getGrid(4, 3).setBackground(Color.yellow);
    package guess10.gui;
    import java.awt.*;
    import javax.swing.*;
    * <p>Title: </p>
    * <p>Description: </p>
    * <p>Copyright: Copyright (c) 2005</p>
    * <p>Company: </p>
    * @author not attributable
    * @version 1.0
    public class Grid
    extends JPanel {
    public Grid() {
    super();
    this.setBorder(BorderFactory.createEtchedBorder());
    // this.add(new javax.swing.JTextField("777"));
    public static void main(String[] args) {
    Grid grid1 = new Grid();
    public void action() {
    try {
    Thread.currentThread().sleep(100);
    catch (InterruptedException ex) {
    // this.setBackground(Color.yellow);
    this.setBackground(new Color(r--, g--, b++));
    // add(new javax.swing.JLabel(Thread.currentThread().getName()+" "+count++));
    // this.validate();
    private static int r = 255;
    private static int g = 230;
    private static int b = 128;
    private static int count = 0;

    copy the java file into notepad, and save to .java file,
    then javac guess10\*.java file to compile, and java guess.Guess10 to run , then can see the gui's output,
    Only you see the gui's output, you can understand what i describe.
    Only seeing the source will not found the reason of the problem, it's need to run indeedly.
    is there anyone to try that ?

  • Socket and multithreading problem (flow control)

    This code is heavily influenced by the KKMultiServerThread. I am having problems controlling the thread flow.
                 login = new MultiServerThreadLogin(serverSocket.accept(), serverSocket);
            login.start();     
              while(true){
                 System.out.println(login.getAuthen());
                 while(login.getAuthen()){
                      System.out.println("doing hello");
                      hello = new KKMultiServerThread(serverSocket.accept(), serverSocket);
                      hello.start();
                      if(hello.getFlag())
                      break;
              }here, you can see that i am trying to start a thread to login the user and then recieve files from the cilent. When my GUI runs, there is no problem whatsoever that is for the 1st time, however when i try running the 2nd time, the code as u can see, doesnt allow that... so is there anyway to break away from the inner loop?

    hey thanks for replying... i'm sorry but in a rush here...
    this snippet resides in the server. There are 2 classes, namely MultiServerLoginThread and KKMultiServerThread, both extends Thread.
    The function of the MultiServerLoginThread is to read in bytes of Secretkey, username(encrypted) and password(encrypted). This should only take place once.
    The function of theother thread, KKMultiServerThread is to read in the file name to be transferred and the contents. This is based on the KKMultiServerThread which can be found somewhere in this forum... i hope...
    The KKMultiServerThread is started over and over because the client is sending multiple files. Hence the while loop. However after sending the last file, it should go to the MultiServerLoginThread....
    One thing i don't really get it is that if i were to do this(put the creation of the login thread within the while loop):
    while(true){
                 System.out.println(login.getAuthen());
                 login = new MultiServerThreadLogin(serverSocket.accept(), serverSocket);
            login.start();
                 while(login.getAuthen()){
                      System.out.println("doing hello");
                      hello = new KKMultiServerThread(serverSocket.accept(), serverSocket);
                      hello.start();
                      if(hello.getFlag())
                      break;
              }The GUI totally hangs.
    More explanation...
    hello.getFlag() returns the flag when the client has finished sending all the files
    login.getAuthen() returns whether the user has successfully logged in with correct creditials

  • Multithreaded problem in read and write thread

    This is a producer consumer problem in a multi-threaded environment.
    Assume that i have multiple consumer (Multiple read threads) and a
    single producer(write thread).
    I have a common data structure (say an int variable), being read and written into.
    The write to the data sturcture happens occasionally (say at every 2 secs) but read happens contineously.
    Since the read operation is contineous and done by multiple threads, making the read method synchronized will add
    overhead(i.e read operation by one thread should not block the other read threads). But when ever write happens by
    the write thread, that time the read operations should not be allowed.
    Any ideas how to achive this ??

    If all you're doing is reading an int, then just use regular Java synchronization. You'll actually get a performance hit if you're doing simple read operations, as stated in the ReadWriteLock documentation:
    Whether or not a read-write lock will improve performance over the use of a mutual exclusion lock depends on the frequency that the data is read compared to being modified, the duration of the read and write operations, and the contention for the data - that is, the number of threads that will try to read or write the data at the same time. For example, a collection that is initially populated with data and thereafter infrequently modified, while being frequently searched (such as a directory of some kind) is an ideal candidate for the use of a read-write lock. However, if updates become frequent then the data spends most of its time being exclusively locked and there is little, if any increase in concurrency. Further, if the read operations are too short the overhead of the read-write lock implementation (which is inherently more complex than a mutual exclusion lock) can dominate the execution cost, particularly as many read-write lock implementations still serialize all threads through a small section of code. Ultimately, only profiling and measurement will establish whether the use of a read-write lock is suitable for your application.

  • OBIU Extract Multithread problem.

    We have come across a problem in our ETL. Some batch programs when multi-threaded, such as C1-RECTD, produce duplicate files. Does anyone know which of base batch programs have this problem ? Thank you.

    We have come across a problem in our ETL. Some batch programs when multi-threaded, such as C1-RECTD, produce duplicate files. Does anyone know which of base batch programs have this problem ? Thank you.

  • GUI Multithreading problems

    I'm making a chat client and I'm having problems with the threading around the GUI. It works when I don't use the GUI (and ActionListeners aren't at fault). I basically have two threads, a send thread and a receive thread, which are both subclasses that extend Thread. When I start them through the GUI, on an ActionListener, they don't work... but when I start them in a program that is GUI-less, they do work. Just for clarification, it's not the ActionListeners at fault, I tried doing a System.out on the same ActionListener and it worked.
    A peculiarity is that when I make a new instance of the same frame [another frame.setVisible(true)] in my Receive thread, it starts receiving on the new window. I get the messages from the server, but I can't send stuff. I used to view this as a half-success, but now I think I'm going about it all wrong.
    So, here's my questions:
    1.Do I need to make more threads? I thought that everything outside the Receive and Send threads were naturally in a thread themselves, but it seems that they are not. Should I put the TextArea in my GUI that receives messages in a different Thread?
    2.Or is the problem that I have to somehow refresh the frame without causing it to make new frames?

    It's hard to tell what's going on without seeing your code. What do you mean when you say "When I start them through the GUI, on an ActionListener, they don't work"? Does that mean the threads don't start, or you don't see anything happening in GUI, or everything freezes, or... etc, etc.? Please post code or describe the sequence of events in detail so we can help.
    As a guess, it sounds like you're starting your threads when you press send, which doesn't sound right. In a chat, both threads should be running from the beginning, and when you have stuff to send you put it in a queue, then let the send thread pick it up. The receive thread just receives and puts messagese in the GUI. - see http://java.sun.com/products/jfc/tsc/articles/threads/threads1.html

  • Multithreading problems

    This is my first post here so I don't know the feedback i will get, however
    i need some help on my code. sorry if it's a bit nooby in formatting:
    import java.util.*;
    public class Demo1
         public static void main(String args[])
              try
                   new Talker2();
                   new Talker1();
              catch (Exception e)
                   System.out.println("Error: " + e );
    class Talker1 implements Runnable
         String[] words = {"I'm awesome!","I'm better than Person2 at java!"};
         Talker1() throws Exception
              for (int x = 0; x < 10; x++)
                   String name = "Person1";
                   int number1 = RandomInt1();
                   int number2 = RandomInt2();
                   Thread t = new Thread();
                   System.out.println(name + ": " + words[number1]);
                   t.start();
                   t.sleep(number2);
         public void run()
         public int RandomInt1()
              Random rr = new Random();
              int number1 = rr.nextInt(2);
              return number1;
         public int RandomInt2()
              Random rrr = new Random();
              int number2 = rrr.nextInt(4000);
              while (number2 < 1000)
                   number2 = rrr.nextInt(4000);
              return number2;
    class Talker2 implements Runnable
         String[] words = {"I'm an idiot!","I'm stupid!"};
         Talker2() throws Exception
              for (int x = 0; x < 10; x++)
                   String name = "Person2";
                   int number1 = RandomInt1();
                   int number2 = RandomInt2();
                   Thread t = new Thread();
                   System.out.println(name + ": " + words[number1]);
                   t.start();
                   t.sleep(number2);
         public void run()
         public int RandomInt1()
              Random rr = new Random();
              int number1 = rr.nextInt(2);
              return number1;
         public int RandomInt2()
              Random rrr = new Random();
              int number2 = rrr.nextInt(4000);
              while (number2 < 1000)
                   number2 = rrr.nextInt(4000);
              return number2;
    }this program was made so i could make a virtual chatroom of some sort
    anyways when this program runs, the two threads do not run simultaneously so i was wondering how to do it thanks!

    Hi,
    See this wither this meets your requirement...
    import java.util.*;
    public class Sample
         public static void main(String args[])
              try
                   Thread th = new Thread(new Talker2());
                   Thread th2 = new Thread(new Talker1());
                            th.start();
                            th2.start();
              catch (Exception e)
                   System.out.println("Error: " + e );
    class Talker1 implements Runnable
         String[] words = {"I'm awesome!","I'm better than Person2 at java!"};
         Talker1() throws Exception
         public void run()
                try{
                for (int x = 0; x < 10; x++)
                   String name = "Person1";
                   int number1 = RandomInt1();
                   int number2 = RandomInt2();               
                   System.out.println(name + ": " + words[number1]);
                            Thread.sleep(number2);
                }catch(Exception e){}
         public int RandomInt1()
              Random rr = new Random();
              int number1 = rr.nextInt(2);
              return number1;
         public int RandomInt2()
              Random rrr = new Random();
              int number2 = rrr.nextInt(4000);
              while (number2 < 1000)
                   number2 = rrr.nextInt(4000);
              return number2;
    class Talker2 implements Runnable
         String[] words = {"I'm an idiot!","I'm stupid!"};
         Talker2() throws Exception
         public void run()
                try{
                for (int x = 0; x < 10; x++)
                   String name = "Person2";
                   int number1 = RandomInt1();
                   int number2 = RandomInt2();               
                   System.out.println(name + ": " + words[number1]);
                            Thread.sleep(number2);
                }catch(Exception e){}
         public int RandomInt1()
              Random rr = new Random();
              int number1 = rr.nextInt(2);
              return number1;
         public int RandomInt2()
              Random rrr = new Random();
              int number2 = rrr.nextInt(4000);
              while (number2 < 1000)
                   number2 = rrr.nextInt(4000);
              return number2;
    }

  • Multithreading issue on Solaris 8 branded zone

    Hi,
    We are facing a multithreading problem in Solaris 8 container (branded zone) on Solaris 10.
    The core file shows 2 LWPs for a single thread.
    First LWP
    (dbx) lwp
    current LWP ($lwp) is l@1403
    (dbx) print this->m_ThreadId->m_IdImpl.m_PosixId
    this->m_ThreadId.m_IdImpl.m_PosixId = 1404U
    Second LWP
    (dbx) lwp
    current LWP ($lwp) is l@1404
    (dbx) print this->m_ThreadId->m_IdImpl.m_PosixId
    this->m_ThreadId.m_IdImpl.m_PosixId = 1404U
    Another point to note is that dbx returns 'MT support is disabled' for this program even though it has been built using the -mt option. The dbx version is Sun Dbx Debugger 7.5 2005/10/13.
    As far as I have read, the Solaris 8 branded zone uses the alternate T2 thread library. Note also that this program is linked with the alternate thread library @ /usr/lib/lwp.
    This alternate thread library is supposed to use the 1:1 thread model.
    Can someone explain why are we then seeing 2 LWPs for a single thread ?
    Thanks,
    Best regards,
    Raj Iyer

    This error messages are output by
    cssd which is a input method of Japanese.
    If you don't use Japanese input method cs00, you can stop it by following method.
    # /etc/init.d/loc.ja.cssd stop
    # mv /etc/rc2.d/S90loc.ja.cssd /etc/rc2.d/_S90loc.ja.cssd

  • Visibility of variables in a multithreaded application

    In a code review of our GUI application, we encountered some multithreading problems, concerning the visibility of variable values.
    In theory, write and read operations have to be synchronized or at least, volatile has to be used to provide a accurate access to the variable values from different threads.
    Although we have encountered many code sequences in our application violating the above rules, we have never seen a problem in our application.
    This forced us to write a simple test program which should discover these problems, but there was no difference using volatile or non volatile variables !!
    Our experience is, that on our platform (Intel Core2Duo/Pentium M - Linux 2.6.23 - Sun Java HotSpot 1.6.0_04), no visibility problems caused by multithread access occurs, even if the variables are neither declared as volatile nor protected by a synchronized block.
    Is there anybody out there, who has more details to this multi threading issue ?

    Pulsar7 wrote:
    But visibility of variables in multi core environments is not an issue of atomic access.No. I meant to say that you also can see other problems if you remove the syncronized/volatile access. Reading stale data isn't the only problem.
    Multi-Core architectures can have per core-registers, -caches, -controller devices interchanging the memory content in a certain way.
    It is obvious, that two thread running on different cores should run into problems. But we do not see them !?It's all implementation and hardware dependent. You can get different result when you are executing on different VMs as well as different operating systems.
    Are there some memory consistency features implemented in modern CPUs, supporting immediate register/cache/memory updates ?
    Is the behaviour depended on the OS ?See above.

  • Multithreading and daq acquisition

    I�m trying to run 2 DAQ�s (PCI MIO 16 XE) devices in one PC (Win XP) to acquire N-data samples from 5 AI channels each using LV 7.0. For the acquisition to starts, each device is independently triggered (5KS/s) . It works fine and I can get the data. The problem is that the second DAQ starts the acquisition probably only after the first has finished its acquisition. (I cannot be sure about that because actually I do not know how to get the start time of an acquisition). At least the DAQ�s are starting the acquisition at different times and this could be a problem if the time difference is to big( >500 micro seconds).
    1. is this a classical Multithreading problem? Is there a solution?
    2. how can I assure that both DAQ�s start
    the acq. nearly at the same time?
    3. how can I get the start time of the Acq. ?
    4. if I have to use 4 DAQ�s on one PC will this work? Known problems?
    Thanks
    Alberto

    Let me try to explain my problem using the DAQmx example VI �Cont Acq&Graph Voltage-Ext Clk- Dig Start.vi�.
    Making few changes to the above VI, you can use it as a Sub-Vi. ( I also limited the number of scans to 1000). I used 2 PCI MIO 16XE-10 devices and wrote a program using two of this sub.vi. I used one trigger signal and one clock for both devices and scanned the same channel. As input I used a Sinus voltage. After the program runs, If I plot the obtained data time independent, i.e the x-axis is now the scan number rather than time (relative or absolute) I get a shift in the signals of about 90 clocks, this means that for example, the scan position for the max amplitude came for one device 90 clocks later than for th
    e first device. This is unacceptable for my application
    In other test , If I just did copy the block diagram of the example in a new VI twice and made the necessary changes (trigger channel, channel names, etc). Now I got NO shift in the Graph. Both sinus waves were exactly the same. But I still have no idea about the difference on the start time of both devices. I suppose, in this case both devices started at the same time. But how can I be sure of that?
    Without the possibility of using that Sub-Vi�s and because I have to use 1, 2 or 4 devices selectively, my program will be looking very complicated. I�m sure there must be a better way to solve this.
    Thanks

  • Multithreading and partitioned shared memory

    Hi All,
    I'm having no success with this (simple?) multithreading problem on my core-i7 processor, using CVI 9.0 (32-bit compiler).
    In the code snippets below, I have a node level structure of 5 integers, and I use 32 calls to calloc() to allocate space for 32 blocks of 128*128 (16K) nodes and store the returned pointers in an array as a global var. 
    Node size in bytes = 20, block size in bytes = (approx) 328KB, total allocated size in bytes = (approx) 10.5MB.
    I then spawn 32 threads, each of which is passed a unique index into the "node_space" pointer_array (see code below), so each thread is manipulating (reading/writing) a separate 16K block of nodes.
    It should be thread safe and scale by the number of threads because each thread is addressing a different memory block (with no overlap), but multithreading goes no faster (maybe slightly) than a single thread.
    I've tried various threadpool sizes, padding nodes to 16 and 64 byte boundaries,  all to no avail.
    Is this a memory bandwidth problem due to the size of the arrays? Does each thread somehow load the whole 32 blocks?  Any help appreciated.
    struct  Nodes
       unsigned int a;  
       unsigned int b;  
       unsigned int c;
       unsigned int d;  
       unsigned int e;
    typedef struct Nodes  Nodes;
    typedef  Nodes   *Node_Ptr;
    Node_Ptr            node_space[32];          /* pointer array into 32 separate blocks ( loaded via individual calloc calls for each block) */
    .... Thread Spawning  ....
             for (index = 0; index < 32; ++index)
                 CmtScheduleThreadPoolFunction(my_thread_pool_handle, My_Thread_Function, &index, NULL);
    Solved!
    Go to Solution.

    Hello CVI_Rules,
    It's hard to answer your question because it depends on what you are doing in your thread function. Since you are not seeing any speed up in your program when you change the number of threads in your thread pool, you are either doing too much (or all of the work) in each thread, serializing your threads with locks, or somehow slowing down execution in each thread.
    Your basic setup looks fine. You can simplify it slightly by passing the nodes directly to your thread function:
    for (index = 0; index < 32; ++index)
    CmtScheduleThreadPoolFunction(pool, My_Thread_Function, node_space[index], NULL);
    static int My_Thread_Function(void *functionData)
    Node_Ptr nodes = functionData;
     But that's not going to affect performance.
    Things to look into:
    Verify that you're really only working on one subset of the node space in each thread, that you're passing and receiving the correct node space in each thread and that you're working only on that one.
    Verify that you don't have any locks or other synchronization in your program. It sounds like you don't because you designed your program so that it wouldn't need any. But check anyway.
    Verify that you're not doing something unnecessary in your thread function. Sometimes people call ProcessSystemEvents or ProcessDrawEvents because they feel that it makes the UI more responsive. These two functions are expensive (around 20ms per call, I think). So if you are calling these functions in a loop, with a fixed total number of iteraction across all threads, and if the actual computations are relatively fast, then these functions can easily dominate the execution time of your program. (It need not be these functions, it might be other ones. These are just examples.)
    Show and explain your code to a colleague. Sometimes you don't see the obvious until you show it to someone. Or they might notice something.
    Apart from that, can you explain what you are doing in your thread function so that we can have a better understanding of your program and what might inhibit parallelism?

  • CVI incomplete​/missing popup panels

    Using CVI 6.0 under W2000 with MS VC++ 6, i sometimes can bring execution of my application to a halt by invoking a CVI message or prompt popup from a menu command callback procedure. The popup does not appear or appears without buttons and execution is stuck. I have to stop debugging and restart the application. I am using a Matrox G450 with two monitors, but they are configured as one large monitor, GetSystemAttribute(ATTR_NUM_MONITORS,..) returns 1. Sometimes the hangup is reproducible several times, then it disappears, possibly after closing other CVI applications before debugging again. Has anybody seen such behaviour?
    I checked this is not a multithreading problem (my modal popups are created from the same thread as main panel). I am
    using the system attribute to have CVI popups with 3D buttons.

    I am having similar issues, whereby I sometimes get incomplete popup panels using CVI 7.1.1.
    I tried updating the style of the popup panel to VAL_LAB_STYLE for the rendered buttons, but
    the message and confirm popup are still in the classic style.
    I am setting the POPUP_STYLE with
    SetSystmePopupsAttribute(ATTR_POPUP_STYLE,VAL_LAB_​STYLE) and verifiying
    with GetSystemPopupsAttribute, but popup panels are not changed.
    Any feedback would be helpful

  • Very challenging situation...LabVIEW experts are all invited......

    Greetings
    the scenario that i'm having now is as following:
    - I'm a 1st year PhD student,and am trying to figure out(find) a new,innovative and impressive project in wireless communications systems area. while am doing my literature review and exploring my favorit knowledge base www.ni.com website ,by chance, i read some titles about the new Multicore tech.then, after surfing most ni's webcasts i got many ideas on how to exploit this tech. together with LabVIEW to boost up my yet-undefined PhD wireless com.main project.in other words,i want to speed-up any existing wireless technology (e.g beamforming algorithms of smart antennas).However, while i met my supervisor i did for him a quick demo and he was wondering about which wireless topic we can make use of multicore tech together with labview,i suggested him {improving wireless systems using multicore tech. and labview coding}.But, a class A student told us that that multithreading problems of multicore tech. have already been solved by software giants, and nothing special about using labview to design parallel processing as many other text-based langauges can do the same,as their compilers already designed for multicore systems.I get depressed actually after he told me this.becuase am intending to use labview (my most favorit software with multicore tech to simulate the performance of a wireless system,and publish a paper about this topic.
    in short gentle men, i wish u guide me and tell me anything related to multicore tech with labview.any new problem you want to simulate it using labview so that i can work on it using labview.and please try to refer me to the latest updates about multicore and latest webcast as i saw almost all webcasts now available on ni website. and suggestion, any feed back, any new PhD research idea.all welcomed and appreciated.
    thanks a lot
    please help to find something related to wireless, anything new for research.....please
    Labview Lover

    Labview Lover wrote:
    again please, any suggestion of new idea about wireless communications systems??.....please help me guys.....you are my only hope.
    refer to me clear links, as am a biggner using labview...
    BIG THANK TO YOU MY PEOPLE
    Not that it will be of much use to you but I have another Sea_Story I can tell.
    I'm siting in  project Kick-off meeting with the my PHD customer whos' first language is not English. He seak english well but he has a tendancy to talk with his hands.
    So he explaining to us all of the sensors I wil interface with and as he does, he would make the hand gesture showing where the sensors get applied to the test subject. So my boss has to ask about how were we going to measure the core body temperature. There are two methods they will use. The first uses a wireless transmitter the subject will swallow. It looks like a big purple pill (don't have to decide between the blue or ther red). So of course he make a hand gesture to simulate taking a pill. Byt the time he mentioned the second method the second time along with the hand gesture, I had to stop him and tell him he was freaking me out (man). So I asked him to try and control the "thumbs-up" gesture when mentioning the anal-probe.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Labview and multicore technology

    Greetings
    the scenario that i'm having now is as following:
    - I'm a 1st year PhD student,and am trying to figure out(find) a new,innovative and impressive project in wireless communications systems area. while am doing my literature review and exploring my favorit knowledge base www.ni.com website ,by chance, i read some titles about the new Multicore tech.then, after surfing most ni's webcasts i got many ideas on how to exploit this tech. together with LabVIEW to boost up my yet-undefined PhD wireless com.main project.in other words,i want to speed-up any existing wireless technology (e.g beamforming algorithms of smart antennas).However, while i met my supervisor i did for him a quick demo and he was wondering about which wireless topic we can make use of multicore tech together with labview,i suggested him {improving wireless systems using multicore tech. and labview coding}.But, a class A student told us that that multithreading problems of multicore tech. have already been solved by software giants, and nothing special about using labview to design parallel processing as many other text-based langauges can do the same,as their compilers already designed for multicore systems.I get depressed actually after he told me this.becuase am intending to use labview (my most favorit software with multicore tech to simulate the performance of a wireless system,and publish a paper about this topic.
    in short gentle men, i wish u guide me and tell me anything related to multicore tech with labview.any new problem you want to simulate it using labview so that i can work on it using labview.and please try to refer me to the latest updates about multicore and latest webcast as i saw almost all webcasts now available on ni website. and suggestion, any feed back, any new PhD research idea.all welcomed and appreciated.
    thanks a lot
    please help to find something related to wireless, anything new for research.....please
    Labview Lover

    Labview Lover wrote:
    labview (my most favorit software with multicore tech to simulate the performance of a wireless system,and publish a paper about this topic.
    Why not do a project using Labview to create different models of wireless technologies, and create simulations toevaluate their potential performance.  The benefit of multi-core programming would be to optimize the speed to which you canrun simulations of the models.  For instance, you can include spectral analysis using LabVIEW.  
    An idea would be to do the above for RAKE receivers or Software Defined Radios.  There are many things you can research and investigate using LabVIEW.  You can create the hardware and compare physical to the model.  There are lots of project ideas in this area.
    R

Maybe you are looking for