Skip to content
Tcl Source Code History Of Ticket 416643ffffffffff
Login

History Of Ticket 416643ffffffffff

Artifacts Associated With Ticket 416643ffffffffff

  1. Ticket change [ce2c4b8ed4] (rid 96012) by davygrvy on 2001-04-17 11:27:49:

    1. assignee initialized to: "nobody"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      This is having difficulty on windows.  Isn't the c-
      runtime supposed to handle this situation just fine?  
      I'm perplexed by this:
      
      
      package require Thread
      
      foreach a {1 2 3 4 5 6} {
         set threads($a) [thread::create { proc doit {} { 
      puts [expr {rand()}] }; thread::wait }]
      }
      
      foreach a {1 2 3 4 5 6} {
         thread::send -async $threads($a) doit
      }
      
      foreach a {1 2 3 4 5 6} {
         thread::send -async $threads($a) thread::exit
      }
      
      
      C:\Program Files\Tcl\bin>tclsh84t
      % source test.tcl
      % 0.0541875106535
      0.0541875106535
      0.0541875106535
      0.0541875106535
      0.0541875106535
      0.0541875106535
      
      
      I really don't think this is a Tcl inherit to Tcl, but 
      does show an interesting behavior.  Changing the run 
      to be syncronous got this:
      
      package require Thread
      
      foreach a {1 2 3 4 5 6} {
         thread::create { puts [expr {rand()}] }
      }
      
      % source test.tcl
      0.11639496317
      0.366838779471
      0.366838779471
      0.484234318363
      0.609456226513
      % 0.726851765405
      
      
      The docs state "Each interpreter has it's own seed." 
      on the expr man page, but I tend to disagree after 
      seeing the above.  Where's the seeding happening?  
      Should Tcl_CreateInterp() do the seeding?
      
    4. foundin initialized to: "obsolete: 8.4a2"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "davygrvy"
    9. subsystem initialized to: "49. Threading"
    10. title initialized to: "rand() has identical results in threads."
    11. type initialized to: "Bug"
  2. Ticket change [135e8919d7] (rid 124205) by davygrvy on 2001-04-17 18:31:21:

    1. icomment:
      Logged In: YES 
      user_id=7549
      
      wait a sec...  2 of those in the syncronous test were 
      identical.  This is interesting :)
      
      
    2. login: "davygrvy"
    3. mimetype: "text/plain"
    4. username: "davygrvy"
  3. Ticket change [7750a4613e] (rid 89757) by dgp on 2001-04-18 03:07:37:

    1. icomment:
      Logged In: YES 
      user_id=80530
      
      Is this a new problem, or does it also exist in Tcl 8.3.2?
      
      Tcl has it's own rand() implementation -- it does not call
      a system rand() -- so this problem is a problem with Tcl.
      
      There is one seed per interp: iPtr->randSeed, and it is
      initialized in ExprRandFunc() in generic/tclExecute.c.
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  4. Ticket change [e1e9c0e968] (rid 87530) by davygrvy on 2001-04-18 04:49:03:

    1. icomment:
      Logged In: YES 
      user_id=7549
      
      I haven't checked 8.3.2 or 8.3.3, yet.
      
      It could be possible that all 6 threads hit this bit of 
      code at the exact same time (line 4087, tclExecute.c):
      
      iPtr->randSeed = TclpGetClicks();
      
      I leave this up to you guys.  I'm not sure if this is 
      really a "bug" or not.  I can send all the threads a seed 
      when I start them.  I can get around the behavior in 
      script.  I don't know if this warrants a sluething.
      
      
    2. login: "davygrvy"
    3. mimetype: "text/plain"
    4. username: "davygrvy"
  5. Ticket change [b8076dadbd] (rid 128904) by dgp on 2001-04-18 04:52:23:

    1. icomment:
      Logged In: YES 
      user_id=80530
      
      Since I just rewrote rand() for Tcl 8.4a2 and Tcl 8.3.3,
      I want to find out whether this is something new I broke
      or not.
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  6. Ticket change [7f507bb7c9] (rid 97546) by dgp on 2001-04-18 05:13:28:

    1. icomment:
      Logged In: YES 
      user_id=80530
      
      Ah.  I see you report this on Windows.  Do you still see
      this behavior using the latest CVS HEAD sources (8.4a3)?
      Since 8.4a2 was released, Kevin Kenny enhanced TclpGetTime
      to get much finer "clicks" resolution on Windows.  That
      might take care of this.
      
      If you're really using 8.4a2, that rules out the new
      rand() code too, since it was added since then.
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  7. Ticket change [2957c71607] (rid 88857) by davygrvy on 2001-04-18 06:15:59:

    1. icomment:
      Logged In: YES 
      user_id=7549
      
      Say I do update and rebuild for the HEAD, and all threads 
      do hit line 4087, tclExecute.c:
      
      iPtr->randSeed = TclpGetClicks();
      
      and for the sake of discussion, TclpGetClicks() returns the 
      exact same result for all threads running in parallel.  
      Even with a higher resolution of the timer, the 
      *possibility* for a same seed value still exists.
      
      Would it make sense to have the thread extension do this 
      for me by pre-seeding so even if parallel threads call rand
      () at the exact same moment, the return will be different?
      
      
    2. login: "davygrvy"
    3. mimetype: "text/plain"
    4. username: "davygrvy"
  8. Ticket change [28d86f9bf3] (rid 88772) by davygrvy on 2001-04-20 08:49:36:

    1. icomment:
      Logged In: YES 
      user_id=7549
      
      Don,
      
      I'm happy with the attached patch.  These are the results 
      for me (on windows) running the first code snippit:
      
      source test2.tcl
      % 0.928865028046
      0.515779082904
      0.648316936404
      0.315270977707
      0.826455665671
      0.931451399779
      source test2.tcl
      % 0.878650014232
      0.370051698
      0.808093390804
      0.0654099826074
      0.547328303357
      0.958690000679
      source test2.tcl
      % 0.210988179879
      0.774670734897
      0.41666902854
      0.185170308307
      0.105992445772
      0.954533711986
      info patch
      8.4a3
      %
      
      If I remember correctly, Thread IDs on UNIX have smaller 
      numbers then on windows and might not effectively shift 
      TclpGetClicks deeply enough.  I'll leave the math up 
      someone more qualified than myself.
      
      
    2. login: "davygrvy"
    3. mimetype: "text/plain"
    4. username: "davygrvy"
  9. Add attachment "rand_patch.txt" [3e908255a3] (rid 121292) by davygrvy on 2001-04-20 10:20:40.

  10. Ticket change [d990568eb2] (rid 107633) by davygrvy on 2001-04-20 10:20:41:

    1. icomment:
      
      
      File Added - 5549: rand_patch.txt
      
      
      
    2. login: "davygrvy"
    3. mimetype: "text/plain"
    4. username: "davygrvy"
  11. Ticket change [176dc35986] (rid 122493) by davygrvy on 2001-04-21 05:36:17:

    1. icomment:
      Logged In: YES 
      user_id=7549
      
      This seems to work Ok, too.
      
      iPtr->randSeed = TclpGetClicks() ^ ((long) 
      Tcl_GetCurrentThread() << ((TclpGetClicks() % 10) + 17));
      
      
      
    2. login: "davygrvy"
    3. mimetype: "text/plain"
    4. username: "davygrvy"
  12. Ticket change [d67b8d3180] (rid 123813) by davygrvy on 2001-04-26 08:01:39:

    1. assignee changed to: "dgp"
    2. icomment:
      Logged In: YES 
      user_id=7549
      
      Don,
      
      I hand this to you.  I can handle this from script anyways, 
      so it's no rush.
      
      
    3. login: "davygrvy"
    4. mimetype: "text/plain"
    5. username: "davygrvy"
  13. Ticket change [4cd3dec497] (rid 126953) by dgp on 2001-04-30 01:35:18:

    1. assignee changed to: "nobody"
    2. icomment:
      Logged In: YES 
      user_id=80530
      
      The patch looks OK to me.  I think I would add
      a more detailed explanation in the comment about
      why the Tcl_GetCurrentThread call is there, maybe
      even a link back to this bug report.
      
      I'm assigning this to the proper Category for final
      maintainer review and commit.
      
      
    3. login: "dgp"
    4. mimetype: "text/plain"
    5. subsystem changed to: "47. Bytecode Compiler"
    6. username: "dgp"
  14. Ticket change [4e561a73ae] (rid 127210) by msofer on 2001-05-05 05:31:09:

    1. assignee changed to: "msofer"
  15. Ticket change [3b833c440c] (rid 112759) by msofer on 2001-05-08 05:16:08:

    1. closedate changed to: "2001-05-07T22:16:08"
    2. closer changed to: "msofer"
    3. icomment:
      Logged In: YES 
      user_id=148712
      
      Patch committed.
      
      
    4. login: "msofer"
    5. mimetype: "text/plain"
    6. resolution changed to: "Fixed"
    7. status changed to: "Closed"
    8. username: "msofer"