当前位置:网站首页>Those things on the server side
Those things on the server side
2022-07-18 07:23:00 【Pseudo procedural ape who loves fishing】
Previous review
In a previous blog post , We introduced OpenHarmony Structure of module 2 , It also roughly expounds that Provider and Consumer It is the relationship between the server and the client of the main role . At the same time, we also introduced samgr_client The function implementation process of the client with file as the object .
All the contents are reviewed as follows :
OpenHarmony Preliminary analysis of module 2
OpenHarmony Preliminary analysis of module 2 (2)
Those things about the client
What happened to the client (2)
Functional analysis
Function encapsulation
The code of the file begins with two function encapsulation , Respectively SamgrServer and ProcFunc Two function packages .
The code is as follows :
static SamgrServer g_server = {
.GetName = GetName, // Get the name of a service element
.Initialize = Initialize, // initialization
.GetTaskConfig = GetTaskConfig, // Define the task configuration of the service
.MessageHandle = MessageHandle, // Processing service messages
SERVER_IPROXY_IMPL_BEGIN, // Defines the start of the default initialization of the server proxy class .
// This macro is used to develop the server proxy class , You can inherit this macro to reduce the amount of code and prevent inconsistent class definitions .
.Invoke = Invoke, // From the client to IServerProxy send out IPC news
IPROXY_END,
};
static ProcFunc g_functions[] = {
// Process function
[RES_ENDPOINT] = ProcEndpoint, // Process terminal
[RES_FEATURE] = ProcFeature, // Process characteristics
[RES_SYSCAP] = ProcSysCap, // Process system capability
};
When encapsulating functions , The functions encapsulated in the package are not immediately executed , Instead, execute at the time of the call , These two function packages will often be called in subsequent function functions .
Now briefly introduce the function implementation process of the encapsulated function :
GetName
This function calls a pointer service, Return to one SAMGR_SERVICE, This pointer points to the service that needs to be obtained
Initialize
Initialization operation , It mainly initializes the service and identity invoked by the user , The function of adding router is called in this function , At the same time, the user's identity 、 The pointer to the called function returns null , A new space is reapplied for storing the identity of the new user and the new pointer to the called function , So as to achieve the initialization operation .
GetTaskConfig
The function of this function is to define the task configuration of the service , In this function , We can see that it calls a TaskConfig function
static TaskConfig GetTaskConfig(Service *service) // Define the task configuration of the service , Used to get task management
{
(void)service;
// Can't be used directly PRI_BUTT, As a result, less 1
TaskConfig config = {
LEVEL_HIGH, PRI_BUTT - 1, 0x400, 20, SINGLE_TASK}; // Cannot use PRI_BUTT directly, so minus 1
return config;
}
This function defines five contents , as follows :
struct TaskConfig {
int16 level; // Multi service shared tasks ID.
int16 priority; // Task priority .
uint16 stackSize; // The size of the task stack
uint16 queueSize; // The size of the task queue
uint8 taskFlags; // Task type .
};
#pragma pack()
Therefore, defining the task configuration of services mainly starts with defining five task configurations :
- Multi service shared tasks ID
- Task priority
- The size of the task stack
- The size of the task queue
- Task type
MessageHandle
Processing service messages , First open the mutex , And then call SASTORA_ClearByPid adopt Pid Remove old ( After use ) User service information , Close the mutex after these steps
static BOOL MessageHandle(Service *service, Request *request) // Processing service messages
{
SamgrServer *server = (SamgrServer *)service;
switch (request->msgId) {
case MSG_CLEAN:
MUTEX_Lock(server->mtx); // The mutex
SASTORA_ClearByPid(&server->store, request->msgValue); // adopt Pid eliminate
MUTEX_Unlock(server->mtx); // Mutually exclusive unlock
break;
default:
break;
}
return TRUE;
}
ProcEndpoint
Process terminal , Node used to set the end of the process .
Implementation process : First get a call pid, Then open the mutex , Through the pid Find a handle to store , Then through a service handle , Get call Tid And call uid, Re pass Pid Preservation processing , Logout death callback , Close mutex .
You can use a simple flow chart to describe :
ProcFeature
Process characteristics , This function is used to detect whether the characteristic value is set successfully . In the function , According to different conditions Get three different features :
①IPC Authentication interface ;② Process output characteristics ;③ Process acquisition characteristics
The functions and implementation processes of these features will be introduced later
ProcSysCap
This function is used to test the system capability , First call CanRequest Function to judge and check , Do not give permission when the conditions are met . If the customer gets permission , The following test functions can be performed :
① Process adds system capabilities (ProcAddSysCap)
② Processes acquire system capabilities (ProcGetSysCap)
③ The process acquires all system capabilities (ProcGetAllSysCap)
The implementation process of these functions will also be introduced in subsequent blogs
Next up
In the next issue, we will introduce the implementation process of some functions mentioned in this blog , In addition samgr_server Functions of other functions under the file .
What if you want to know what happened , Let's hear the decomposition next time
Related blog
OpenHarmony File under module 2 samgr_server analysis (1)
OpenHarmony File under module 2 samgr_server analysis (2)
OpenHarmony File under module 2 samgr_server analysis (3)
OpenHarmony File under module 2 samgr_server analysis (4)
OpenHarmony File under module 2 samgr_server analysis (5)
边栏推荐
- PHP大量数据循环时内存耗尽问题的解决方案
- 福赛生物解读2022上半年大气环境变化,VOCs治理依然是破局关键
- C language (high level) static address book
- Basic usage of flask
- (戴尔灵越7572)笔记本外扩显示器以后,笔记本没有声音了的解决办法
- JVM内存比例调节
- Is it safe to choose a securities company to open an account for tongdaxin?
- Centernet (objects as points) [based on tf.slim]
- Processing and analysis of yolov3 training data
- 单链链表的创建
猜你喜欢

MySQL pymysql module

【示波器的基本使用】以及【示波器按键面板上各个按键含义的介绍】

MODBUS-RS485布线的8条准则

ERROR: THESE PACKAGES DO NOT MATCH THE HASHES FROM THE REQUIREMENTS FILE. If you have updated the

抽丝剥茧C语言(高阶)静态通讯录

consul启动闪退

MySQL MySQL Foundation

Getting started with OpenCV ----- vs how to install opencv Library

MySQL autoincrement, index, foreign key, other operations
![[use win10's own remote connection tool] to remotely access and control [another win10 Computer]](/img/a8/c58e43b4e2441db9dc57e1751ee262.png)
[use win10's own remote connection tool] to remotely access and control [another win10 Computer]
随机推荐
在数组中指定位置插入任意一个元素及删除数组中值为x的元素
模块二interfaces下头文件解析
利用chardet检测网页编码
ab网站压力测试
福赛生物解读2022上半年大气环境变化,VOCs治理依然是破局关键
PHP 如何把二维数组变为 一维数组
Unet++ network tensorflow Version (slim Implementation)
Parsing of header file under interfaces in module 2
自增(自减)运算符的运算优先级
Programming exercises
What is the distributed query engine of polardb for PostgreSQL?
ASP. Net
C language: use macro to redefine printf and print [debug debugging information]
Typora changes text color and line breaks
【森城市】GIS数据漫谈(四)— 坐标系统
LINQ implements query string splicing: and and or
linq 实现动态 orderby
Lenovo Power Management Download
传值、传引用、传指针
如何将面向Oracle开发的应用所使用到的复杂的SQL语句,迁移至基于PolarDB for Pos