Fri Apr 26 08:06:02 2024
EVENTS
 FREE
SOFTWARE
INSTITUTE

POLITICS
JOBS
MEMBERS'
CORNER

MAILING
LIST

NYLXS Mailing Lists and Archives
NYLXS Members have a lot to say and share but we don't keep many secrets. Join the Hangout Mailing List and say your peice.

DATE 2015-04-01

HANGOUT

2024-04-26 | 2024-03-26 | 2024-02-26 | 2024-01-26 | 2023-12-26 | 2023-11-26 | 2023-10-26 | 2023-09-26 | 2023-08-26 | 2023-07-26 | 2023-06-26 | 2023-05-26 | 2023-04-26 | 2023-03-26 | 2023-02-26 | 2023-01-26 | 2022-12-26 | 2022-11-26 | 2022-10-26 | 2022-09-26 | 2022-08-26 | 2022-07-26 | 2022-06-26 | 2022-05-26 | 2022-04-26 | 2022-03-26 | 2022-02-26 | 2022-01-26 | 2021-12-26 | 2021-11-26 | 2021-10-26 | 2021-09-26 | 2021-08-26 | 2021-07-26 | 2021-06-26 | 2021-05-26 | 2021-04-26 | 2021-03-26 | 2021-02-26 | 2021-01-26 | 2020-12-26 | 2020-11-26 | 2020-10-26 | 2020-09-26 | 2020-08-26 | 2020-07-26 | 2020-06-26 | 2020-05-26 | 2020-04-26 | 2020-03-26 | 2020-02-26 | 2020-01-26 | 2019-12-26 | 2019-11-26 | 2019-10-26 | 2019-09-26 | 2019-08-26 | 2019-07-26 | 2019-06-26 | 2019-05-26 | 2019-04-26 | 2019-03-26 | 2019-02-26 | 2019-01-26 | 2018-12-26 | 2018-11-26 | 2018-10-26 | 2018-09-26 | 2018-08-26 | 2018-07-26 | 2018-06-26 | 2018-05-26 | 2018-04-26 | 2018-03-26 | 2018-02-26 | 2018-01-26 | 2017-12-26 | 2017-11-26 | 2017-10-26 | 2017-09-26 | 2017-08-26 | 2017-07-26 | 2017-06-26 | 2017-05-26 | 2017-04-26 | 2017-03-26 | 2017-02-26 | 2017-01-26 | 2016-12-26 | 2016-11-26 | 2016-10-26 | 2016-09-26 | 2016-08-26 | 2016-07-26 | 2016-06-26 | 2016-05-26 | 2016-04-26 | 2016-03-26 | 2016-02-26 | 2016-01-26 | 2015-12-26 | 2015-11-26 | 2015-10-26 | 2015-09-26 | 2015-08-26 | 2015-07-26 | 2015-06-26 | 2015-05-26 | 2015-04-26 | 2015-03-26 | 2015-02-26 | 2015-01-26 | 2014-12-26 | 2014-11-26 | 2014-10-26 | 2014-09-26 | 2014-08-26 | 2014-07-26 | 2014-06-26 | 2014-05-26 | 2014-04-26 | 2014-03-26 | 2014-02-26 | 2014-01-26 | 2013-12-26 | 2013-11-26 | 2013-10-26 | 2013-09-26 | 2013-08-26 | 2013-07-26 | 2013-06-26 | 2013-05-26 | 2013-04-26 | 2013-03-26 | 2013-02-26 | 2013-01-26 | 2012-12-26 | 2012-11-26 | 2012-10-26 | 2012-09-26 | 2012-08-26 | 2012-07-26 | 2012-06-26 | 2012-05-26 | 2012-04-26 | 2012-03-26 | 2012-02-26 | 2012-01-26 | 2011-12-26 | 2011-11-26 | 2011-10-26 | 2011-09-26 | 2011-08-26 | 2011-07-26 | 2011-06-26 | 2011-05-26 | 2011-04-26 | 2011-03-26 | 2011-02-26 | 2011-01-26 | 2010-12-26 | 2010-11-26 | 2010-10-26 | 2010-09-26 | 2010-08-26 | 2010-07-26 | 2010-06-26 | 2010-05-26 | 2010-04-26 | 2010-03-26 | 2010-02-26 | 2010-01-26 | 2009-12-26 | 2009-11-26 | 2009-10-26 | 2009-09-26 | 2009-08-26 | 2009-07-26 | 2009-06-26 | 2009-05-26 | 2009-04-26 | 2009-03-26 | 2009-02-26 | 2009-01-26 | 2008-12-26 | 2008-11-26 | 2008-10-26 | 2008-09-26 | 2008-08-26 | 2008-07-26 | 2008-06-26 | 2008-05-26 | 2008-04-26 | 2008-03-26 | 2008-02-26 | 2008-01-26 | 2007-12-26 | 2007-11-26 | 2007-10-26 | 2007-09-26 | 2007-08-26 | 2007-07-26 | 2007-06-26 | 2007-05-26 | 2007-04-26 | 2007-03-26 | 2007-02-26 | 2007-01-26 | 2006-12-26 | 2006-11-26 | 2006-10-26 | 2006-09-26 | 2006-08-26 | 2006-07-26 | 2006-06-26 | 2006-05-26 | 2006-04-26 | 2006-03-26 | 2006-02-26 | 2006-01-26 | 2005-12-26 | 2005-11-26 | 2005-10-26 | 2005-09-26 | 2005-08-26 | 2005-07-26 | 2005-06-26 | 2005-05-26 | 2005-04-26 | 2005-03-26 | 2005-02-26 | 2005-01-26 | 2004-12-26 | 2004-11-26 | 2004-10-26 | 2004-09-26 | 2004-08-26 | 2004-07-26 | 2004-06-26 | 2004-05-26 | 2004-04-26 | 2004-03-26 | 2004-02-26 | 2004-01-26 | 2003-12-26 | 2003-11-26 | 2003-10-26 | 2003-09-26 | 2003-08-26 | 2003-07-26 | 2003-06-26 | 2003-05-26 | 2003-04-26 | 2003-03-26 | 2003-02-26 | 2003-01-26 | 2002-12-26 | 2002-11-26 | 2002-10-26 | 2002-09-26 | 2002-08-26 | 2002-07-26 | 2002-06-26 | 2002-05-26 | 2002-04-26 | 2002-03-26 | 2002-02-26 | 2002-01-26 | 2001-12-26 | 2001-11-26 | 2001-10-26 | 2001-09-26 | 2001-08-26 | 2001-07-26 | 2001-06-26 | 2001-05-26 | 2001-04-26 | 2001-03-26 | 2001-02-26 | 2001-01-26 | 2000-12-26 | 2000-11-26 | 2000-10-26 | 2000-09-26 | 2000-08-26 | 2000-07-26 | 2000-06-26 | 2000-05-26 | 2000-04-26 | 2000-03-26 | 2000-02-26 | 2000-01-26 | 1999-12-26

