* RE: [ECOS] Re: listing all threads
@ 2005-11-23 20:29 Zimman, Chris
0 siblings, 0 replies; 4+ messages in thread
From: Zimman, Chris @ 2005-11-23 20:29 UTC (permalink / raw)
To: Good Guy; +Cc: eCos Discussion
We wrote this little function you may find useful:
#include <cyg/infra/cyg_type.h>
#include <cyg/hal/var_ints.h>
#include <cyg/kernel/kapi.h>
static const unsigned char * const thread_state_str[] = {
"RUN", /* 0 - Running */
"SLEEP", /* 1 - Sleeping */
"CNTSLP", /* 2 - Counted sleep */
"SLPSET", /* 3 - Sleep set */
"SUSP", /* 4 - Suspended */
NULL, /* 5 - INVALID */
NULL, /* 6 - INVALID */
NULL, /* 7 - INVALID */
"CREAT", /* 8 - Creating */
NULL, /* 9 - INVALID */
NULL, /* 10 - INVALID */
NULL, /* 11 - INVALID */
NULL, /* 12 - INVALID */
NULL, /* 13 - INVALID */
NULL, /* 14 - INVALID */
NULL, /* 15 - INVALID */
"EXIT" /* 16 - Exiting */
};
/*
* This function produces a list of the threads
* that are currently scheduled. The output is roughly
* analagous to 'ps', with the exception of VSS for obvious
* reasons
*/
void get_thread_info()
{
cyg_handle_t thandle = 0, *thandleptr = &thandle;
cyg_uint16 tid;
cyg_thread_info tinfo;
/*
* Because we're running this on ourselves,
* it's basically guaranteed to be OK the first
* time through
*/
cyg_thread_get_next(thandleptr, &tid);
printf("%-8s %-2s %-6s %-15s %-2s %-2s %-10s %-10s %-10s\n",
"-------",
"--",
"------",
"----------------------",
"--",
"--",
"----------",
"----------",
"----------");
printf("%-8s %-2s %-6s %-22s %-2s %-2s %-10s %-10s %-10s\n",
"Handle",
"ID",
"State",
"Name",
"SP",
"CP",
"Stack Base",
"Stack Size",
"Stack Used");
printf("%-8s %-2s %-6s %-22s %-2s %-2s %-10s %-10s %-10s\n",
"-------",
"--",
"------",
"----------------------",
"--",
"--",
"----------",
"----------",
"----------");
do {
cyg_thread_get_info(*thandleptr, tid, &tinfo);
printf("%-8d %-2d %-6s %-22s %-2d %-2d 0x%08x 0x%08x 0x%08x\n",
tinfo.handle,
tinfo.id,
thread_state_str[tinfo.state],
tinfo.name,
tinfo.set_pri,
tinfo.cur_pri,
tinfo.stack_base,
tinfo.stack_size,
tinfo.stack_used);
} while(cyg_thread_get_next(thandleptr, &tid));
#if defined(THREADINFO_DEBUG)
printf("Here I am:\n");
printf("Handle-> %d\n", tinfo.handle);
printf("ID-> %d\n", tinfo.id);
printf("State-> 0x%08x\n", tinfo.state);
printf("Name-> '%s'\n", tinfo.name);
printf("Set Priority-> 0x%08x\n", tinfo.set_pri);
printf("Current Priority-> 0x%08x\n", tinfo.cur_pri);
printf("Stack base-> 0x%08x\n", tinfo.stack_base);
printf("Stack size-> 0x%08x\n", tinfo.stack_size);
printf("Stack used-> 0x%08x\n", tinfo.stack_used);
#endif /* defined(THREADINFO_DEBUG) */
}
--Chris
-----Original Message-----
From: ecos-discuss-owner@ecos.sourceware.org
[mailto:ecos-discuss-owner@ecos.sourceware.org] On Behalf Of Nick
Garnett
Sent: Wednesday, November 23, 2005 5:13 AM
To: Good Guy
Cc: eCos Discussion
Subject: Re: [ECOS] Re: listing all threads
Gary Thomas <gary@mlbassoc.com> writes:
> On Tue, 2005-11-22 at 15:12 -0800, Good Guy wrote:
> > I was looking for a utility function which will list all the threads
> > (and state associated with each thread) in a running system. Does
such
> > a function or some sample code to help write this function exist?
I'm
> > using ecos 1.3.1.
> ^^^^^^^^^^
> Now some 5+ years old, so you may have challenges ahead. Why not
> update?
>
> Any way, the basic code to do this is in the GDB stubs. Look at
> .../hal/common/<VERSION>/src
There's an API to do this from user code. Take a look at
cyg_thread_get_info() and friends. It is described in the
documentation. However, it is not present in 1.3.1.
--
Nick Garnett eCos Kernel Architect
http://www.ecoscentric.com The eCos and RedBoot experts
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [ECOS] Re: listing all threads
2005-11-23 3:05 ` Gary Thomas
@ 2005-11-23 10:13 ` Nick Garnett
0 siblings, 0 replies; 4+ messages in thread
From: Nick Garnett @ 2005-11-23 10:13 UTC (permalink / raw)
To: Good Guy; +Cc: eCos Discussion
Gary Thomas <gary@mlbassoc.com> writes:
> On Tue, 2005-11-22 at 15:12 -0800, Good Guy wrote:
> > I was looking for a utility function which will list all the threads
> > (and state associated with each thread) in a running system. Does such
> > a function or some sample code to help write this function exist? I'm
> > using ecos 1.3.1.
> ^^^^^^^^^^
> Now some 5+ years old, so you may have challenges ahead. Why not
> update?
>
> Any way, the basic code to do this is in the GDB stubs. Look at
> .../hal/common/<VERSION>/src
There's an API to do this from user code. Take a look at
cyg_thread_get_info() and friends. It is described in the
documentation. However, it is not present in 1.3.1.
--
Nick Garnett eCos Kernel Architect
http://www.ecoscentric.com The eCos and RedBoot experts
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [ECOS] Re: listing all threads
2005-11-22 23:12 ` Good Guy
@ 2005-11-23 3:05 ` Gary Thomas
2005-11-23 10:13 ` Nick Garnett
0 siblings, 1 reply; 4+ messages in thread
From: Gary Thomas @ 2005-11-23 3:05 UTC (permalink / raw)
To: Good Guy; +Cc: eCos Discussion
On Tue, 2005-11-22 at 15:12 -0800, Good Guy wrote:
> I was looking for a utility function which will list all the threads
> (and state associated with each thread) in a running system. Does such
> a function or some sample code to help write this function exist? I'm
> using ecos 1.3.1.
^^^^^^^^^^
Now some 5+ years old, so you may have challenges ahead. Why not
update?
Any way, the basic code to do this is in the GDB stubs. Look at
.../hal/common/<VERSION>/src
--
------------------------------------------------------------
Gary Thomas | Consulting for the
MLB Associates | Embedded world
------------------------------------------------------------
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 4+ messages in thread
* [ECOS] Re: listing all threads
[not found] <a395a2600511221452l4171a814v8de90241417db6f4@mail.gmail.com>
@ 2005-11-22 23:12 ` Good Guy
2005-11-23 3:05 ` Gary Thomas
0 siblings, 1 reply; 4+ messages in thread
From: Good Guy @ 2005-11-22 23:12 UTC (permalink / raw)
To: ecos-discuss
I was looking for a utility function which will list all the threads
(and state associated with each thread) in a running system. Does such
a function or some sample code to help write this function exist? I'm
using ecos 1.3.1.
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2005-11-23 20:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-23 20:29 [ECOS] Re: listing all threads Zimman, Chris
[not found] <a395a2600511221452l4171a814v8de90241417db6f4@mail.gmail.com>
2005-11-22 23:12 ` Good Guy
2005-11-23 3:05 ` Gary Thomas
2005-11-23 10:13 ` Nick Garnett
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).