ANDROID SOFTWARE AGING AND REJUVENATION MODEL CONSIDERING THE BATTERY CHARGE

.


ABBREVIATIONS
OS is an operating system; UI is a user interface; AY is an "Active Young" state; RA is a "Rebirth Active" state; ARe is an "Active Recovering" state; AYS(L)p is an "Active Young Stable (Low) Power Op is an "Off Power" state.NOMENCLATURE λ is a transition rate between states; λ AS is a transition rate from "Active" state to "Sleep" state; λ SA is a transition rate from "Sleep" state to "Active" state; λ YO is a transition rate from "Young" state to "Old" state; λ ORe is a transition rate from "Old" state to "Recovering" state; λ ReY is a transition rate from "Recovering" state to "Young" state; λ YR is a transition rate from "Young" state to "Rebirth" state; λ RY is a transition rate from "Rebirth" state to "Young" state; λ HpLp is a transition rate from "High Power" state to "Low Power" state; λ LpCh is a transition rate from "Low Power" state to "Charging" state; λ ChHp is a transition rate from "Charging" state to "High Power" state; λ LpOp is a transition rate from "Low Power" state to "Off Power" state; λ SpLp is a transition rate from "Stable Power" state to "Low Power" state; λ LpSp is a transition rate from "Low Power" state to "Stable Power" state; t is a time; P(t) is the probabilities vector of the system in different states at time t; P AYS(L)p (t) is the probability of a system being at time t in the "Active Young Stable (Low) Power" state; P AOS(L)p (t) is the probability of a system being at time t in the "Active Old Stable (Low) Power" state; P AReS(L)p (t) is the probability of a system being at time t in the "Active Recovering Stable (Low) Power" state; P ARS(L)p (t) is the probability of a system being at time t in the "Active Rebirth Stable (Low) Power" state; P SYS(L)p (t) is the probability of a system being at time t in the "Sleep Young Stable (Low) Power" state; P SOS(L)p (t) is the probability of a system being at time t in the "Sleep Old Stable (Low) Power" state; P SReS(L)p (t) is the probability of a system being at time t in the "Sleep Recovering Stable (Low) Power" state; P SRS(L)p (t) is the probability of a system being at time t in the "Sleep Rebirth Stable (Low) Power" state; P Op (t) is the probability of a system being at time t in the "Off Power" state; T avg is an average transition time.
INTRODUCTION Software aging process is a phenomenon of performance deterioration and failures rate increase caused by the accumulation of software and system errors that are unpredictable and their effects can occur with delays in systems that run for a long time without reboots [1][2][3][4][5][6][7].Aging-related errors are memory leaks, rounding errors, etc.The phenomenon of software aging has been widely studied in various systems and applications, such as Linux, Apache server, middleware [3][4][5][6], Android OS [8][9][10].
Software rejuvenation procedure is a proactive technique to prevent and delay software aging [2].This approach involves the planned regular or irregular cleaning of the system internal state in such a way as to reduce the number of accumulated errors.Software rejuvenation can be applied to different levels of the system, such as system processes and user applications, data objects within processes, or the entire operating system.
Mobile systems have specific characteristics of operation and use by the user, compared to server or personal computer systems.The previous article [10] describes some features of mobile platforms, as well as the relevance of studying the phenomenon of software aging in mobile systems.Software aging in Android OS manifests as slow response of the user interface after prolonged use of a mobile phone, which is common issue for most users.Also, Android is one of the most popular systems for mobile phones and occupies 84.1% of the market as of 2020 [11].Due to the urgency of the software aging problem in mobile systems and the popularity of Android OS, an important task is to develop mathematical and algorithmic tools to combat the phenomenon of software aging, in particular modeling of the phenomenon taking into account different factors allows to plan the rejuvenation procedure.
The object of the study is the process of software aging.
The subject of the study is a model of the software aging process for mobile OS with performing rejuvenation procedure.
The purpose of the work is to develop a model of software aging process for Android OS with performing rejuvenation procedure, which takes into account the model of mobile device usage by the users and battery charge level.

