Mixed Time-Share & real-Time scheduling

Mixed Time-Share & real-Time scheduling

Post by Sinan Kara » Sun, 28 Aug 1994 08:03:34



 I seem to have this problem:

 Process Proc is started in real time, it in turns creates  THR_BOUND thrA.

 And then it drops itself in time share queue and creates THR_BOUND thrB.
(Actually there are a multitude of time-share and real-time threads.)

 Now thrA runs for a while (some milliseconds, say 15 ) and then it sleeps
for some milliseconds. (This is actually done by some interrupt mechanism
but that probably is not important either) and then thrB comes in prints some
data generated by thrA and goes to sleep. So far so good. Now however
if I go to another window and do an "ls" or another command, what I am
seeing is that if "ls" starts when the time-share thread thrB is running,
it can preempt thrB, and when the time to run thrA comes again, scheduler
doesn't necessarily run thrA. Soit appears that some piece of code
in the scheduler, when it gets a level 10 interrupt, it checks the
process table, and not the LWP table to find out if any real-time
LWPs are waiting or not. So if there is NO processes in real-time
queue, it assumes that there are no real-time LWPs waiting, and skips
that portion of the scheduler.... This is pure conjecture, but I am at
a loss to explain this behaviour. This can make me sometimes lose 10 or
20 milliseconds, invalidating houirs worth of run sometimes.
It works correctly if the process is in the real-time queue. Any
suggestions. (we got and tried patch -54 just to be sure...)

Sinan

PS: platform is SS10/512MP

 
 
 

Mixed Time-Share & real-Time scheduling

Post by Bart Smaalde » Sun, 28 Aug 1994 11:02:08



Quote:

> I seem to have this problem:

> Process Proc is started in real time, it in turns creates  THR_BOUND thrA.

> And then it drops itself in time share queue and creates THR_BOUND thrB.
>(Actually there are a multitude of time-share and real-time threads.)

> Now thrA runs for a while (some milliseconds, say 15 ) and then it sleeps
>for some milliseconds. (This is actually done by some interrupt mechanism
>but that probably is not important either) and then thrB comes in prints some
>data generated by thrA and goes to sleep. So far so good. Now however
>if I go to another window and do an "ls" or another command, what I am
>seeing is that if "ls" starts when the time-share thread thrB is running,
>it can preempt thrB, and when the time to run thrA comes again, scheduler
>doesn't necessarily run thrA.

Possible causes I can think of:

1. By any chance does thrB acquire a lock to read the data produced by thrA,
   and so prevent thrA from running if thrB is blocked in a critical section?

2. By "drops itself in time share queue" do you mean a priocntl call
   that sets only the lwp of the main thread?  Or are you using the P_PID
   option.  The later case will _not_ do what you want; it sets all the lwps
   of the process back to the timeshare class.  Since the main thread is not
   bound to an lwp I would be very careful to make sure that no extraneous lwps
   exist which could run the main thread in a different class than you expect.

3) The ls command isn't doing output directly to the system console, is it?
   (E.g. with no window system running) The kernel handles raw console IO at
   a much higher priority than you might expect.

Is the system idle when the thrA isn't running, or is the ls still going as
assumed in the possible causes above?

Hope this helps -

- Bart Smaalders        Solaris Performance             SunSoft

 
 
 

Mixed Time-Share & real-Time scheduling

Post by Sinan Kara » Mon, 29 Aug 1994 06:02:08





>> I seem to have this problem:

>> Process Proc is started in real time, it in turns creates  THR_BOUND thrA.

>> And then it drops itself in time share queue and creates THR_BOUND thrB.
>>(Actually there are a multitude of time-share and real-time threads.)

>> Now thrA runs for a while (some milliseconds, say 15 ) and then it sleeps
>>for some milliseconds. (This is actually done by some interrupt mechanism
>>but that probably is not important either) and then thrB comes in prints some
>>data generated by thrA and goes to sleep. So far so good. Now however
>>if I go to another window and do an "ls" or another command, what I am
>>seeing is that if "ls" starts when the time-share thread thrB is running,
>>it can preempt thrB, and when the time to run thrA comes again, scheduler
>>doesn't necessarily run thrA.

