当前位置:网站首页>[openairinterface5g] high level module interface and ITTI entity thread creation
[openairinterface5g] high level module interface and ITTI entity thread creation
2022-06-22 06:23:00 【No.7 Huazai】
Catalog
OAI High rise structure
OAI L3 It is mainly divided into RRC,NGAP,SCTP In the third part of :
- RRC Responsible for radio resource management , Be responsible for making gNB And UE Establishing a connection , And signaling encoding and decoding .
- NGAP be responsible for gNB And AMF Establishing a connection , Signaling NGAP Encode, decode and forward .
- SCTP Be similar to TCP, Provide reliable network transmission , be responsible for AMF And gNB Between NGAP Sending and receiving messages .
Between modules ,OAI Used ITTI The public management module is responsible for standardizing entity management , Thread management , Queue management , Memory management, etc , Ensure the standardization of resource use of each module .
OAI The main program calls itti_create_task() establish RRC、NGAP、SCTP as well as PDCP The main thread , Thread creation can be performed CPU Kernel binding ( At present OAI The program does not enable kernel binding ). After thread creation , Use in each module while(1) Cycle call itti_receive_msg() Get data from the message queue of this module , Process according to the flow after decoding , Called when a message is sent iiti_send_msg_to_task() Push data into the queue of the target module .SCTP And AMF Between SCTP Connect for messaging .
ITTI Entity thread creation
Entity creation
Entity creation is actually OAI Modules task Object creation , And the corresponding thread creation , Each module is usually a main thread , And include possible worker threads . In thread while() The loop ensures that the entity is always running , This is a conventional approach .
int itti_create_task(task_id_t task_id,
void *(*start_routine)(void *),
void *args_p) {
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);
LOG_I(TMR,"Created Posix thread %s\n", itti_get_task_name(task_id) );
return 0;
}
main call itti_create_task Function to create an entity , among
task_id: Module entity ID, Such as TASK_RRC_GNB
start_routine: Name of the thread function created
args_p: Parameters passed ,OAI Inside are NULL
In code tasks An array is a collection of entities , Contains the common attributes of each entity , Easy to access at any time .
threadCreate The function is responsible for thread creation
Thread creation
The thread creation process is as follows , See notes for creation steps
void threadCreate(pthread_t* t, void * (*func)(void*), void * param, char* name, int affinity, int priority){
pthread_attr_t attr;
int ret;
int settingPriority = 1;
// Initializes the properties of the thread object
ret=pthread_attr_init(&attr);
AssertFatal(ret==0,"ret: %d, errno: %d\n",ret, errno);
// Set the thread to the detached state
ret=pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
AssertFatal(ret==0,"ret: %d, errno: %d\n",ret, errno);
// Set the scheduling policy that the thread does not inherit from the parent thread
ret=pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
AssertFatal(ret==0,"ret: %d, errno: %d\n",ret, errno);
if (checkIfFedoraDistribution())
if (checkIfGenericKernelOnFedora())
if (checkIfInsideContainer())
settingPriority = 0;
/*SCHED_OAI, Its macro is defined as #define SCHED_OAI SCHED_RR, That is, the thread adopts polling scheduling Each module can determine its own priority according to its needs */
if (settingPriority) {
ret=pthread_attr_setschedpolicy(&attr, SCHED_OAI);
AssertFatal(ret==0,"ret: %d, errno: %d\n",ret, errno);
if(priority<sched_get_priority_min(SCHED_OAI) || priority>sched_get_priority_max(SCHED_FIFO)) {
LOG_E(TMR,"Prio not possible: %d, min is %d, max: %d, forced in the range\n",
priority,
sched_get_priority_min(SCHED_OAI),
sched_get_priority_max(SCHED_OAI));
if(priority<sched_get_priority_min(SCHED_OAI))
priority=sched_get_priority_min(SCHED_OAI);
if(priority>sched_get_priority_max(SCHED_OAI))
priority=sched_get_priority_max(SCHED_OAI);
}
AssertFatal(priority<=sched_get_priority_max(SCHED_OAI),"");
struct sched_param sparam={
0};
sparam.sched_priority = priority;
// Set thread priority
ret=pthread_attr_setschedparam(&attr, &sparam);
AssertFatal(ret==0,"ret: %d, errno: %d\n",ret, errno);
}
// Create a thread using the previously set property variable
ret=pthread_create(t, &attr, func, param);
AssertFatal(ret==0,"ret: %d, errno: %d\n",ret, errno);
// Set the thread name
pthread_setname_np(*t, name);
if (affinity != -1 ) {
cpu_set_t cpuset;
CPU_ZERO(&cpuset);
CPU_SET(affinity, &cpuset);
AssertFatal( pthread_setaffinity_np(*t, sizeof(cpu_set_t), &cpuset) == 0, "Error setting processor affinity");
}
// Destroy thread property variables
pthread_attr_destroy(&attr);
}
Thread to exit
Be responsible for exiting the current thread , Regular functions .
void itti_exit_task(void) {
pthread_exit (NULL);
}
Entity properties
Entity attributes are defined as follows :
typedef struct task_list_s {
task_info_t admin;
pthread_t thread;
pthread_mutex_t queue_cond_lock;
std::vector<MessageDef *> message_queue;
std::map<long,timer_elm_t> timer_map;
uint64_t next_timer=UINT64_MAX;
struct epoll_event *events =NULL;
int nb_fd_epoll=0;
int nb_events=0;
int epoll_fd=-1;
int sem_fd=-1;
} task_list_t;
admin: Entity information , Including scheduling priority , The queue length , The entity name , Thread functions
thread: Threads ID
queue_cond_lock: Queue lock
message_queue: Message queue , Each module has its own message queue , Responsible for storing messages sent by other modules
timer_map: Timer
next_timer: Due time
边栏推荐
- Shengxin visualization (Part2) -- box diagram
- ERROR: cannot verify nih.at’s certificate, issued by “/C=US/O=Let‘s Encrypt/CN=R3”,wget报错
- Expert PID control in Simulink
- 【5G NR】手机身份证号IMEI与IMEISV
- You are using PIP version 19.0.3, however version 22.1.2 is available
- Detailed interpretation of tab[i = (n - 1) & hash]
- Stream流式计算
- Leetcode the shortest path of three (eight) charts per week
- 【5G NR】UE注册管理状态
- 安装boost
猜你喜欢