PROBLEM STATEMENT
The rejuvenation procedure is used to counteract the phenomenon of software aging.Performing this procedure requires predicting the occurrence of software aging and planning the time of rejuvenation based on the predicted data.The model of the rejuvenation process should take into account the specific factors and features of the Android OS, as well as data that will objectively reflect the status and dynamics of changes in system performance to be able to make accurate predictions.
Analytical description of software aging process with rejuvenation procedure will be presented in the form of Continuous-Time Markov Chains.Steps needed to build a model and perform calculations to determine the optimal rejuvenation time: -build and describe the model of software aging process and rejuvenation procedure, the model of the battery charge states and the model of mobile phone user activity; -identify the states in which the system may be according to considered models and describe the transition rates between these states; -build a graph of state transitions and describe a system of differential equations based on this graph; -calculate a system of differential equations using a test set of transition rates between states and analyze the results of calculations.
Calculating the system of differential equations will determine the probabilities of the mobile OS in different states at a particular time.To determine the optimal time to perform the rejuvenation procedure, proposed model allows to find the time when the probability of the system being in a state of active usage and low battery is minimal and aging-related effects are observed.

RELATED WORKS
To counteract the phenomenon of software aging in the Android mobile system, various approaches are proposed, both at the level of optimizing the architecture of the developed software [12] and by performing the rejuvenation procedure [13][14].
The article [15] proposes a model, which is a combination of the user behavior model and the software aging model with performing rejuvenation procedure.These models and their combinations are constructed in the form of stochastic Petri nets [16], based on which Continuous-Time Markov Chains were generated [17].
The model of user behavior is shown in Figure 1 and is described by two possible states: "Active" (the user is actively using the phone) and "Sleep" (the phone is in standby mode).Determining whether the device is in a certain state, as well as determining the transition rate between states, is proposed by accumulating statistics on user activity over time.Software aging model with performing rejuvenation procedure consists of four states: "Young", "Old", "Recovering" and "Rebirth".It is assumed that when the device is turned on, the system is productive and the probability of aging-related failure is very low, i.e., the system is at "Young" state.After prolonged use of the phone, the system goes into "Old" state.The probability of such a transition can be determined by monitoring certain system metrics (such as UI response time and memory usage) and certain thresholds that will be indicators of the transition from "Young" to "Old" state.Switching from "Old" state to "Recovering" state means restarting the mobile device by the user due to critically poor performance or device rebooting due to system aging-related failure.Restart of the device returns the system to "Young" state.The rejuvenation procedure takes place in "Rebirth" state, which can be accessed from "Young" state.The main goal of the model when planning the rejuvenation procedure is to determine the optimal time of transition to "Rebirth" state, which will precede the transition to "Old" state.An important factor in choosing the optimal time is to restrict the performance of the rejuvenation procedure if the user is currently using the phone, i.e., the phone is in "Active" state.This is important limitation because the rejuvenation procedure may have negative impact on user experience or cause a failure when user uses a mobile device, for example, if the rejuvenation procedure involves rebooting system or critical system components.
The model proposed by the authors [15] allowed them to determine the optimal time for the rejuvenation procedure (approximately 30 hours after turning on the phone), although the input data for the model were selected with many simplifications and assumptions.Proposed model can be expanded and improved.This paper proposes new model which considers the battery charge factor, as mobile devices depend on the battery capacity and are vulnerable to increase of intensity of the battery discharge.

MATERIALS AND METHODS
The model discussed in the previous section is proposed to be extended by an additional model that describes the battery charge.Two variants of battery charge models can be considered: general and simplified, which will be used in this work.The general model of a battery charge level can be described by means of four states (Fig. 3): 1) High Power -high battery level (for example, battery charge interval 100-25%); 2) Low Power -critically low battery charge at which it is impractical to perform rejuvenation procedure (for example, less than 25%); 3) Charging -the device is charging; 4) Off Power -the device discharged and turned off.State "Charging" does not actually affect the choice of rejuvenation, as it is impossible to predict the transition to this state or the duration of stay in this state, so the choice to rejuvenate or not still depends on the current battery status.Therefore, it is proposed to simplify this model and replace "High Power" and "Charging" states with the "Stable Power" state, which will mean a sufficient charge of the phone battery for the rejuvenation procedure.It is worth noting that "Charging" state can still be taken into account to adjust and delay the rejuvenation procedure after the initial planning based on the model.The final version of the simplified model is shown in Figure 4.The transitions between states in this model can be calculated based on information about the current state of battery charge and the estimated time to complete discharge.The transition threshold between "Stable" and "Low", "Low" and "Off" states can be expressed as predictions of the discharge or charging time to the appropriate level, for example, 12 hours before the battery is fully discharged, or 3 hours before the battery is fully charged.
The software aging model with rejuvenation, the user behavior model and the model of battery charge were combined into one model, which is shown in Figure 5 and is represented by a Continuous-Time Markov Chains.An important feature of the new model is the impossibility of transition to "Rebirth" state from "Active" and "Low Power" states.Given the matrix of transition rates between states and the probabilities vector of the system in different states at the initial time, we can calculate the probabilities vector at any subsequent time (1): The main goal of the model considered in this paper is to predict the optimal time to perform the rejuvenation procedure.Since the time distribution in models based on the Continuous-Time Markov Chain is exponential, the average transition time to a certain state is determined by the formula: By calculating a system of differential equations (2) of model for different λ YR values, the optimal rejuvenation time can be determined when the probability of being in the Active" and "Low Power" states is the lowest, i.e., when the rejuvenation procedure will not interfere with the user and will be performed until the battery is fully discharged.

