thread scheduling

M

Mark Volkmann

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?
 
R

Robert Klemme

Mark said:
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
 
M

Mark Volkmann

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=3D 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.
 
L

Lou Vanek

Mark said:
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.

 
M

Mark Volkmann

all threads being equal, it's round robin.

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


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?
 
L

Lou Vanek

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,226
Latest member
KristanTal

Latest Threads

Top