⚲
Project
General
Profile
Sign in
Register
Home
Projects
Help
Search
:
Ruby master
All Projects
Ruby
»
Ruby master
Overview
Activity
Roadmap
Issues
Repository
Like
Download (1.01 KB)
Bug #10009
» test_thread_sched_pipe.rb
normalperson (Eric Wong)
, 07/08/2014 08:37 PM
#puts "definindo taskset -c -p 1 #{Process.pid}"
system
(
"taskset -c -p 2
#{
Process
.
pid
}
"
)
inicio_geral
=
Time
.
now
t1
=
Thread
.
new
do
Thread
.
current
[
:target
]
=
0
while
true
Thread
.
current
[
:target
]
+=
1
end
end
10
.
downto
(
0
)
do
|
i
|
inicio
=
Time
.
now
Kernel
.
sleep
(
1
)
puts
"faltando
#{
i
}
segundos (
#{
Time
.
now
-
inicio
}
)"
end
puts
"zerando thread com contagem em
#{
t1
[
:target
]
}
"
t1
[
:target
]
=
0
t2
=
Thread
.
new
do
Thread
.
current
[
:target
]
=
0
rd
,
wr
=
IO
.
pipe
buf
=
"."
while
true
wr
.
syswrite
(
buf
)
rd
.
readpartial
(
1
,
buf
)
Thread
.
current
[
:target
]
+=
1
end
end
t3
=
Thread
.
new
do
Thread
.
current
[
:target
]
=
0
while
true
Thread
.
current
[
:target
]
+=
1
end
end
10
.
times
do
puts
"first
#{
t1
[
:target
]
}
"
puts
"second
#{
t2
[
:target
]
}
"
puts
"third
#{
t3
[
:target
]
}
"
puts
"
\n\n
"
sleep
(
1
)
end
total
=
t1
[
:target
].
to_i
+
t2
[
:target
].
to_i
+
t3
[
:target
].
to_i
puts
"total
#{
total
}
"
puts
"media
#{
total
/
(
Time
.
now
-
inicio_geral
).
to_i
}
"
puts
"
\n\n
"
puts
"time
#{
Time
.
now
-
inicio_geral
}
"
« Previous
1
2
3
4
5
6
…
8
Next »
(4-4/8)
Loading...