EXPERIMENTS
To verify and analyze the proposed model of software aging with rejuvenation, the system of differential equations (2) was calculated by the 4th order Runge-Kutta method.The calculation of the system of equations for the original model [15] is also performed and it allows us to compare the values of 1/ λ YR of both models and deter-mine the influence of the factor on forecasting the rejuvenation procedure.Transition rates between all states of the system are approximate values which allow to simulate aging process and perform experimental calculations.
In work [15] two periods of user activity are considered, namely day (from 9 a.m.till 10 p.m.) and night (from 10 p.m. till 9 a.m.).Rates of transitions between "Active" and "Sleep" states for these intervals can be determined based on the collected user activity data.For example, you can divide the day into 15-minute time intervals, which will be denoted as "Active" or "Sleep" depending on the average number of events of the device sensors collected over many previous days [15].In this study, 1 minute is used as a unit of time.The period of user activity in the day for analysis has no fundamental differences, so this paper assumes the verification of the model for the day period.Thus, we assume that the transition rates of λ AS and λ SA are 0.05 (average time of phone usage before entering sleep state is 20 minutes) and 0.02 (average time in sleep state is 50 minutes), respectively.
Transition rates from "Young" to "Old" state and from "Old" to "Recovering" state in [15] are considered equal and are based on increasing the average delay time of the user interface.These transition rates in a real system can be calculated based on the observed aging-related metrics, which show a performance degradation or an increase usage of system resources.However, in this paper, it is assumed that the transitions from "Young" to "Old" and from "Old" to "Recovering" last 100 hours, so λ YO = λ ORe = 0.00017.Rejuvenation procedure and recovery of the system after aging can be considered as a process of device rebooting, which lasts about one minute, so λ ReY = λ RY = 1.
Transitions rates of battery charge model can be obtained based on remaining charge predictions at the time of calculations on the mobile device.In this work, it is assumed that the discharge time of the battery to a low level, and then to complete shutdown is 24 and 1 hour, respectively, i.e., λ SpLp = 0.0007, λ LpOp = 0.017.The time required to charge the battery to full level is assumed to be equal to 2 hours, i.e., λ LpSp = 0.0083.

RESULTS
Calculations results of differential equations system of the original model without considering the battery charge are shown in Figure 6.Fig. 6 (a) shows the probability of being in the state AY, and Fig. 6 (b) shows the sum of the probabilities of being in the RA and ARe states.
Figure 7 shows the results of calculations of model considering the battery charge.Figure 8 shows the probability that the mobile device is in a discharged state.The result of original aging model calculating (Fig. 6  (b)) shows that the optimal time to perform the rejuvenation procedure is 1 / λ yr = 1620 minutes (27 hours), i.e., when the sum of the probabilities of being in the RA and ARe states is the lowest.In turn, the calculation of the model which considers the battery charge (Fig. 7 (b)) show that the rejuvenation procedure can be performed in 350 minutes (5 hours 50 minutes) after device start up.Comparing the results of calculations of both models, we can conclude that factor of battery charge has a significant impact on predicting the time of the rejuvenation procedure.
The idea of considering the battery charge factor is that performing a rejuvenation procedure is inefficient and impractical at a time when the battery level is critically low, or device is completely discharged.The formulated hypothesis is confirmed by the obtained calculations.If we do not consider the time to full discharge of the battery, the forecast of the original model is impractical, because after 27 hours (Fig. 8) the device is more likely to be discharged.The influence of the battery discharge can also be observed on Fig. 7 (b) where 1/ λ yr >27.
It is worth noting that planning the rejuvenation procedure based on the battery level may not necessarily lead to performing this procedure at the selected time (5 hours 50 minutes), because at this time the system may still be in the state "Young", and the battery may be recharged.Therefore, it is worth considering additional checks and new calculations of the model at scheduled time.
It is also necessary to note the reasons why the probabilities of being in the states "Recovering" and "Rebirth" are in the range of 10 -7 .These two states are proce-dures that perform rebooting and restoring the system, so after performing them, the system immediately goes to the next state.At the same time, the probability of "Rebirth" is lower, because this state can be performed only if the mobile device is not used by the user and has a high battery charge.A high probability of being in these states would mean that the system is constantly or often in the process of rebooting, which is unacceptable for the user of the mobile device.