Dynamically create object execution methods

5g terminal identification Supi, suci and IMSI analysis

W800 chip platform enters openharmony backbone

WPS文档目录更新产生的问题记录

CMake 入门级别语法

Surfer grid file clipping

Vulnérabilité à l'injection SQL (XIII) injection base64

集合类并发不安全问题

【5G NR】NG接口

Oracle之trim,ltrim,rtrim三个函数的用法
随机推荐
[PHP]TP6 CLI模式下创建tp6和多应用配置以及常见问题
C skill tree evaluation - customer first, making excellent products
GeoSwath plus 技术和数据采集处理
SQL injection vulnerability (XI) wide byte injection
从入门到精通之专家系统CLIPS(一)CLIPS初识与概述
Machine learning concept sorting (no formula)
【5G NR】NGAP协议之NG Setup
Unsafe concurrency of collection classes
类加载内存分析
【OpenAirInterface5g】RRC NR解析之RrcSetupRequest
keil C关于switch语句问题导致芯片不能正常运行
Chrome 安装 driver
Four functional interfaces (required)
C技能树评测——用户至上做精品
878. the nth magic number math + two points
postgresql数据库中根据某个字段判断存在则更新(update)操作,不存在则插入(insert)
Surfer格网文件裁剪
Seven parameters of thread pool and custom thread pool
Research on automatic landing control system of carrier aircraft
Modeling and Simulation of Radar Seeker Servo System