Re: RBTree implementation and thread structure

Ingo Weinhold <[email protected]> Sun, 13 Apr 2008 03:13:28 +0200
Newsgroups gmane.os.openbeos.kernel.devel
Message-ID <[email protected]>
On 2008-04-12 at 23:43:24 [+0200], Salvatore Benedetto <[email protected]> 
wrote:
> 
> I have two quick questions.
> 
> First: do we have a red and black tree class implementation that I
> could use in the scheduler? Just wondering, not actually doing any
> coding yet.
> 
> I see we have a AVLTreeMap class implemented by Ingo, but looks like
> it's not used anywhere.

It is actually used in my ramfs. That's where it originally comes from. The 
instantiated code is quite big, though, so one might consider trimming the 
class (i.e. make it less flexible, use a non-templatized base class, etc.).

> Second: I'm trying to understand the thread structure and I can't find
> anything in the BeBook. What are these next_* fields for?
>     int32           priority;
>     int32           next_priority;
>     int32           state;
>     int32           next_state;

They contain the next values for the respective non "next_" fields, which will 
be set when a running thread is unscheduled. I believe that's really only 
needed for SMP support. Otherwise one could just set the thread state/priority 
directly, since unless it was the current thread, the target thread would never 
be running.

CU, Ingo

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone