#2858 closed enhancement (fixed)

Add user defined thread names

Reported by: Sebastian Huber Owned by: Sebastian Huber
Priority: normal Milestone: 5.1
Component: score Version: 5
Severity: normal Keywords:
Cc: Blocked By:
Blocking:

Description

Add user defined thread names to ease debugging, enhance the system diagnostics and improve compatibility to other systems, e.g. Linux and FreeBSD.

Implement pthread_setname_np() and pthread_getname_np(). Add CONFIGURE_MAXIMUM_THREAD_NAME_SIZE to the application configuration options. Add a application configuration dependent storage area for thread names to the thread control block.

Change History (16)

comment:1 Changed on 01/12/17 at 13:41:01 by Joel Sherrill

This shouldn't be hard to add since rtems_object_[gs]et_name() were added to do the same thing. These have been in since before 4.10. See psx14 for an example usage of rtems_object_set_name() on a pthread.

comment:2 Changed on 01/12/17 at 14:50:47 by Sebastian Huber

The problem with the object set/get name is that the interpretation of the Objects_Name depends on Objects_Information::is_string which is false for Classic and true for POSIX.

comment:3 Changed on 01/12/17 at 14:53:20 by Sebastian Huber

With the new thread name support I get now

[/] # cpuuse
-------------------------------------------------------------------------------
                              CPU USAGE BY THREAD
------------+----------------------------------------+---------------+---------
 ID         | NAME                                   | SECONDS       | PERCENT
------------+----------------------------------------+---------------+---------
 0x09010001 | IDLE                                   |      2.389090 |  71.877
 0x0a010001 | UI1                                    |      0.214980 |   6.464
 0x0a010002 | BSWP                                   |      0.005139 |   0.154
 0x0a010003 | BRDA                                   |      0.001066 |   0.032
 0x0a010004 | MDIA                                   |      0.000583 |   0.017
 0x0a010005 | TIME                                   |      0.180753 |   5.430
 0x0a010006 | IRQS                                   |      0.004529 |   0.136
 0x0a010007 | swi1: netisr 0                         |      0.002570 |   0.077
 0x0a010008 | kqueue_ctx task                        |      0.000676 |   0.020
 0x0a010009 | swi5: fast task                        |      0.000059 |   0.001
 0x0a01000a | thread taskq                           |      0.000058 |   0.001
 0x0a01000b | swi6: task queu                        |      0.003285 |   0.098
 0x0a01000c | DHCP                                   |      0.274554 |   8.237
 0x0a01000d | FTPa                                   |      0.002210 |   0.066
 0x0a01000e | FTPb                                   |      0.000352 |   0.010
 0x0a01000f | FTPc                                   |      0.000240 |   0.007
 0x0a010010 | FTPd                                   |      0.000347 |   0.010
 0x0a010011 | FTPD                                   |      0.002903 |   0.087
 0x0a010012 | TNTD                                   |      0.001117 |   0.033
 0x0a010013 | SHLL                                   |      0.253692 |   7.599
------------+----------------------------------------+---------------+---------
 TIME SINCE LAST CPU USAGE RESET IN SECONDS:                          3.338494
-------------------------------------------------------------------------------

Before all the libbsd threads had the name "_BSD".

comment:4 Changed on 01/12/17 at 16:18:27 by Joel Sherrill

I am missing something in the code about how a Classic API task can have a string name.

What about names for threads created using the new lightweight API? And do they show up in these lists.

comment:5 Changed on 01/12/17 at 16:33:21 by Sebastian Huber

See patch:

https://lists.rtems.org/pipermail/devel/2017-January/016680.html

The optional string name is accessible via Thread_Control::Join_queue::Queue::name.

comment:6 Changed on 01/13/17 at 07:34:32 by Sebastian Huber <sebastian.huber@…>

In b8bcebea186e2d02334a014d5e792a0dde8007fc/rtems:

score: Add and use _Objects_Name_to_string()

Update #2858.

comment:7 Changed on 01/13/17 at 07:34:42 by Sebastian Huber <sebastian.huber@…>

In 2b72162b81b33a9f5983feccadd8426a1ab6f950/rtems:

score: Add Thread_queue_Queue::name

Update #2858.

comment:8 Changed on 01/13/17 at 07:34:52 by Sebastian Huber <sebastian.huber@…>

In 7ced9d9bb2fd51cfef2ce33d22e779adfed604c2/rtems:

score: Add and use _Thread_Get_name()

Update #2858.

comment:9 Changed on 01/13/17 at 07:35:01 by Sebastian Huber <sebastian.huber@…>

In da6ad56a68676d68782ddcbd443a57337c84ee06/rtems:

score: Add _Thread_Set_name()

Add configuration option CONFIGURE_MAXIMUM_THREAD_NAME_SIZE.

Update #2858.

comment:10 Changed on 01/13/17 at 07:35:11 by Sebastian Huber <sebastian.huber@…>

In 7c49927911badda7907703568cadbcb2f1b7ef9d/rtems:

posix: Add pthread_getname_np(), ...

Add pthread_getname_np() and pthread_setname_np().

Update #2858.

comment:11 Changed on 01/13/17 at 08:21:31 by Sebastian Huber <sebastian.huber@…>

In 172f2acb2b0ad183cb2360843e67aa86ca26a210/rtems-libbsd:

Use thread name support

Update #2858.

comment:12 Changed on 01/31/17 at 09:11:16 by Sebastian Huber <sebastian.huber@…>

In e366f774a76d3607ad41dc0992e787ce38df980d/rtems:

score: Add _Thread_queue_Object_name

Add the special thread queue name _Thread_queue_Object_name to mark
thread queues embedded in an object with identifier. Using the special
thread state STATES_THREAD_QUEUE_WITH_IDENTIFIER is not reliable for
this purpose since the thread wait information and thread state are
protected by different SMP locks in separate critical sections. Remove
STATES_THREAD_QUEUE_WITH_IDENTIFIER.

Add and use _Thread_queue_Object_initialize().

Update #2858.

comment:13 Changed on 01/31/17 at 09:11:57 by Sebastian Huber

Resolution: fixed
Status: newclosed

comment:14 Changed on 02/14/17 at 10:13:42 by Sebastian Huber <sebastian.huber@…>

In 468e9a4d99418a95657ab411d6557916d9f68bae/rtems:

monitor: Print short and long task names

Print wait object identifier only if it exists.

Update #2858.

comment:15 Changed on 05/11/17 at 07:31:02 by Sebastian Huber

Milestone: 4.124.12.0

comment:16 Changed on 11/09/17 at 06:27:14 by Sebastian Huber

Milestone: 4.12.05.1

Milestone renamed

Note: See TracTickets for help on using tickets.