This application discloses a method for limiting inter-process communication, which includes intercepting binder requests when a client sends a binder request to a server and obtaining the current number of binder threads consumed by the client and the total number of binder threads on the server, as well as obtaining the share of the client and the total share of all clients currently communicating with the server. Calculate the first ratio of the number of binder threads to the total number of binder threads, and calculate the second ratio of the share to the total share; determine whether the first ratio is greater than the second ratio; if so, add the intercepted binder request to the end of the waiting queue; where the binder request in the waiting queue is processed after a set period of time. The application also discloses an electronic device and a storage medium. In this way, the application can limit the first ratio between the number of binder threads consumed by the client and the total number of binder threads consumed by the server to the second ratio which changes in real time, thus ensuring the fluency of the system.
【技术实现步骤摘要】
电子装置及其限制进程间通信的方法、存储介质
本专利技术涉及电子设备
,特别是涉及一种电子装置及其限制进程间通信的方法、存储介质。
技术介绍
目前,随着科学技术的不断发展,智能手机等电子装置日渐成为人们日常生活的必需品。安卓系统是智能手机等电子装置的一种常见的操作系统,安卓系统中的两个进程之间通常需要进行通信,进程之间的用户空间是不能共享的,因此两个进程之间的通信通常需要Binder机制来实现通信。现有的电子装置没有对进程间采用Binder机制进行通信情况的监控机制,且无法对进程间通信进程进行优化,导致系统流畅度不高。
技术实现思路
本申请实施例采用的一个技术方案是:提供一种限制进程间通信的方法,该方法包括:在客户端向服务端发送binder请求时,截获binder请求,并获取当前客户端消耗服务端的binder线程数量、服务端的binder线程总数量,以及获取客户端所占的份额、当前与服务端通信的所有客户端所占的总份额;计算binder线程数量与binder线程总数量的第一比值,且计算份额与总份额的第二比值;判断第一比值是否大于第二比值;若是,则将截获的binder请求加入等待队列末端;其中,在设定时间段之后处理等待队列中的binder请求。本申请实施例采用的另一个技术方案是:提供一种电子装置,该电子装置包括:获取模块,用于在客户端向服务端发送binder请求时,截获binder请求,并获取当前客户端消耗服务端的binder线程数量、服务端的binder线程总数量,以及获取客户端所占的份额、当前与服务端通信的所有客户端所占的总份额;计算模块,用于计算binde ...
【技术保护点】
1.一种限制进程间通信的方法,其特征在于,所述方法包括:在客户端向服务端发送binder请求时,截获所述binder请求,并获取当前所述客户端消耗所述服务端的binder线程数量、所述服务端的binder线程总数量,以及获取所述客户端所占的份额、当前与所述服务端通信的所有客户端所占的总份额;计算所述binder线程数量与所述binder线程总数量的第一比值,且计算所述份额与所述总份额的第二比值;判断所述第一比值是否大于第二比值;若是,则将截获的所述binder请求加入等待队列末端;其中,在设定时间段之后处理所述等待队列中的binder请求。
【技术特征摘要】
1.一种限制进程间通信的方法,其特征在于,所述方法包括:在客户端向服务端发送binder请求时,截获所述binder请求,并获取当前所述客户端消耗所述服务端的binder线程数量、所述服务端的binder线程总数量,以及获取所述客户端所占的份额、当前与所述服务端通信的所有客户端所占的总份额;计算所述binder线程数量与所述binder线程总数量的第一比值,且计算所述份额与所述总份额的第二比值;判断所述第一比值是否大于第二比值;若是,则将截获的所述binder请求加入等待队列末端;其中,在设定时间段之后处理所述等待队列中的binder请求。2.根据权利要求1所述的方法,其特征在于,所述获取客户端所占的份额、当前与所述服务端通信的所有客户端所占的总份额包括:根据所述客户端的标识信息在标识信息与份额的对应关系表中查找对应的份额以得到所述客户端的份额;根据当前与所述服务端通信的所有客户端各自的标识信息在所述对应关系表中查找各自对应的份额并进行求和以得到所述总份额。3.根据权利要求1所述的方法,其特征在于,所述在设定时间段之后处理所述等待队列中的binder请求的步骤,包括:在设定时间段后将所述等待队列中的binder请求发送至所述服务端,以允许所述服务端对所述等待队列中的binder请求进行响应并与所述客户端进行进程间通信。4.根据权利要求1所述的方法,其特征在于,所述在设定时间段之后处理所述等待队列中的binder请求的步骤,包括:在设定时间段之后将所述等待队列首端的binder请求作为客户端向服务端发送binder请求,返回在客户端向服务端发送binder请求时,截获所述binder请求,并获取当前所述客户端消耗所述服务端的binder线程数量、所述服务端的binder线程总数量,以及获取所述客户端所占的份额、当前与所述服务端通信的所有客户端所占的总份额的步骤。5.根据权利要求1所述的方法,其特征在于,所述在客户端向服务端发送binder请求时,截获所述binder请求,并获取当前所述客户端消耗的binder线程数量、所述服务端的binder线程总数量之前,包括:在所述服务端的binder线程被唤醒时,将唤醒所述binder线程的客户端消耗所述服务端的binder线程数量加一;在所述binder线程恢复空闲状态时,将唤醒所述binder线程的客户端消耗所述服务端的binder线程数量减一。6.根据权利要求1所述的方法,其特征在于,所述判断所述第一比值是否第二比值的步骤之后,还包括:若否,则将截获的所述binder请求发送至所述服务端,以允许所述服务端响应所述客户端发送的binder请求并与所述客户端进行进程间通信。7...
【专利技术属性】
技术研发人员:周明君,方攀,陈岩,
申请(专利权)人:OPPO重庆智能科技有限公司,
类型:发明
国别省市:重庆,50
还没有人留言评论。发表了对其他浏览者有用的留言会获得科技券。