Make sure all system threads and mutexes have clear names

pull/4294/head
Bartek Szatkowski 2017-05-23 11:26:30 +01:00 committed by Martin Kojtal
parent 05548e786d
commit b01f13d1a0
15 changed files with 34 additions and 23 deletions

View File

@ -12,7 +12,7 @@ static uint8_t sys_irq_disable_counter;
static mbed_rtos_storage_mutex_t critical_mutex; static mbed_rtos_storage_mutex_t critical_mutex;
static const osMutexAttr_t critical_mutex_attr = { static const osMutexAttr_t critical_mutex_attr = {
.name = "critical_mutex", .name = "nanostack_critical_mutex",
.attr_bits = osMutexRecursive, .attr_bits = osMutexRecursive,
.cb_mem = &critical_mutex, .cb_mem = &critical_mutex,
.cb_size = sizeof critical_mutex, .cb_size = sizeof critical_mutex,

View File

@ -37,6 +37,7 @@ static void timer_thread(void *arg)
void platform_timer_enable(void) void platform_timer_enable(void)
{ {
static osThreadAttr_t timer_thread_attr = {0}; static osThreadAttr_t timer_thread_attr = {0};
timer_thread_attr.name = "pal_timer_thread";
timer_thread_attr.stack_mem = &timer_thread_stk[0]; timer_thread_attr.stack_mem = &timer_thread_stk[0];
timer_thread_attr.cb_mem = &timer_thread_tcb; timer_thread_attr.cb_mem = &timer_thread_tcb;
timer_thread_attr.stack_size = sizeof(timer_thread_stk); timer_thread_attr.stack_size = sizeof(timer_thread_stk);

View File

@ -19,6 +19,7 @@ static void event_loop_thread(void *arg);
static uint64_t event_thread_stk[MBED_CONF_NANOSTACK_HAL_EVENT_LOOP_THREAD_STACK_SIZE/8]; static uint64_t event_thread_stk[MBED_CONF_NANOSTACK_HAL_EVENT_LOOP_THREAD_STACK_SIZE/8];
static mbed_rtos_storage_thread_t event_thread_tcb; static mbed_rtos_storage_thread_t event_thread_tcb;
static const osThreadAttr_t event_thread_attr = { static const osThreadAttr_t event_thread_attr = {
.name = "nanostack_event_thread",
.priority = osPriorityNormal, .priority = osPriorityNormal,
.stack_mem = &event_thread_stk[0], .stack_mem = &event_thread_stk[0],
.stack_size = sizeof event_thread_stk, .stack_size = sizeof event_thread_stk,
@ -28,7 +29,7 @@ static const osThreadAttr_t event_thread_attr = {
static osThreadId_t event_thread_id; static osThreadId_t event_thread_id;
static mbed_rtos_storage_mutex_t event_mutex; static mbed_rtos_storage_mutex_t event_mutex;
static const osMutexAttr_t event_mutex_attr = { static const osMutexAttr_t event_mutex_attr = {
.name = "event_mutex", .name = "nanostack_event_mutex",
.attr_bits = osMutexRecursive, .attr_bits = osMutexRecursive,
.cb_mem = &event_mutex, .cb_mem = &event_mutex,
.cb_size = sizeof event_mutex, .cb_size = sizeof event_mutex,

View File

@ -712,18 +712,18 @@ err_t eth_arch_enetif_init(struct netif *netif)
LWIP_ASSERT("RxReadySem creation error", (err == ERR_OK)); LWIP_ASSERT("RxReadySem creation error", (err == ERR_OK));
#ifdef LWIP_DEBUG #ifdef LWIP_DEBUG
sys_thread_new("receive_thread", packet_rx, netif->state, DEFAULT_THREAD_STACKSIZE*5, RX_PRIORITY); sys_thread_new("k64f_emac_rx_thread", packet_rx, netif->state, DEFAULT_THREAD_STACKSIZE*5, RX_PRIORITY);
#else #else
sys_thread_new("receive_thread", packet_rx, netif->state, DEFAULT_THREAD_STACKSIZE, RX_PRIORITY); sys_thread_new("k64f_emac_thread", packet_rx, netif->state, DEFAULT_THREAD_STACKSIZE, RX_PRIORITY);
#endif #endif
/* Transmit cleanup task */ /* Transmit cleanup task */
err = sys_sem_new(&k64f_enetdata.TxCleanSem, 0); err = sys_sem_new(&k64f_enetdata.TxCleanSem, 0);
LWIP_ASSERT("TxCleanSem creation error", (err == ERR_OK)); LWIP_ASSERT("TxCleanSem creation error", (err == ERR_OK));
sys_thread_new("txclean_thread", packet_tx, netif->state, DEFAULT_THREAD_STACKSIZE, TX_PRIORITY); sys_thread_new("k64f_emac_txclean_thread", packet_tx, netif->state, DEFAULT_THREAD_STACKSIZE, TX_PRIORITY);
/* PHY monitoring task */ /* PHY monitoring task */
sys_thread_new("phy_thread", k64f_phy_task, netif, DEFAULT_THREAD_STACKSIZE, PHY_PRIORITY); sys_thread_new("k64f_emac_phy_thread", k64f_phy_task, netif, DEFAULT_THREAD_STACKSIZE, PHY_PRIORITY);
/* Allow the PHY task to detect the initial link state and set up the proper flags */ /* Allow the PHY task to detect the initial link state and set up the proper flags */
osDelay(10); osDelay(10);

View File

@ -435,17 +435,17 @@ err_t
#if defined (__GNUC__) #if defined (__GNUC__)
// mbed OS 2.0, DEFAULT_THREAD_STACKSIZE*3 // mbed OS 2.0, DEFAULT_THREAD_STACKSIZE*3
// mbed OS 5.0, DEFAULT_THREAD_STACKSIZE*5 // mbed OS 5.0, DEFAULT_THREAD_STACKSIZE*5
sys_thread_new("receive_thread", __packet_rx_task, &RxReadySem, DEFAULT_THREAD_STACKSIZE*5, osPriorityNormal); sys_thread_new("nuc472_emac_rx_thread", __packet_rx_task, &RxReadySem, DEFAULT_THREAD_STACKSIZE*5, osPriorityNormal);
#else #else
sys_thread_new("receive_thread", __packet_rx_task, &RxReadySem, DEFAULT_THREAD_STACKSIZE, osPriorityNormal); sys_thread_new("nuc472_emac_rx_thread", __packet_rx_task, &RxReadySem, DEFAULT_THREAD_STACKSIZE, osPriorityNormal);
#endif #endif
/* PHY monitoring task */ /* PHY monitoring task */
#if defined (__GNUC__) #if defined (__GNUC__)
// mbed OS 2.0, DEFAULT_THREAD_STACKSIZE // mbed OS 2.0, DEFAULT_THREAD_STACKSIZE
// mbed OS 5.0, DEFAULT_THREAD_STACKSIZE*2 // mbed OS 5.0, DEFAULT_THREAD_STACKSIZE*2
sys_thread_new("phy_thread", __phy_task, netif, DEFAULT_THREAD_STACKSIZE*2, osPriorityNormal); sys_thread_new("nuc472_emac_phy_thread", __phy_task, netif, DEFAULT_THREAD_STACKSIZE*2, osPriorityNormal);
#else #else
sys_thread_new("phy_thread", __phy_task, netif, DEFAULT_THREAD_STACKSIZE, osPriorityNormal); sys_thread_new("nuc472_emac_phy_thread", __phy_task, netif, DEFAULT_THREAD_STACKSIZE, osPriorityNormal);
#endif #endif
/* Allow the PHY task to detect the initial link state and set up the proper flags */ /* Allow the PHY task to detect the initial link state and set up the proper flags */
osDelay(10); osDelay(10);

View File

@ -1031,16 +1031,16 @@ err_t eth_arch_enetif_init(struct netif *netif)
LWIP_ASSERT("TXLockMutex creation error", (err == ERR_OK)); LWIP_ASSERT("TXLockMutex creation error", (err == ERR_OK));
/* Packet receive task */ /* Packet receive task */
lpc_enetdata.RxThread = sys_thread_new("receive_thread", packet_rx, netif->state, DEFAULT_THREAD_STACKSIZE, RX_PRIORITY); lpc_enetdata.RxThread = sys_thread_new("lpc17_emac_rx_thread", packet_rx, netif->state, DEFAULT_THREAD_STACKSIZE, RX_PRIORITY);
LWIP_ASSERT("RxThread creation error", (lpc_enetdata.RxThread)); LWIP_ASSERT("RxThread creation error", (lpc_enetdata.RxThread));
/* Transmit cleanup task */ /* Transmit cleanup task */
err = sys_sem_new(&lpc_enetdata.TxCleanSem, 0); err = sys_sem_new(&lpc_enetdata.TxCleanSem, 0);
LWIP_ASSERT("TxCleanSem creation error", (err == ERR_OK)); LWIP_ASSERT("TxCleanSem creation error", (err == ERR_OK));
sys_thread_new("txclean_thread", packet_tx, netif->state, DEFAULT_THREAD_STACKSIZE, TX_PRIORITY); sys_thread_new("lpc17_emac_txclean_thread", packet_tx, netif->state, DEFAULT_THREAD_STACKSIZE, TX_PRIORITY);
/* periodic PHY status update */ /* periodic PHY status update */
sys_thread_new("phy_thread", phy_update, netif, DEFAULT_THREAD_STACKSIZE, TX_PRIORITY); sys_thread_new("lpc17_emac_phy_thread", phy_update, netif, DEFAULT_THREAD_STACKSIZE, TX_PRIORITY);
#endif #endif
return ERR_OK; return ERR_OK;

View File

@ -195,8 +195,8 @@ err_t eth_arch_enetif_init(struct netif *netif)
sys_sem_new(&recv_ready_sem, 0); sys_sem_new(&recv_ready_sem, 0);
/* task */ /* task */
sys_thread_new("rza1_recv_task", rza1_recv_task, netif, DEFAULT_THREAD_STACKSIZE, RECV_TASK_PRI); sys_thread_new("rza1_emac_rx_thread", rza1_recv_task, netif, DEFAULT_THREAD_STACKSIZE, RECV_TASK_PRI);
sys_thread_new("rza1_phy_task", rza1_phy_task, netif, DEFAULT_THREAD_STACKSIZE, PHY_TASK_PRI); sys_thread_new("rza1_emac_phy_thread", rza1_phy_task, netif, DEFAULT_THREAD_STACKSIZE, PHY_TASK_PRI);
return ERR_OK; return ERR_OK;
} }

View File

@ -451,8 +451,8 @@ err_t eth_arch_enetif_init(struct netif *netif)
sys_mutex_new(&tx_lock_mutex); sys_mutex_new(&tx_lock_mutex);
/* task */ /* task */
sys_thread_new("_eth_arch_rx_task", _eth_arch_rx_task, netif, DEFAULT_THREAD_STACKSIZE, RECV_TASK_PRI); sys_thread_new("stm32_emac_rx_thread", _eth_arch_rx_task, netif, DEFAULT_THREAD_STACKSIZE, RECV_TASK_PRI);
sys_thread_new("_eth_arch_phy_task", _eth_arch_phy_task, netif, DEFAULT_THREAD_STACKSIZE, PHY_TASK_PRI); sys_thread_new("stm32_emac_phy_thread", _eth_arch_phy_task, netif, DEFAULT_THREAD_STACKSIZE, PHY_TASK_PRI);
/* initialize the hardware */ /* initialize the hardware */
_eth_arch_low_level_init(netif); _eth_arch_low_level_init(netif);

View File

@ -195,8 +195,8 @@ err_t eth_arch_enetif_init(struct netif *netif)
sys_sem_new(&recv_ready_sem, 0); sys_sem_new(&recv_ready_sem, 0);
/* task */ /* task */
sys_thread_new("rza1_recv_task", rza1_recv_task, netif, DEFAULT_THREAD_STACKSIZE, RECV_TASK_PRI); sys_thread_new("rza1_emac_rx_thread", rza1_recv_task, netif, DEFAULT_THREAD_STACKSIZE, RECV_TASK_PRI);
sys_thread_new("rza1_phy_task", rza1_phy_task, netif, DEFAULT_THREAD_STACKSIZE, PHY_TASK_PRI); sys_thread_new("rza1_emac_phy_thread", rza1_phy_task, netif, DEFAULT_THREAD_STACKSIZE, PHY_TASK_PRI);
return ERR_OK; return ERR_OK;
} }

View File

@ -378,6 +378,7 @@ void sys_sem_free(sys_sem_t *sem) {}
* @return a new mutex */ * @return a new mutex */
err_t sys_mutex_new(sys_mutex_t *mutex) { err_t sys_mutex_new(sys_mutex_t *mutex) {
memset(&mutex->data, 0, sizeof(mutex->data)); memset(&mutex->data, 0, sizeof(mutex->data));
mutex->attr.name = "lwip_mutex";
mutex->attr.cb_mem = &mutex->data; mutex->attr.cb_mem = &mutex->data;
mutex->attr.cb_size = sizeof(mutex->data); mutex->attr.cb_size = sizeof(mutex->data);
mutex->id = osMutexNew(&mutex->attr); mutex->id = osMutexNew(&mutex->attr);
@ -417,6 +418,7 @@ mbed_rtos_storage_mutex_t lwip_sys_mutex_data;
void sys_init(void) { void sys_init(void) {
us_ticker_read(); // Init sys tick us_ticker_read(); // Init sys tick
lwip_sys_mutex_attr.name = "lwip_sys_mutex";
lwip_sys_mutex_attr.cb_mem = &lwip_sys_mutex_data; lwip_sys_mutex_attr.cb_mem = &lwip_sys_mutex_data;
lwip_sys_mutex_attr.cb_size = sizeof(lwip_sys_mutex_data); lwip_sys_mutex_attr.cb_size = sizeof(lwip_sys_mutex_data);
lwip_sys_mutex = osMutexNew(&lwip_sys_mutex_attr); lwip_sys_mutex = osMutexNew(&lwip_sys_mutex_attr);
@ -517,7 +519,7 @@ sys_thread_t sys_thread_new(const char *pcName,
sys_thread_t t = (sys_thread_t)&thread_pool[thread_pool_index]; sys_thread_t t = (sys_thread_t)&thread_pool[thread_pool_index];
thread_pool_index++; thread_pool_index++;
t->attr.name = pcName; t->attr.name = pcName ? pcName : "lwip_unnamed_thread";
t->attr.priority = (osPriority_t)priority; t->attr.priority = (osPriority_t)priority;
t->attr.cb_size = sizeof(t->data); t->attr.cb_size = sizeof(t->data);
t->attr.cb_mem = &t->data; t->attr.cb_mem = &t->data;

View File

@ -111,6 +111,7 @@ void __uvisor_lib_box_init(void * lib_config)
__uvisor_initialize_rpc_queues(); __uvisor_initialize_rpc_queues();
thread_attr.name = "uvisor_box_main_thread";
thread_attr.priority = box_main->priority; thread_attr.priority = box_main->priority;
thread_attr.stack_size = box_main->stack_size; thread_attr.stack_size = box_main->stack_size;

View File

@ -65,6 +65,7 @@ static int init_allocator()
if ((__uvisor_ps->mutex_id == NULL) && is_kernel_initialized()) { if ((__uvisor_ps->mutex_id == NULL) && is_kernel_initialized()) {
/* Point the mutex attr to the data. */ /* Point the mutex attr to the data. */
__uvisor_ps->mutex_attr.name = "uvisor_malloc_mutex";
__uvisor_ps->mutex_attr.attr_bits = 0; /* Non-recursive */ __uvisor_ps->mutex_attr.attr_bits = 0; /* Non-recursive */
__uvisor_ps->mutex_attr.cb_mem = &__uvisor_ps->mutex_data; __uvisor_ps->mutex_attr.cb_mem = &__uvisor_ps->mutex_data;
__uvisor_ps->mutex_attr.cb_size = sizeof(__uvisor_ps->mutex_data); __uvisor_ps->mutex_attr.cb_size = sizeof(__uvisor_ps->mutex_data);

View File

@ -54,7 +54,7 @@ int uvisor_page_free(const UvisorPageTable *const table)
static osMutexId_t g_page_allocator_mutex_id = NULL; static osMutexId_t g_page_allocator_mutex_id = NULL;
static osRtxMutex_t g_page_allocator_mutex_data; static osRtxMutex_t g_page_allocator_mutex_data;
static osMutexDef_t g_page_allocator_mutex_attr = { static osMutexDef_t g_page_allocator_mutex_attr = {
.name = "", .name = "uvisor_page_alloc_mutex",
.attr_bits = 0, /* Non-recursive */ .attr_bits = 0, /* Non-recursive */
.cb_mem = &g_page_allocator_mutex_data, .cb_mem = &g_page_allocator_mutex_data,
.cb_size = sizeof(g_page_allocator_mutex_data) .cb_size = sizeof(g_page_allocator_mutex_data)

View File

@ -43,7 +43,7 @@ void Thread::constructor(osPriority priority,
memset(&_attr, 0, sizeof(_attr)); memset(&_attr, 0, sizeof(_attr));
_attr.priority = priority; _attr.priority = priority;
_attr.stack_size = stack_size; _attr.stack_size = stack_size;
_attr.name = name; _attr.name = name ? name : "application_unnamed_thread";
_attr.stack_mem = (uint32_t*)stack_mem; _attr.stack_mem = (uint32_t*)stack_mem;
} }

View File

@ -315,7 +315,7 @@ void mbed_start_main(void)
_main_thread_attr.cb_size = sizeof(_main_obj); _main_thread_attr.cb_size = sizeof(_main_obj);
_main_thread_attr.cb_mem = &_main_obj; _main_thread_attr.cb_mem = &_main_obj;
_main_thread_attr.priority = osPriorityNormal; _main_thread_attr.priority = osPriorityNormal;
_main_thread_attr.name = "MAIN"; _main_thread_attr.name = "main_thread";
osThreadId_t result = osThreadNew((osThreadFunc_t)pre_main, NULL, &_main_thread_attr); osThreadId_t result = osThreadNew((osThreadFunc_t)pre_main, NULL, &_main_thread_attr);
if ((void *)result == NULL) { if ((void *)result == NULL) {
error("Pre main thread not created"); error("Pre main thread not created");
@ -381,6 +381,7 @@ extern int main(int argc, char* argv[]);
void pre_main (void) void pre_main (void)
{ {
singleton_mutex_attr.name = "singleton_mutex";
singleton_mutex_attr.attr_bits = osMutexRecursive; singleton_mutex_attr.attr_bits = osMutexRecursive;
singleton_mutex_attr.cb_size = sizeof(singleton_mutex_obj); singleton_mutex_attr.cb_size = sizeof(singleton_mutex_obj);
singleton_mutex_attr.cb_mem = &singleton_mutex_obj; singleton_mutex_attr.cb_mem = &singleton_mutex_obj;
@ -437,16 +438,19 @@ int __wrap_main(void) {
void pre_main(void) void pre_main(void)
{ {
singleton_mutex_attr.name = "singleton_mutex";
singleton_mutex_attr.attr_bits = osMutexRecursive; singleton_mutex_attr.attr_bits = osMutexRecursive;
singleton_mutex_attr.cb_size = sizeof(singleton_mutex_obj); singleton_mutex_attr.cb_size = sizeof(singleton_mutex_obj);
singleton_mutex_attr.cb_mem = &singleton_mutex_obj; singleton_mutex_attr.cb_mem = &singleton_mutex_obj;
singleton_mutex_id = osMutexNew(&singleton_mutex_attr); singleton_mutex_id = osMutexNew(&singleton_mutex_attr);
malloc_mutex_attr.name = "malloc_mutex";
malloc_mutex_attr.attr_bits = osMutexRecursive; malloc_mutex_attr.attr_bits = osMutexRecursive;
malloc_mutex_attr.cb_size = sizeof(malloc_mutex_obj); malloc_mutex_attr.cb_size = sizeof(malloc_mutex_obj);
malloc_mutex_attr.cb_mem = &malloc_mutex_obj; malloc_mutex_attr.cb_mem = &malloc_mutex_obj;
malloc_mutex_id = osMutexNew(&malloc_mutex_attr); malloc_mutex_id = osMutexNew(&malloc_mutex_attr);
env_mutex_attr.name = "env_mutex";
env_mutex_attr.attr_bits = osMutexRecursive; env_mutex_attr.attr_bits = osMutexRecursive;
env_mutex_attr.cb_size = sizeof(env_mutex_obj); env_mutex_attr.cb_size = sizeof(env_mutex_obj);
env_mutex_attr.cb_mem = &env_mutex_obj; env_mutex_attr.cb_mem = &env_mutex_obj;
@ -520,6 +524,7 @@ static uint8_t low_level_init_needed;
void pre_main(void) void pre_main(void)
{ {
singleton_mutex_attr.name = "singleton_mutex";
singleton_mutex_attr.attr_bits = osMutexRecursive; singleton_mutex_attr.attr_bits = osMutexRecursive;
singleton_mutex_attr.cb_size = sizeof(singleton_mutex_obj); singleton_mutex_attr.cb_size = sizeof(singleton_mutex_obj);
singleton_mutex_attr.cb_mem = &singleton_mutex_obj; singleton_mutex_attr.cb_mem = &singleton_mutex_obj;