~ubuntu-branches/ubuntu/intrepid/ruby1.9/intrepid-updates

« back to all changes in this revision

Viewing changes to benchmark/bm_vm3_thread_mutex.rb

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2007-09-04 16:01:17 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20070904160117-i15zckg2nhxe9fyw
Tags: 1.9.0+20070830-2ubuntu1
* Sync from Debian; remaining changes:
  - Add -g to CFLAGS.
* Fixes build failure on ia64.
* Fixes build failure with gcc-4.2 on lpia.
* Robustify check for target_os, fixing build failure on lpia.
* Set Ubuntu maintainer address.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
require 'thread'
 
2
m = Mutex.new
 
3
r = 0
 
4
max = 1000
 
5
(1..max).map{
 
6
  Thread.new{
 
7
    i=0
 
8
    while i<max
 
9
      i+=1
 
10
      m.synchronize{
 
11
        r += 1
 
12
      }
 
13
    end
 
14
  }
 
15
}.each{|e|
 
16
  e.join
 
17
}
 
18
raise r.to_s if r != max * max