#9 NBC: thread exit stops a second thread

closed
None
5
2007-02-17
2007-02-17
Rupert
No

hi,

Two threads, started at the same level (ie, both spawned by main) have the problem that when one thread exits, it freezes the other thread. The problem is shown in the attached code - it might be new in versions 25-26 of the NBC compiler, i havent tried it on older versions.

The code has two threads that just loop printing to the screen. If the jmp is commented in the first thread, it should exit after one pass - this also freezes the second thread, but does not stop the program.

(I dont know if this is a bug, or improperly used threads)

Thanks
Rupert B.

(and thanks to Andrew for the code and showing me the bug)

Discussion

  • Rupert

    Rupert - 2007-02-17

    code showing the problem

     
  • John Hansen

    John Hansen - 2007-02-17
    • assigned_to: nobody --> afanofosc_99
    • status: open --> closed
     
  • John Hansen

    John Hansen - 2007-02-17

    Logged In: YES
    user_id=661666
    Originator: NO

    This is actually not a bug in NBC. It might be considered a firmware bug but it is triggered by a bug in the program itself.

    In thread worker you have this code:

    numtostr value, val
    loop1:
    MyMacro(0, 10, FALSE, val)

    This should be:

    numtostr value, val
    loop1:
    MyMacro(0, 10, FALSE, value)

    You are setting the dtArgs.Text byte array to a scalar byte value rather than the output of the numtostr call. Making the two character change to the code fixes the hanging thread problem.

    I will add better type checking to the mov opcode so that it checks for type compatibility.

    John Hansen