mirror of
https://gitee.com/openharmony/graphic_graphic_2d
synced 2025-02-20 12:23:52 +00:00
SetQOS for ipc
Signed-off-by: chenlulu <chenlulu16@huawei.com> Change-Id: Ic740d38eef5976432f718e3f33ef653ce6a78724
This commit is contained in:
parent
9b3a1d8270
commit
a317adc237
@ -16,6 +16,11 @@
|
||||
#include "rs_render_service_connection_stub.h"
|
||||
#include <memory>
|
||||
#include "ivsync_connection.h"
|
||||
#ifdef RES_SCHED_ENABLE
|
||||
#include "res_sched_client.h"
|
||||
#include "res_type.h"
|
||||
#include <sched.h>
|
||||
#endif
|
||||
#include "securec.h"
|
||||
#include "sys_binder.h"
|
||||
|
||||
@ -39,6 +44,10 @@ constexpr size_t MAX_DATA_SIZE_FOR_UNMARSHALLING_IN_PLACE = 1024 * 15; // 15kB
|
||||
constexpr size_t FILE_DESCRIPTOR_LIMIT = 15;
|
||||
constexpr size_t MAX_OBJECTNUM = INT_MAX;
|
||||
constexpr size_t MAX_DATA_SIZE = INT_MAX;
|
||||
#ifdef RES_SCHED_ENABLE
|
||||
const uint32_t RS_IPC_QOS_LEVEL = 7;
|
||||
constexpr const char* RS_BUNDLE_NAME = "render_service";
|
||||
#endif
|
||||
static constexpr std::array descriptorCheckList = {
|
||||
static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::SET_FOCUS_APP_INFO),
|
||||
static_cast<uint32_t>(RSIRenderServiceConnectionInterfaceCode::GET_DEFAULT_SCREEN_ID),
|
||||
@ -274,12 +283,40 @@ bool IsValidCallingPid(pid_t pid, pid_t callingPid)
|
||||
|
||||
}
|
||||
|
||||
void RSRenderServiceConnectionStub::SetQos()
|
||||
{
|
||||
#ifdef RES_SCHED_ENABLE
|
||||
std::string strBundleName = RS_BUNDLE_NAME;
|
||||
std::string strPid = std::to_string(getpid());
|
||||
std::string strTid = std::to_string(gettid());
|
||||
std::string strQos = std::to_string(RS_IPC_QOS_LEVEL);
|
||||
std::unordered_map<std::string, std::string> mapPayload;
|
||||
mapPayload["pid"] = strPid;
|
||||
mapPayload[strTid] = strQos;
|
||||
mapPayload["bundleName"] = strBundleName;
|
||||
OHOS::ResourceSchedule::ResSchedClient::GetInstance().ReportData(
|
||||
OHOS::ResourceSchedule::ResType::RES_TYPE_THREAD_QOS_CHANGE, 0, mapPayload);
|
||||
struct sched_param param = {0};
|
||||
param.sched_priority = 1;
|
||||
if (sched_setscheduler(0, SCHED_FIFO, ¶m) != 0) {
|
||||
RS_LOGE("RSRenderServiceConnectionStub Couldn't set SCHED_FIFO.");
|
||||
} else {
|
||||
RS_LOGI("RSRenderServiceConnectionStub set SCHED_FIFO succeed.");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int RSRenderServiceConnectionStub::OnRemoteRequest(
|
||||
uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option)
|
||||
{
|
||||
RS_PROFILER_ON_REMOTE_REQUEST(this, code, data, reply, option);
|
||||
|
||||
pid_t callingPid = GetCallingPid();
|
||||
auto tid = gettid();
|
||||
if (tids_.find(tid) == tids_.end()) {
|
||||
SetQos();
|
||||
tids_.insert(tid);
|
||||
}
|
||||
if (std::find(std::cbegin(descriptorCheckList), std::cend(descriptorCheckList), code) !=
|
||||
std::cend(descriptorCheckList)) {
|
||||
auto token = data.ReadInterfaceToken();
|
||||
|
@ -16,6 +16,7 @@
|
||||
#ifndef ROSEN_RENDER_SERVICE_BASE_TRANSACTION_RS_RENDER_SERVICE_CONNECTION_STUB_H
|
||||
#define ROSEN_RENDER_SERVICE_BASE_TRANSACTION_RS_RENDER_SERVICE_CONNECTION_STUB_H
|
||||
|
||||
#include <unordered_set>
|
||||
#include <iremote_stub.h>
|
||||
#include <message_option.h>
|
||||
#include <message_parcel.h>
|
||||
@ -42,7 +43,9 @@ private:
|
||||
|
||||
void ReadDataBaseRs(DataBaseRs& info, MessageParcel& data);
|
||||
void ReadGameStateDataRs(GameStateData& info, MessageParcel& data);
|
||||
void SetQos();
|
||||
RSRenderServiceSecurityUtils securityUtils_;
|
||||
std::unordered_set<int> tids_;
|
||||
};
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
Loading…
x
Reference in New Issue
Block a user