Forum: Ruby thread scheduling

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
52a177e9dbd3e614825aabc4e45f8cd6?d=identicon&s=25 Mark Volkmann (Guest)
on 2006-01-10 23:53
(Received via mailing list)
I've search for documentation about whether Ruby thread scheduling
uses FIFO or round-robin and can't find anything. It seems to be
round-robin. Is that correct?

Is there a way to control the time slice used for each thread running
at the same priority?
5befe95e6648daec3dd5728cd36602d0?d=identicon&s=25 Robert Klemme (Guest)
on 2006-01-11 10:55
(Received via mailing list)
Mark Volkmann wrote:
> I've search for documentation about whether Ruby thread scheduling
> uses FIFO or round-robin and can't find anything. It seems to be
> round-robin. Is that correct?
>
> Is there a way to control the time slice used for each thread running
> at the same priority?

No direct means AFAIK.  You can always use Thread#pass but I recommend
to
not to.  Also, there are no thread priorities AFAIK.

    robert
52a177e9dbd3e614825aabc4e45f8cd6?d=identicon&s=25 Mark Volkmann (Guest)
on 2006-01-11 15:10
(Received via mailing list)
On 1/11/06, Robert Klemme <bob.news@gmx.net> wrote:
> Mark Volkmann wrote:
> > I've search for documentation about whether Ruby thread scheduling
> > uses FIFO or round-robin and can't find anything. It seems to be
> > round-robin. Is that correct?
> >
> > Is there a way to control the time slice used for each thread running
> > at the same priority?
>
> No direct means AFAIK.  You can always use Thread#pass but I recommend to
> not to.  Also, there are no thread priorities AFAIK.

The Thread class has priority and priority= instance methods. I
created two threads and noticed that they were time slicing. Then I
set the priority of one to be higher than the other and it got all the
time until it completed. So thread priorities seem to be supported.
Ce60c4f78a63b0695e4dafc4bd7964f7?d=identicon&s=25 Lou Vanek (Guest)
on 2006-01-11 15:48
(Received via mailing list)
Mark Volkmann wrote:

> I've search for documentation about whether Ruby thread scheduling
> uses FIFO or round-robin and can't find anything. It seems to be
> round-robin. Is that correct?

all threads being equal, it's round robin.

the thread scheduler is called rb_thread_schedule in the eval.c file.



> Is there a way to control the time slice used for each thread running
> at the same priority?

you would have to change the hard-coded time (integer) values
in the eval.c file and recompile ruby.
52a177e9dbd3e614825aabc4e45f8cd6?d=identicon&s=25 Mark Volkmann (Guest)
on 2006-01-11 16:18
(Received via mailing list)
On 1/11/06, Lou Vanek <vanek@acd.net> wrote:
> > Is there a way to control the time slice used for each thread running
> > at the same priority?
>
> you would have to change the hard-coded time (integer) values
> in the eval.c file and recompile ruby.

Thanks for the info!  That's some tough code to read. I thought I
could at least find the time slice duration, but I failed. Do you know
which variable/constant holds that?  Is it WAIT_TIME?  That has a
value of (1<<2) which I guess is equal to 4. 4 what? milliseconds?
microseconds?
Ce60c4f78a63b0695e4dafc4bd7964f7?d=identicon&s=25 Lou Vanek (Guest)
on 2006-01-11 17:30
(Received via mailing list)
times are set in either function:

   thread_timer, or
   rb_thread_start_timer,

depending on whether _THREAD_SAFE is set (on my platform it is).

On my platform, time slice is set to 10 milliseconds:

   req.tv_nsec = 10000000;


WAIT_TIME is just a flag. It is not the amount of time to wait.
This topic is locked and can not be replied to.