当前位置:网站首页>[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
边栏推荐
- tp6链接sqlserver,php链接sqlserver,linux离线安装与部署超详细
- R language observation log (part24) -- writexl package
- 【OpenAirInterface5g】RRC NR解析之RrcSetupRequest
- 5G-GUTI详解
- Producer and consumer issues
- 5g terminal identification Supi, suci and IMSI analysis
- Use of stopwatch
- [NAND file system] UBI introduction
- Lock锁(重点)
- 【openairinterface5g】项目目录结构
猜你喜欢

BlockingQueue四组API

What is JUC

C skill tree evaluation - customer first, making excellent products

Producer and consumer issues

On the matrix order of MNIST linear model

常用的辅助类—(重点)

【OpenAirInterface5g】RRC NR解析(一)

Empirical mode decomposition (EMD) and Hilbert Huang transform (HHT)

GeoSwath plus 技术和数据采集处理

【OpenAirInterface5g】高层模块接口及itti实体线程创建
随机推荐
Bathymetry along Jamaica coast based on Satellite Sounding
常用的辅助类—(重点)
SQL injection vulnerability (XIV) XFF injection attack
Generics in C #
IO intensive and CPU intensive
e.hash & oldCap == 0 详细解读
【TP6】使用workerman websocket
Expert PID control in Simulink
Single cell thesis record (Part12) -- unsupervised spatial embedded deep representation of spatial transcriptomics
[technical notes]
SQL 注入漏洞(十四)xff 注入攻击
5G终端标识SUPI,SUCI及IMSI解析
5g-guti detailed explanation
SQL 注入漏洞(十二)Cookie注入
Three methods of thread pool
生产者和消费者问题
【OpenAirInterface5g】高层模块接口及itti实体线程创建
Entry level test kotlin implements popwindow pop-up code
高考是人生旅途的一处驿站
Class load memory analysis