>Possible causes I can think of:

>1. By any chance does thrB acquire a lock to read the data produced by thrA,
>   and so prevent thrA from running if thrB is blocked in a critical section?

No. No mutexes are shared between real-time and time-share threads.
All the message passing is done thru queues (Ala Aho, Hopcroft et al...)
Quote:

>2. By "drops itself in time share queue" do you mean a priocntl call
>   that sets only the lwp of the main thread?  Or are you using the P_PID

Yes.          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Quote:>   option.  The later case will _not_ do what you want; it sets all the lwps
>   of the process back to the timeshare class.  Since the main thread is not
>   bound to an lwp I would be very careful to make sure that no extraneous lwps
>   exist which could run the main thread in a different class than you expect.

This actually may be the problem, since we get symptoms that there may be
a rogue thread (renegade or whatever you want to call it...).The only
ointment in the fly is tho' main thread does not do anything.(it is
suspended). BTW if you repeatedly do a ps -c  then you see that the
scheduling class changes between TS and RT.
Quote:>3) The ls command isn't doing output directly to the system console, is it?
>   (E.g. with no window system running) The kernel handles raw console IO at
>   a much higher priority than you might expect.

No , we are running olwm/cmdtool/xterm.
Quote:

>Is the system idle when the thrA isn't running, or is the ls still going as
>assumed in the possible causes above?

thrA does all the hardware in the loop I/O and then does an ioctl,
which waits on a cv_wait which gets cv_signalled when a timer interrupts
comes in. What almost appears that when the cv_signal comes in , the
scheduler checks to see if there are any PROCESSES in the real-time queue,
if there isn't then it assumes that there is no real-time lwp's running
either.(I know this is a reach but I can't guess anything else that is
happening.) Yesterday, I changed the scheme to that now I no longer
drop the process out of the real-time queue, instead I boost the
priority of thrA (actually they are 4 threads) by 10. It worked
like a charm. Therefore the problem seems to be when there are
real-time lwp's associated with a process but when the process itself
is in the time-share.

BTW How does one get rid of the rogue lwp?. Seems the system creates
one just in case you have unbound threads. I do not quite understand
the main thread not being bound to a lwp...

Sinan

- Show quoted text -

Quote:

>Hope this helps -

>- Bart Smaalders    Solaris Performance             SunSoft

 
 
 

1. Solaris2.0/2.1 Real time "Fast" timing/scheduling

Hi,
I am porting an application that requires very fine
timing control to Solaris 2.0/2.1. I need to be able to schedule
my program at given time increments. The time increment can be
anywhere from 1 millisecond to 50 milliseconds. I gave played
with setitimer and SIGALRM , they do work fine except I can not
get better than 10 millisecond granularity. So I decided
to try something more hardware oriented and noticed that there are
2 timer/counters in the MMU chip.
Questions:

1) Does the OS use either or both of these counters?
2) Are there other timers available on the Sparc platform?
3) Does the equation change if I use a VME based SparcEngine?
4) Does/Has anybody done/? any work in this area and give me some
   pointers?
5) Are there other calls in Solaris 2.0 and derivatives that would
   allow me to what I am trying to do ????

Thanx for any and all answers/pointers/criticism/etc...
Sinan Karasu

2. open text file on xemacs windows

3. Real-time Scheduling

4. Using X on a TV screen

5. questions about poll(2) in real-time scheduling

6. "Slide Show" Screensaver

7. unix real-time scheduling?

8. Creative Labs 3D Blaster Savage 4 and RH 6.0

9. real-time scheduling on unix?

10. Real-time Scheduling

11. 2.4-ac: real-time / scheduling information out of /proc

12. threads in real-time scheduling - help needed

13. "Real-Time" Time Display in Console