Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: threads and low values with Time::HiRes::setitimer

by liz (Monsignor)
on Sep 06, 2003 at 08:25 UTC ( [id://289437]=note: print w/replies, xml ) Need Help??


in reply to threads and low values with Time::HiRes::setitimer

I guess I have two questions for you:
  1. How many CPU's does your computer have?
  2. How many threads do you think a single CPU can handle simultaneously?

Then think about what you're trying to achieve.

I would like to point out that Perl ithreads are not lightweight. Whatever you're trying to achieve is so very CPU dependent that you will never be able to do that in Perl 5 with the current ithreads implementation.

Maybe you can do what you want using POE.

Or try using C and POSIX threads. But even then you should realize that (most modern) thread implementations depend on a scheduler that decides to give the next timeslice to this or an other thread. Such a scheduler is usually dependent on some hardware timer event. Once you get close to the resolution of that timer event, you're going to see "disturbances". If you know any physics, think "waves" versus "photons".

Hope this helps.

Liz

  • Comment on Re: threads and low values with Time::HiRes::setitimer

Replies are listed 'Best First'.
Re: Re: threads and low values with Time::HiRes::setitimer
by revdiablo (Prior) on Sep 06, 2003 at 18:02 UTC
    How many threads do you think a single CPU can handle simultaneously?

    Well, maybe my question didn't accurately reflect my intentions. I don't necessary want all this stuff to happen simultaneously but just closer to eachother than it currently is (this is what I meant when I said "roughly simultaneously"). Maybe asking for my code to trigger closer than a few 100ths of a second is too much? (This is not a rhetorical question. I really don't know if this is reasonable or not.) If so, I'll think of another approach... though I must admit I was quite excited to be using threads for something like this. =)

    Maybe you can do what you want using POE.

    This may be my next best option. I'll definitely take a good look if I can't get the threads to work.

    Hope this helps.

    Definitely. Thanks very much for the reply.

    PS: Your Things you need to know before programming Perl ithreads post is partially what made me want to play with threads in the first place. I'm not sure if that will be more or less reassuring to you, considering what I'm trying to do. Perhaps I entirely missed the point of your post? :)

      ...Maybe asking for my code to trigger closer than a few 100ths of a second is too much?

      I think it is. I must admit I don't know the kernel nitty gritty of this, but I'm fairly sure that timer 0 (check procinfo on Linux) is related to forced context switches (context switches forced by the Operating System when a thread/process is using more than it's alotted). That timer runs at a frequency of around 100Hz.

      Liz

Re: Re: threads and low values with Time::HiRes::setitimer
by deliria (Chaplain) on Sep 06, 2003 at 11:42 UTC
    How many threads do you think a single CPU can handle simultaneously?

    Maybe slightly OT, but do you happen to know how a Hypertreaded Xeon processor deals with this? The only processors of that type i have access to are on production machines with 5.6.1, so it's not very usefull to test on those i think.

    Kind regards,
    Deliria.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://289437]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (8)
As of 2024-04-19 08:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found