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: ID for cyg_thread_get_info


On Thu, Jul 03, 2003 at 02:03:58PM +0100, Nick Garnett wrote:
> Billy <billy@DaDaDaDa.net> writes:
> > Why does cyg_thread_get_info() need the id parameter at all?
> > Is there a reason that it can't just use the id associated with
> > the handle which was already given as argument 1?

> That API was really invented to support code that needed to enumerate
> all the threads in the system. Needing to supply both the handle and
> the id allows us to detect cases where the thread has been deleted and
> the memory reused between calls to cyg_thread_get_next().

I see your point.
This sequence would print nothing.

Thread A:                                 Thread B:
.                                         .
cyg_handle_t h=0;                         .
while(cyg_thread_get_next(&h, &id))       .
{                                         .
  // h,id now refer to Thread B           .
  .                                       cyg_thread_exit();
  .
  if(!cyg_thread_get_info(h, id, &info))
      break;
  printf("name: %10s\n", info.name);
}

Of course, the "self" thread hasn't terminated yet (by definition).

> I suspect that a cyg_thread_get_id() function might be useful. I'll
> look at adding it.

Thanks.  I think it would be handy for debug macros.

Also, thanks for giving this mailing list so much of your attention.

-- 
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]