Introduce no-thread mode in ITTI
Introduce a --no-itti-threads command line option to disable threading in ITTI, and call message handlers in the current thread. This is being introduced in order to increase repeatability when testing the nrUE with the IQPlayer. Without this feature, runs with the IQPlayer will end up differently, depending on the timing of ITTI threads, mostly when sending messages to RRC and NAS.
This commit is contained in:
committed by
Robert Schmidt
parent
724c8c014c
commit
a198239084
@@ -30,17 +30,19 @@
|
||||
extern "C" {
|
||||
#include <intertask_interface.h>
|
||||
#include <common/utils/system.h>
|
||||
#include "executables/softmodem-common.h"
|
||||
|
||||
typedef struct timer_elm_s {
|
||||
timer_type_t type; ///< Timer type
|
||||
long instance;
|
||||
long duration;
|
||||
uint64_t timeout;
|
||||
void *timer_arg; ///< Optional argument that will be passed when timer expires
|
||||
} timer_elm_t ;
|
||||
typedef struct timer_elm_s {
|
||||
timer_type_t type; ///< Timer type
|
||||
long instance;
|
||||
long duration;
|
||||
uint64_t timeout;
|
||||
void *timer_arg; ///< Optional argument that will be passed when timer expires
|
||||
} timer_elm_t;
|
||||
|
||||
typedef struct task_list_s {
|
||||
task_info_t admin;
|
||||
ittiTask_parms_t task_parms;
|
||||
pthread_t thread;
|
||||
pthread_mutex_t queue_cond_lock;
|
||||
std::vector<MessageDef *> message_queue;
|
||||
@@ -162,12 +164,12 @@ extern "C" {
|
||||
pthread_mutex_lock (&t->queue_cond_lock);
|
||||
int ret=itti_send_msg_to_task_locked(destination_task_id, destinationInstance, message);
|
||||
|
||||
while ( t->message_queue.size()>0 && t->admin.func != NULL ) {
|
||||
while (t->message_queue.size() > 0 && t->task_parms.shortcut_func != NULL) {
|
||||
if (t->message_queue.size()>1)
|
||||
LOG_W(ITTI,"queue in no thread mode is %ld\n", t->message_queue.size());
|
||||
|
||||
pthread_mutex_unlock (&t->queue_cond_lock);
|
||||
t->admin.func(NULL);
|
||||
t->task_parms.shortcut_func(NULL);
|
||||
pthread_mutex_lock (&t->queue_cond_lock);
|
||||
}
|
||||
|
||||
@@ -327,11 +329,20 @@ extern "C" {
|
||||
pthread_mutex_unlock (&t->queue_cond_lock);
|
||||
}
|
||||
|
||||
int itti_create_task(task_id_t task_id,
|
||||
void *(*start_routine)(void *),
|
||||
void *args_p) {
|
||||
int itti_create_task(const task_id_t task_id, void *(*start_routine)(void *), const ittiTask_parms_t *parms)
|
||||
{
|
||||
task_list_t *t=tasks[task_id];
|
||||
threadCreate (&t->thread, start_routine, args_p, (char *)itti_get_task_name(task_id),-1,OAI_PRIORITY_RT);
|
||||
if (get_softmodem_params()->no_itti && task_id < sizeofArray(tasks_info) && parms && parms->shortcut_func) {
|
||||
LOG_W(ITTI, "not starting the thread for %s, the msg processing will be done in place\n", tasks_info[task_id].name);
|
||||
t->task_parms.shortcut_func = parms->shortcut_func;
|
||||
return 0;
|
||||
}
|
||||
threadCreate(&t->thread,
|
||||
start_routine,
|
||||
parms ? parms->args_to_start_routine : NULL,
|
||||
(char *)itti_get_task_name(task_id),
|
||||
-1,
|
||||
OAI_PRIORITY_RT);
|
||||
LOG_I(ITTI,"Created Posix thread %s\n", itti_get_task_name(task_id) );
|
||||
return 0;
|
||||
}
|
||||
@@ -353,6 +364,7 @@ extern "C" {
|
||||
AssertFatal(new_tasks != NULL, "could not realloc() tasks list");
|
||||
tasks = new_tasks;
|
||||
tasks[newQueue]= new task_list_t;
|
||||
tasks[newQueue]->task_parms = {0};
|
||||
pthread_mutex_unlock (&lock_nb_queues);
|
||||
LOG_I(ITTI,"Starting itti queue: %s as task %d\n", taskInfo->name, newQueue);
|
||||
pthread_mutex_init(&tasks[newQueue]->queue_cond_lock, NULL);
|
||||
@@ -361,9 +373,6 @@ extern "C" {
|
||||
AssertFatal( ( tasks[newQueue]->sem_fd = eventfd(0, EFD_SEMAPHORE) ) >=0, "");
|
||||
itti_subscribe_event_fd((task_id_t)newQueue, tasks[newQueue]->sem_fd);
|
||||
|
||||
if (tasks[newQueue]->admin.threadFunc != NULL)
|
||||
itti_create_task((task_id_t)newQueue, tasks[newQueue]->admin.threadFunc, NULL);
|
||||
|
||||
return newQueue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user