Use pthread_setname_np to name threads

osmo-trx can start a considerable amount of threads that can make
debugging it challenging at least. By using phtread_setname_np, the
system sets a meaningful name to the thread which can be seen while
debugging with gdb or by printing /proc/$pid/task/$tid/comm.

Now we also log system TID when setting the name so we can identify
different tasks in /proc even if pthread_setname_np fails.

Change-Id: I84711739c3e224cb383fd12b6db933785b28209e
diff --git a/Transceiver52M/Transceiver.cpp b/Transceiver52M/Transceiver.cpp
index cdfd79d..076db3e 100644
--- a/Transceiver52M/Transceiver.cpp
+++ b/Transceiver52M/Transceiver.cpp
@@ -1044,11 +1044,15 @@
 
 void *RxUpperLoopAdapter(TransceiverChannel *chan)
 {
+  char thread_name[16];
   Transceiver *trx = chan->trx;
   size_t num = chan->num;
 
   delete chan;
 
+  snprintf(thread_name, 16, "RxUpper%zu", num);
+  set_selfthread_name(thread_name);
+
   trx->setPriority(0.42);
 
   while (1) {
@@ -1060,6 +1064,8 @@
 
 void *RxLowerLoopAdapter(Transceiver *transceiver)
 {
+  set_selfthread_name("RxLower");
+
   transceiver->setPriority(0.45);
 
   while (1) {
@@ -1071,6 +1077,8 @@
 
 void *TxLowerLoopAdapter(Transceiver *transceiver)
 {
+  set_selfthread_name("TxLower");
+
   transceiver->setPriority(0.44);
 
   while (1) {
@@ -1082,11 +1090,15 @@
 
 void *ControlServiceLoopAdapter(TransceiverChannel *chan)
 {
+  char thread_name[16];
   Transceiver *trx = chan->trx;
   size_t num = chan->num;
 
   delete chan;
 
+  snprintf(thread_name, 16, "CtrlService%zu", num);
+  set_selfthread_name(thread_name);
+
   while (1) {
     trx->driveControl(num);
     pthread_testcancel();
@@ -1096,11 +1108,15 @@
 
 void *TxUpperLoopAdapter(TransceiverChannel *chan)
 {
+  char thread_name[16];
   Transceiver *trx = chan->trx;
   size_t num = chan->num;
 
   delete chan;
 
+  snprintf(thread_name, 16, "TxUpper%zu", num);
+  set_selfthread_name(thread_name);
+
   trx->setPriority(0.40);
 
   while (1) {