No deterministic results with spinlock

Solution Verified - Updated -

Issue

  • This simple source code demonstrates the problem in which PThread spinlocks perform with drastically different results. All one has to do is run it several times to see. May run in 6 seconds or 15 seconds. PThread mutexes do not exhibit this behaviour.
g++ -lpthread spin.cpp

Elapsed: 6463623
medinaa{164}: ./a.out
Elapsed: 6698702
medinaa{164}: ./a.out
Elapsed: 9361279
medinaa{164}: ./a.out
Elapsed: 6438923
medinaa{164}: ./a.out
Elapsed: 15922792
  • Sample pthread spinlocks perform with drastically different time results (6-15 seconds in example), while pthread mutexs are more consistent

Environment

  • Red Hat Enterprise Linux Server release 6.3 (Santiago)
  • kernel-2.6.32-358.23.2.el6.x86_64
  • cmdline: nosoftlockup intel_idle.max_cstate=0 mce=ignore_ce processor.max_cstate=0 nomodeset3 vga=normal

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In