Merge remote-tracking branch 'origin/develop' into threading-rk
This commit is contained in:
@@ -10,10 +10,9 @@
|
||||
# define NUMBER_OF_ULSCH_MAX 8
|
||||
# define NUMBER_OF_DLSCH_MAX 8
|
||||
# define NUMBER_OF_SRS_MAX 16
|
||||
# define NUMBER_OF_NR_ULSCH_MAX MAX_MOBILES_PER_GNB
|
||||
# define NUMBER_OF_NR_DLSCH_MAX MAX_MOBILES_PER_GNB
|
||||
# define NUMBER_OF_SCH_STATS_MAX 16
|
||||
# define NUMBER_OF_NR_SCH_STATS_MAX MAX_MOBILES_PER_GNB
|
||||
|
||||
#define NUMBER_FRAMES_PHY_UE_INACTIVE 10
|
||||
|
||||
#define MAX_MANAGED_ENB_PER_MOBILE 2
|
||||
#define MAX_MANAGED_GNB_PER_MOBILE 2
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <sys/eventfd.h>
|
||||
#include <semaphore.h>
|
||||
|
||||
|
||||
extern "C" {
|
||||
@@ -434,24 +435,32 @@ extern "C" {
|
||||
void itti_send_terminate_message(task_id_t task_id) {
|
||||
}
|
||||
|
||||
pthread_mutex_t signal_mutex;
|
||||
sem_t itti_sem_block;
|
||||
void itti_wait_tasks_unblock()
|
||||
{
|
||||
int rc = sem_post(&itti_sem_block);
|
||||
AssertFatal(rc == 0, "error in sem_post(): %d %s\n", errno, strerror(errno));
|
||||
}
|
||||
|
||||
static void catch_sigterm(int) {
|
||||
static const char msg[] = "\n** Caught SIGTERM, shutting down\n";
|
||||
__attribute__((unused))
|
||||
int unused = write(STDOUT_FILENO, msg, sizeof(msg) - 1);
|
||||
pthread_mutex_unlock(&signal_mutex);
|
||||
itti_wait_tasks_unblock();
|
||||
}
|
||||
|
||||
void itti_wait_tasks_end(void) {
|
||||
void itti_wait_tasks_end(void (*handler)(int))
|
||||
{
|
||||
int rc = sem_init(&itti_sem_block, 0, 0);
|
||||
AssertFatal(rc == 0, "error in sem_init(): %d %s\n", errno, strerror(errno));
|
||||
|
||||
pthread_mutex_init(&signal_mutex, NULL);
|
||||
pthread_mutex_lock(&signal_mutex);
|
||||
if (handler == NULL) /* no handler given: install default */
|
||||
handler = catch_sigterm;
|
||||
signal(SIGTERM, handler);
|
||||
signal(SIGINT, handler);
|
||||
|
||||
signal(SIGTERM, catch_sigterm);
|
||||
signal(SIGINT, catch_sigterm);
|
||||
|
||||
pthread_mutex_lock(&signal_mutex);
|
||||
rc = sem_wait(&itti_sem_block);
|
||||
AssertFatal(rc == 0, "error in sem_wait(): %d %s\n", errno, strerror(errno));
|
||||
}
|
||||
|
||||
void itti_update_lte_time(uint32_t frame, uint8_t slot) {}
|
||||
|
||||
@@ -550,10 +550,13 @@ MessageDef *itti_alloc_new_message_sized(
|
||||
MessagesIds message_id,
|
||||
MessageHeaderSize size);
|
||||
|
||||
/** \brief handle signals and wait for all threads to join when the process complete.
|
||||
This function should be called from the main thread after having created all ITTI tasks.
|
||||
/** \brief Wait for SIGINT/SIGTERM signals to unblock ITTI.
|
||||
This function should be called from the main thread after having created all ITTI tasks. If handler is NULL, a default handler is installed.
|
||||
\param handler a custom signal handler. To unblock, it should call itti_wait_tasks_unblock()
|
||||
**/
|
||||
void itti_wait_tasks_end(void);
|
||||
void itti_wait_tasks_end(void (*handler)(int));
|
||||
/** \brif unblocks ITTI waiting in itti_wait_tasks_end(). **/
|
||||
void itti_wait_tasks_unblock(void);
|
||||
void itti_set_task_real_time(task_id_t task_id);
|
||||
|
||||
/** \brief Send a termination message to all tasks.
|
||||
|
||||
@@ -98,6 +98,8 @@ void *one_thread(void *arg) {
|
||||
myThread->runningOnKey=-1;
|
||||
mutexunlock(tp->incomingFifo.lockF);
|
||||
}
|
||||
else
|
||||
delNotifiedFIFO_elt(elt);
|
||||
} while (!myThread->terminate);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -279,6 +279,8 @@ static inline void pushTpool(tpool_t *t, notifiedFIFO_elt_t *msg) {
|
||||
|
||||
if (msg->reponseFifo)
|
||||
pushNotifiedFIFO(msg->reponseFifo, msg);
|
||||
else
|
||||
delNotifiedFIFO_elt(msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user