Key: Value:

Key: Value:

MESSAGE
DATE 2015-04-02
FROM Ruben Safir
SUBJECT Subject: [NYLXS - HANGOUT] Re: omp pthread madness

On 04/02/2015 10:26 AM, Jens Thoms Toerring wrote:
> ruben wrote:
>> On Wed, 01 Apr 2015 10:04:59 +0000, Jens Thoms Toerring wrote:
>
>>> The obvious problem is that you have (at least) 2 threads which
>>> uncoordinatedly write into shared, global variables.
>
>> How is it uncoordinated. I couldn't think of anything that is shared
>> that would upset the final result.
>
> It is uncoordinated because it's unpredictable in which sequence
> the threads will access these global variables and, worse, they
> may do it at the same time.
>
> Are you aware of the 'sig_atomic_t' type in C? The reason
> for its existence is that reads from or writes to even
> something simple as an integer isn't "atomic", i.e. one
> thread may have updated parts of that integer (say one of
> the bytes it consists of) when another thread gets sche-
> duled and tries to read this integer which is now in some
> strange state. So the second thread will get some more or
> less random value instead of what the programmer expected.
> Or let's have thread 1 having started to update the integer,
> then thread 2 comes along, updates all of it and then we're
> back in thread 1 that writes the parts it hadn't got around
> to before. Result? A random value in memory. What's special
> about the 'sig_atomic_t' is that with that type this can't
> happen, you're guaranteed that a thread of execution can't
> be interupted while it writes or reads it.
>
> Now, if this already can happen with integers, it clearly isn't
> any better with floats or doubles. And your program assumes
> obviously that the random values you write into the 'workspace'
> have a well-definen upper limit (looks like it's 1). Unccor-
> dinated writes to the same location may result in values that
> doesn't satisfy this condition. And in other cases values
> may be smaller. You probably won't notice it, but it can
> happen and add some additional noise to the results of
> your calculations.
>
> Another place were things can go wrong is with your
> 'inside_the_circle' variable. There's a non-vanishing
> chance that, for the line
>
> inside_the_circle++;
>
> the following happens: thread 1 reads its value to increment
> it. Along comes thread 2 and possibly increments it several
> times before thread 1 gets to finish what it set out to do.
> Then it will increment ther value it had read and write it
> into memory, thereby destroying all the work the other thread
> had done in between.
>
> Or you may end up with a situation where the compiler
> optimizes your program in way that during the count_inside()
> function the value of 'inside_the_circle' is kept in a CPU
> register and only this copy is incremented. It's then only
> written out at the very end of the function. And then, when
> both threads run that function at the same time, they both
> increment their copy in the CPU register and write it out at
> the end, with the thread getting there last simply overwri-
> ting whatever any other thread had put there before.
>
> So you can't trust what this variable is set to when both
> threads are done with it.
>
> In any case, if you'd run your program several times with
> the same seed for the random generator you'll rather likely
> end up with different results. Your program has become in-
> deterministic with its result depending on subtle timing
> differences in how the threads get scheduled or access
> your global variables. That's something one tries to avoid
> like the plague.
> Regards, Jens
>

  1. 2015-04-01 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] omp pthread madness
  2. 2015-04-02 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] Fwd: omp pthread madness
  3. 2015-04-02 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] Re: omp pthread madness
  4. 2015-04-02 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] Fwd: [New discussion] which technologies/skills are good to have
  5. 2015-04-02 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] Fwd: omp pthread madness
  6. 2015-04-02 mrbrklyn-at-panix.com Subject: [NYLXS - HANGOUT] [LinuxJournalservices-at-linuxjournalservices.com: Free Geek
  7. 2015-04-02 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] Fwd: Fw: Perl Developer / Linux SysAdmin Opportunities in South Florida
  8. 2015-04-07 Elfen Magix <elfen_magix-at-yahoo.com> Subject: [NYLXS - HANGOUT] Low Cost or Free Raspberry Pi's?
  9. 2015-04-07 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] Let My People Go
  10. 2015-04-08 Rick Moen <rick-at-linuxmafia.com> Subject: [NYLXS - HANGOUT] (forw) Re: DistroWatch.com: Put the fun back into computing. Use
  11. 2015-04-08 adrba-at-nyct.net Re: [NYLXS - HANGOUT] Let My People Go
  12. 2015-04-08 adrba-at-nyct.net Re: [NYLXS - HANGOUT] JOUNAL MEETING AT 10AM TOMORROW
  13. 2015-04-08 Steven Ovadia <steve.ovadia-at-gmail.com> Subject: [NYLXS - HANGOUT] Explore Privacy Issues at the LACUNY Institute!
  14. 2015-04-09 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] Re: Kernel thread scheduling
  15. 2015-04-09 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] Re: Kernel thread scheduling
  16. 2015-04-10 Elfen Magix <elfen_magix-at-yahoo.com> Subject: [NYLXS - HANGOUT] Bulk Raspberry Pi Deal A Failure.
  17. 2015-04-12 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] Kernel Hacking Workshop - Focusing on the CFS Scheduler
  18. 2015-04-13 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] Schedule Meetings
  19. 2015-04-13 Robert Menes <viewtiful.icchan-at-gmail.com> Re: [NYLXS - HANGOUT] Schedule Meetings
  20. 2015-04-13 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] Kernel Hacking Resources
  21. 2015-04-14 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] Fwd: Invitation: Vintage Computer Festival
  22. 2015-04-14 einker <eminker-at-gmail.com> Re: [NYLXS - HANGOUT] Fwd: Invitation: Vintage Computer Festival
  23. 2015-04-15 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] Fwd: Monday: Join 121 HackerNestologists at "HackerNest NYC April
  24. 2015-04-15 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] [ruben-at-mrbrklyn.com: Re: Heap Management Problem]
  25. 2015-04-15 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] Fwd: [HackerNestNYC] Security Info for Monday's HackerNest NYC
  26. 2015-04-15 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] Fwd: Re: [LIU Comp Sci] BASh Shell Scripting
  27. 2015-04-16 Ruben Safir <mrbrklyn-at-panix.com> Re: [NYLXS - HANGOUT] Schedule Meetings
  28. 2015-04-16 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] linsched
  29. 2015-04-16 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] Fwd: Re: virtualbox
  30. 2015-04-16 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] Fwd: Re: Kernel thread scheduling
  31. 2015-04-17 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] Kernel Scheduling Project
  32. 2015-04-17 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] Graduate School goes in circles
  33. 2015-04-17 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] Come Sunday Morning
  34. 2015-04-19 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] Re: The more I learn the less I know
  35. 2015-04-19 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] interesting jobs
  36. 2015-04-19 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] marco typeof and 0
  37. 2015-04-19 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] Summers Here
  38. 2015-04-19 Ruben Safir <mrbrklyn-at-panix.com> Re: [LIU Comp Sci] Fwd: [NYLXS - HANGOUT] Summers Here
  39. 2015-04-19 Ruben <mrbrklyn-at-panix.com> Re: [LIU Comp Sci] Fwd: [NYLXS - HANGOUT] Summers Here
  40. 2015-04-19 Elfen Magix <elfen_magix-at-yahoo.com> Re: [NYLXS - HANGOUT] Summers Here
  41. 2015-04-19 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] Syria and Sarin Gas
  42. 2015-04-19 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] extract video
  43. 2015-04-19 Ruben Safir <mrbrklyn-at-panix.com> Re: [NYLXS - HANGOUT] Syria and Sarin Gas
  44. 2015-04-20 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] sytemd crimes
  45. 2015-04-20 Ruben <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] OS Homework
  46. 2015-04-21 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] Skinner Box
  47. 2015-04-21 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] Business children and Privacy
  48. 2015-04-21 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] nukes in NYC
  49. 2015-04-21 Ruben Safir <mrbrklyn-at-panix.com> Re: [NYLXS - HANGOUT] nukes in NYC
  50. 2015-04-21 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] Nukes over NYC
  51. 2015-04-24 adrba-at-nyct.net Re: [NYLXS - HANGOUT] Summers Here LET'S
  52. 2015-04-25 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] Fwd: Kernel Scheduling and wait queues
  53. 2015-04-26 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] While the weather is heating up ...
  54. 2015-04-27 Ruben Safir <mrbrklyn-at-panix.com> Re: [NYLXS - HANGOUT] While the weather is heating up ...
  55. 2015-04-27 mrbrklyn-at-panix.com Subject: [NYLXS - HANGOUT] [info-at-fsf.org: DMCA exemption commenting process broken beyond
  56. 2015-04-28 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] Re: Arduino article for next Linux Journal
  57. 2015-04-28 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] final project - Linux Scheduler
  58. 2015-04-29 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] trolling newsgroupds
  59. 2015-04-30 Ruben Safir <mrbrklyn-at-panix.com> Subject: [NYLXS - HANGOUT] usenet and systemd
  60. 2015-04-30 Elfen Magix <elfen_magix-at-yahoo.com> Subject: [NYLXS - HANGOUT] NYC ROBO Conference

NYLXS are Do'ers and the first step of Doing is Joining! Join NYLXS and make a difference in your community today!