[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

thread problem.....

Pokkai Dokkai

10/9/2007 3:05:00 AM

i want to make a program code ,but it ll take long time to execute
so i am spiliting my program into thread ....

but the general concept about thread is ,it will reduce the execution
time of our program under good condition (depending RAM size,Processor
speed ,etc.....)

But if the number of thread is more than that capacity of RAM ,Processor
speed,and other resouces.....then the program will be very very slow

so i want to check all the resource status(RAM ,processor,etc..) ,after
creating everyone child thread from parent thread ...

so how can i find the resource status(RAM ,processor,etc..) in the
parent thread .
so i can decide about to create next child thread.....

any idea.....
--
Posted via http://www.ruby-....

4 Answers

Pokkai Dokkai

10/9/2007 4:08:00 AM

0

Michael Bevilacqua-Linn wrote:
> 2.) The current version of Ruby only supports green threads anyhow. So
> even
> if you did have multiple cores, you wouldn't get a speedup.
>
> MBL

green thread means ?...
--
Posted via http://www.ruby-....

Greg Willits

10/9/2007 4:42:00 AM

0

Pokkai Dokkai wrote:
> Michael Bevilacqua-Linn wrote:
>> 2.) The current version of Ruby only supports green threads anyhow. So
>> even
>> if you did have multiple cores, you wouldn't get a speedup.
>>
>> MBL
>
> green thread means ?...

threads managed by the language you're working in rather than by the
operating system

http://en.wikipedia.org/wiki/Gre...

--gw
--
Posted via http://www.ruby-....

7stud 7stud

10/9/2007 8:36:00 AM

0

Michael Bevilacqua-Linn wrote:
> 1.) The only way threads get you a speedup is when you write your code
> in
> such a way that sections of it can be executed in parallel so you can
> take
> advantage of multiple cores (or processors).
>
> 2.) The current version of Ruby only supports green threads anyhow. So
> even
> if you did have multiple cores, you wouldn't get a speedup.
>
> MBL

Then perhaps you could explain the output of this program:

require 'rtiming' #a simple program that times methods

def test1
threads = []

2.times do |i|
threads[i] = Thread.new do
sleep(2)
puts "task #{i+1} finished"
end
end

threads.each do |t|
t.join
end
end

def test2
sleep(2)
puts "task 1 finished"

sleep(2)
puts "task 2 finished"
end

puts timer(:test1, 1)
puts timer(:test2, 1)


--output:---
task 2 finished
task 1 finished
Method exec time(1 loops): 2.010791 total
task 1 finished
task 2 finished
Method exec time(1 loops): 4.000226 total
--
Posted via http://www.ruby-....

khaines

10/9/2007 3:51:00 PM

0