Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > thread problem.....

Reply
Thread Tools

thread problem.....

 
 
Pokkai Dokkai
Guest
Posts: n/a
 
      10-09-2007
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-forum.com/.

 
Reply With Quote
 
 
 
 
Pokkai Dokkai
Guest
Posts: n/a
 
      10-09-2007
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-forum.com/.

 
Reply With Quote
 
 
 
 
Greg Willits
Guest
Posts: n/a
 
      10-09-2007
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/Green_threads

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

 
Reply With Quote
 
7stud --
Guest
Posts: n/a
 
      10-09-2007
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-forum.com/.

 
Reply With Quote
 
khaines@enigo.com
Guest
Posts: n/a
 
      10-09-2007
On Tue, 9 Oct 2007, 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.


It's not that simple. With Ruby's green threads, it all depends on
whether there's a latency somewhere, in one thread, that can allow another
to make use of that time and get something done.

You aren't going to find that latency in any CPU bound operation, and you
aren't going to find that latency in any extension to Ruby that was not
written to be Ruby aware.

If your problem is IO bound, though, ruby can capture that time where one
thread is waiting on IO to let another thtread do something. In those
cases, you can get a speedup from Ruby's green threads.


Kirk Haines


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Terminating a thread from the main thread Charles A. Lackman ASP .Net 3 12-09-2004 02:12 PM
Thread was being aborted thrown for background thread (win2003 ser =?Utf-8?B?Sm9oYW5uYQ==?= ASP .Net 3 10-15-2004 01:35 PM
Thread was being aborted in win2003 server. Back ground thread reading MS access database, no redirects or transfers. Johanna ASP .Net 0 10-13-2004 01:32 PM
"Thread was being aborted" error from WebApp using Thread.Sleep. Stephen Miller ASP .Net 3 07-01-2004 11:50 PM
perl 5.8.2/3 - thread started by a thread pawo Perl 0 02-16-2004 01:18 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57