Haris wrote:
What I want to achieve is to execute some book keeping
code before the descheduling of a thread and after the
scheduling of a thread. This bookkeeping code should save
and restore some user space state and perform possibly
perform some recovery. That is why I am thinking of two
ways to do that:
>
- either find where the kernel schedules/deschedules a
thread and send a signal to the user thread to signify
the scheduling/descheduling, or
- change the thread library implementation so it can
execute this recovery and book keeping code when it
receives a scheduling upcall from the kernel.
> So, what I want in this case is the code of the user level
dispatcher that handles the scheduling of the user threads.
The Solaris kernel may deschedule a thread at any point if
a higher priority thread becomes runnable; given real-time
constraints there really isn't a way of running user code
before releasing the CPU. In any case, interrupts cause an
immediate interruption w/o any chance for running special code.
If a thread is pre-empted, no user level code runs at all; the
kernel saves the thread's state and schedules the next one to
run.
You can, however, use the FX (fixed priority) scheduling class
to allow your threads to run at a fixed priority indefinitely.
You can then create a user level scheduler for your threads
that selects which one to run by juggling priorities.
Hmmmm... you _could_ use the thread context support to
cause side effects when switching threads; this runs in the
kernel but may be able to do what you want. Look at t_ctx
fields and the save and restore functions in struct ctxop.
You use installctx to add operations to your threads when
they're scheduled/descheduled. You'll need to add a driver
or system call to add this.... all of your context switch
code will need to run in the kernel, though...
- Bart
--
Bart Smaalders Solaris Kernel Performance
[EMAIL PROTECTED] http://blogs.sun.com/barts
_______________________________________________
opensolaris-code mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code