This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Per thread data.


On Thu, Aug 08, 2002 at 07:43:33AM -0700, NavEcos wrote:
> I have a question I was hoping somebody could answer.
> 
> I'm going through the code and was looking at the implementation of
> the per thread data.
> 
> In ecos/packages/kernel/current/include/thread.hxx on line ~430, I
> see the following code:
> 
> private:
>     // Array of single word entries for each index. 
>     CYG_ADDRWORD        thread_data[CYGNUM_KERNEL_THREADS_DATA_MAX];
> 
>     // Map of free thread_data indexes. Each bit represents an index
>     // and is 1 if that index is free, and 0 if it is in use.
>     static cyg_ucount32        thread_data_map;
> 
> Why is "thread_data_map" defined as static?
> 
> Going through the code, it seems that this will limit the TOTAL number
> of per-thread data indexes to just CYGNUM_KERNEL_THREADS_DATA_MAX
> instead of limiting each thread to a total number of indexes of
> CYGNUM_KERNEL_THREADS_DATA_MAX.
> 
> Why is "thead_data_map" static?

The idea here is you get an index allocated once, and you know its
valid for every thread. You can then put this index into some global
variable. So when you need to get at the data, you just do
cyg_thread_get_data(index). 

What you suggests would mean that each thread would have a different
index. You could not keep it in a global variable, since its thread
specific. Instead you have to do some sort of search on this threads
data entries to find the one you want. That takes time, memory, etc.

     Andrew

-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]