CONCLUSIONS
The paper describes software aging and rejuvenation model for mobile device which considers the factor of battery charge level.
The scientific novelty of the proposed mathematical model is to consider the new factor of battery charge level.The developed model is represented by a Continuous-Time Markov Chain, which combines the user behavior model, the model of software aging with the rejuvenation procedure, as well as the battery charge model.
The practical significance of using the battery level in the model to predict the rejuvenation time is to consider real mobile device usage scenarios, in particular, rejuvenation performing will not be effective or will not be performed at all in cases when the mobile device may have a very low charge or be completely discharged.In turn, early rejuvenation can delay the transition to a low battery level state, as rejuvenation will reduce the system workload and power consumption.

Figure 1 -
Figure 1 -Mobile device usage model

Figure 2 -
Figure 2 -Software aging model with rejuvenation procedure

Figure 3 -
Figure 3 -General model of battery charge

Figure 4 -
Figure 4 -Simplified model of battery charge

Figure 5 -
Figure 5 -Continuous-Time Markov Chain for the model of software aging and rejuvenation which takes into account the battery charge

Fig. 7 aFigure 6 -Figure 7 - 4 ©
Figure 6 -Calculations results of the model which doesn't take into account the battery charge: а -the probability of state AY; b -the total probability of states RA and ARe

Figure 8 -
Figure 8 -The probability of state Op6 DISCUSSIONFigures6 (a) and7 (a)  show that as the time to the rejuvenation procedure increases, the probability of system being in a young state decreases both battery and without taking it into account.The result of original aging model calculating (Fig.6 (b)) shows that the optimal time to perform the rejuvenation procedure is 1 / λ yr = 1620 minutes (27 hours), i.e., when the sum of the probabilities of being in the RA and ARe states is the lowest.In turn, the calculation of the model which considers the battery charge (Fig.7 (b)) show that the rejuvenation procedure can be performed in 350 minutes (5 hours 50 minutes) after device start up.Comparing the results of calculations of both models, we can conclude that factor of battery charge has a significant impact on predicting the time of the rejuvenation procedure.The idea of considering the battery charge factor is that performing a rejuvenation procedure is inefficient and impractical at a time when the battery level is critically low, or device is completely discharged.The formulated hypothesis is confirmed by the obtained calculations.If we do not consider the time to full discharge of the battery, the forecast of the original model is impractical, because after 27 hours (Fig.8) the device is more likely to be discharged.The influence of the battery discharge can also be observed on Fig.7 (b) where 1/ λ yr >27.It is worth noting that planning the rejuvenation procedure based on the battery level may not necessarily lead to performing this procedure at the selected time (5 hours 50 minutes), because at this time the system may still be in the state "Young", and the battery may be recharged.Therefore, it is worth considering additional checks and new calculations of the model at scheduled time.It is also necessary to note the reasons why the probabilities of being in the states "Recovering" and "Rebirth" are in the range of 10 -7 .These two states are proce- УДК 004.93 МОДЕЛЬ ПРОЦЕСУ СТАРІННЯ ТА ОМОЛОДЖЕННЯ ПРОГРАМНОГО ЗАБЕЗПЕЧЕННЯ ДЛЯ ОПЕРАЦІЙНОЇ СИСТЕМИ ANDROID З УРАХУВАННЯМ ФАКТОРУ РІВНЯ ЗАРЯДУ БАТАРЕЇ Яковина В. С. -д-р техн.наук, професор, професор кафедри Систем штучного інтелекту, Національний університет «Львівська політехніка», Львів, Україна; Факультет математики та комп'ютерних наук, Вармінсько-Мазурський Університет в Ольштині, Польща.Угриновський Б. В. -асистент кафедри Програмного забезпечення, Національний університет «Львівська політехніка», Львів, Україна.АНОТАЦІЯ Актуальність.Особливість мобільних систем полягає в їх залежності від рівня заряду батареї, що є важливим чинником під час планування різного роду процесів, зокрема виконання процедури омолодження програмного забезпечення для зменшення впливу ефектів старіння цього програмного забезпечення.Мета роботи.Розроблення моделі процесу старіння та омолодження програмного забезпечення для операційної системи Android з урахуванням чинника рівня заряду батареї.