Skip to content

Commit

Permalink
add thread name to most pthreads
Browse files Browse the repository at this point in the history
  • Loading branch information
kirkscheper committed Apr 26, 2018
1 parent 4792400 commit 3c9c903
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 8 deletions.
7 changes: 4 additions & 3 deletions sw/airborne/arch/linux/mcu_periph/sys_time_arch.c
Expand Up @@ -39,7 +39,6 @@
#define SYS_TIME_THREAD_PRIO 29
#endif

pthread_t sys_time_thread;
static struct timespec startup_time;

static void sys_tick_handler(void);
Expand Down Expand Up @@ -78,7 +77,7 @@ void *sys_time_thread_main(void *data)
unsigned long long missed;
/* Wait for the next timer event. If we have missed any the
number is written to "missed" */
int r = read(fd, &missed, sizeof(missed));
int r = read(fd, &missed, sizeof(missed));
if (r == -1) {
perror("Couldn't read timer!");
}
Expand All @@ -98,11 +97,13 @@ void sys_time_arch_init(void)

clock_gettime(CLOCK_MONOTONIC, &startup_time);

int ret = pthread_create(&sys_time_thread, NULL, sys_time_thread_main, NULL);
pthread_t tid;
int ret = pthread_create(&tid, NULL, sys_time_thread_main, NULL);
if (ret) {
perror("Could not setup sys_time_thread");
return;
}
pthread_setname_np(tid, "pprz_sys_time_thread");
}

static void sys_tick_handler(void)
Expand Down
1 change: 1 addition & 0 deletions sw/airborne/arch/linux/mcu_periph/uart_arch.c
Expand Up @@ -60,6 +60,7 @@ void uart_arch_init(void)
fprintf(stderr, "uart_arch_init: Could not create UART reading thread.\n");
return;
}
pthread_setname_np(tid, "pprz_uart_thread");
}

static void *uart_thread(void *data __attribute__((unused)))
Expand Down
1 change: 1 addition & 0 deletions sw/airborne/arch/linux/mcu_periph/udp_arch.c
Expand Up @@ -60,6 +60,7 @@ void udp_arch_init(void)
fprintf(stderr, "udp_arch_init: Could not create UDP reading thread.\n");
return;
}
pthread_setname_np(tid, "pprz_udp_thread");
}

/**
Expand Down
1 change: 1 addition & 0 deletions sw/airborne/boards/ardrone/navdata.c
Expand Up @@ -236,6 +236,7 @@ bool navdata_init()
printf("[navdata] Could not create navdata reading thread!\n");
return false;
}
pthread_setname_np(navdata_thread, "pprz_navdata_thread");

#if PERIODIC_TELEMETRY
register_periodic_telemetry(DefaultPeriodic, PPRZ_MSG_ID_ARDRONE_NAVDATA, send_navdata);
Expand Down
1 change: 1 addition & 0 deletions sw/airborne/boards/swing/baro_board.c
Expand Up @@ -81,6 +81,7 @@ void baro_init(void)
if (pthread_create(&baro_thread, NULL, baro_read, NULL) != 0) {
printf("[swing_board] Could not create baro reading thread!\n");
}
pthread_setname_np(baro_thread, "pprz_baro_thread");

}

Expand Down
2 changes: 2 additions & 0 deletions sw/airborne/boards/swing/board.c
Expand Up @@ -116,12 +116,14 @@ void board_init(void)
if (pthread_create(&bat_thread, NULL, bat_read, NULL) != 0) {
printf("[swing_board] Could not create battery reading thread!\n");
}
pthread_setname_np(bat_thread, "pprz_bat_thread");

/* Start button reading thread */
pthread_t button_thread;
if (pthread_create(&button_thread, NULL, button_read, NULL) != 0) {
printf("[swing_board] Could not create button reading thread!\n");
}
pthread_setname_np(button_thread, "pprz_button_thread");

}

Expand Down
2 changes: 1 addition & 1 deletion sw/airborne/modules/computer_vision/cv.c
Expand Up @@ -97,7 +97,7 @@ struct video_listener *cv_add_to_device_async(struct video_config_t *device, cv_

// Create new processing thread
pthread_create(&listener->async->thread_id, NULL, cv_async_thread, listener);

pthread_setname_np(listener->async->thread_id, "pprz_camera_thread");
return listener;
}

Expand Down
1 change: 1 addition & 0 deletions sw/airborne/modules/computer_vision/video_thread.c
Expand Up @@ -235,6 +235,7 @@ static void start_video_thread(struct video_config_t *camera)
printf("[viewvideo] Could not create streaming thread for camera %s: Reason: %d.\n", camera->dev_name, errno);
return;
}
pthread_setname_np(tid, "pprz_camera_thread");
}
}

Expand Down
7 changes: 3 additions & 4 deletions sw/airborne/modules/sonar/sonar_bebop.c
Expand Up @@ -90,9 +90,6 @@ struct SonarBebop sonar_bebop;

static struct spi_transaction sonar_bebop_spi_t;
void *sonar_bebop_read(void *data);
#ifdef USE_SONAR
static pthread_t sonar_bebop_thread;
#endif

void sonar_bebop_init(void)
{
Expand All @@ -111,7 +108,9 @@ void sonar_bebop_init(void)
sonar_bebop_spi_t.input_length = 0;

#if USE_SONAR
pthread_create(&sonar_bebop_thread, NULL, sonar_bebop_read, NULL);
pthread_t tid;
pthread_create(&tid, NULL, sonar_bebop_read, NULL);
pthread_setname_np(tid, "pprz_sonar_thread");
#endif

init_median_filter_f(&sonar_filt, 3);
Expand Down

0 comments on commit 3c9c903

Please sign in to comment.