Mercurial > ecos
changeset 1436:1b465c781382
New API for cyg_thread_get_id() - from Dan Jakubiec
| author | gthomas |
|---|---|
| date | Tue, 09 Dec 2003 15:10:39 +0000 |
| parents | 6e485f9ff763 |
| children | 40912f487083 |
| files | packages/kernel/current/ChangeLog packages/kernel/current/doc/kernel.sgml packages/kernel/current/include/kapi.h packages/kernel/current/src/common/kapi.cxx |
| diffstat | 4 files changed, 29 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/packages/kernel/current/ChangeLog +++ b/packages/kernel/current/ChangeLog @@ -1,3 +1,13 @@ +2003-12-08 Dan Jakubiec <djakubiec@yahoo.com> + + * src/common/kapi.cxx: Added new function cyg_thread_get_id(). + This function returns the unique thread ID for a given thread + handle. + + * include/kapi.h: Added function prototype for cyg_thread_get_id(). + + * doc/kernel.sgml: Added documentation for cyg_thread_get_id(). + 2003-10-13 Nick Garnett <nickg@balti.calivar.com> * src/common/clock.cxx (Cyg_Counter::tick): Changed code to deal
--- a/packages/kernel/current/doc/kernel.sgml +++ b/packages/kernel/current/doc/kernel.sgml @@ -1278,6 +1278,7 @@ be achieved when programming in C++ is l <refname>cyg_thread_measure_stack_usage</refname> <refname>cyg_thread_get_next</refname> <refname>cyg_thread_get_info</refname> + <refname>cyg_thread_get_id</refname> <refname>cyg_thread_find</refname> <refpurpose>Get basic thread information</refpurpose> </refnamediv> @@ -1319,6 +1320,10 @@ be achieved when programming in C++ is l <paramdef>cyg_thread_info *<parameter>info</parameter></paramdef> </funcprototype> <funcprototype> + <funcdef>cyg_uint16 <function>cyg_thread_get_id</function></funcdef> + <paramdef>cyg_handle_t <parameter>thread</parameter></paramdef> + </funcprototype> + <funcprototype> <funcdef>cyg_handle_t <function>cyg_thread_find</function></funcdef> <paramdef>cyg_uint16 <parameter>id</parameter></paramdef> </funcprototype> @@ -1403,6 +1408,10 @@ typedef struct </programlisting> </para> <para> +<function>cyg_thread_get_id</function> returns the unique thread ID for +the thread identified by <parameter>thread</parameter>. + </para> + <para> <function>cyg_thread_find</function> returns a handle for the thread whose ID is <parameter>id</parameter>. If no such thread exists, a zero handle is returned. @@ -1420,6 +1429,9 @@ initialized. <function>cyg_thread_get_st any time after the specified thread has been created, but measuring stack usage involves looping over at least part of the thread's stack so this should normally only be done from thread context. +<function>cyg_thread_get_id</function> may be called from any context +as long as the caller can guarantee that the supplied thread handle +remains valid. </para> </refsect1>
--- a/packages/kernel/current/include/kapi.h +++ b/packages/kernel/current/include/kapi.h @@ -229,6 +229,8 @@ cyg_bool_t cyg_thread_get_info( cyg_hand cyg_uint16 id, cyg_thread_info *info ); +cyg_uint16 cyg_thread_get_id( cyg_handle_t thread ); + cyg_handle_t cyg_thread_find( cyg_uint16 id ); /*---------------------------------------------------------------------------*/
--- a/packages/kernel/current/src/common/kapi.cxx +++ b/packages/kernel/current/src/common/kapi.cxx @@ -236,6 +236,11 @@ externC cyg_handle_t cyg_thread_self() return (cyg_handle_t)Cyg_Thread::self(); } +externC cyg_uint16 cyg_thread_get_id( cyg_handle_t thread) +{ + return ((Cyg_Thread *)thread)->get_unique_id(); +} + // idle thread is not really a plain CygThread; danger. externC cyg_handle_t cyg_thread_idle_thread() {
