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]

ID for cyg_thread_get_info


How do I get an ID to use in cyg_thread_get_info()?
I want a write routine to get the thread name.

Do I really have to go into a cyg_thread_get_next() loop
enumerating all of the threads until I match the handle
obtained with cyg_thread_self()?  That seems to be the
only way of getting the kernel to cough up a thread id.

Do I really have to do all of this work in my id_for_thread()?

    cyg_uint16
    id_for_thread(cyg_handle_t needle)
    {
	cyg_uint16 id = 0;
	cyg_handle_t *haystack = 0;
        while( cyg_thread_get_next(&haystack, &id) )
	    if(haystack == needle)
		return id;
	return 0;
    }

    char *
    thread_name(char *buf)
    {
        cyg_thread_info info;
	cyg_handle_t myself = cyg_thread_self();
        cyg_uint16 id = id_for_thread(myself);
        cyg_thread_get_info(myself, id, &info);
        return strcpy(buf, info->name);
    }

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?

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