WO2012072550A1 - Method for the functional optimisation of the sequence of a program in an embedded system - Google Patents

Method for the functional optimisation of the sequence of a program in an embedded system Download PDF

Info

Publication number
WO2012072550A1
WO2012072550A1 PCT/EP2011/071126 EP2011071126W WO2012072550A1 WO 2012072550 A1 WO2012072550 A1 WO 2012072550A1 EP 2011071126 W EP2011071126 W EP 2011071126W WO 2012072550 A1 WO2012072550 A1 WO 2012072550A1
Authority
WO
WIPO (PCT)
Prior art keywords
stack
address
program
embedded system
threshold value
Prior art date
Application number
PCT/EP2011/071126
Other languages
German (de)
French (fr)
Inventor
Ralph Mader
Rudolf Bauer
Maximilian Riepl
Original Assignee
Continental Automotive Gmbh
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Continental Automotive Gmbh filed Critical Continental Automotive Gmbh
Publication of WO2012072550A1 publication Critical patent/WO2012072550A1/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5016Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/504Resource capping
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Definitions

  • the invention relates to a method for optimizing the operation of a program in an embedded system, the program to its expiration uses a stack of the embedded system, which is formed by a delimited address range in a memory of the embedded system and its size by an address range with a lower (start) address and an upper (end) address is defined.
  • Known methods usually perform static analyzes of the program. These are based on the compiler-generated assembler or ob ect code. Here, so-called call trees are created, which call trees of program parts (radio tions) of the program. In this case, the consumption of the stack of each program part is added up.
  • a disadvantage of this approach is that dynamic effects, such as interrupts by external events, a long-term behavior or a task change of the operating system of the embedded system, can not be detected. It is only possible to carry out a worst-case analysis of the captured call trees. It is determined which consumption of the stack can occur maximum.
  • the dynamic load of the stack can be determined by the so-called stack pattern method.
  • stack pattern method the address space reserved for the stack memory is pre-initialized with a predetermined pattern (ie, a known date).
  • the depth of penetration of the used Stapelbe ⁇ realm is determined in the predefined pattern then during the course of the program to be checked cyclically. It can be used to check how much of the stack was consumed. Again, there is the problem that it is not possible to determine which program part of the program has caused the consumption of the stack.
  • the invention provides a method for optimizing the operation of a program in an embedded system, wherein the program uses a stack of the embedded system, which is formed by a delimited address range in a memory of the embedded system and its size by an address range of a lower (Start) address and an upper (end) address is defined.
  • a threshold value for the stack is defined according to the invention, which is repre sented ⁇ by an address of the stack in which the address is smaller than the upper address of the address range of the stack.
  • a predefined function is called which reads out the contents of the stack.
  • the predefined function is eg a so-called trap, ie an error function with predefined functionality.
  • program part is also known as a function of the program. Based on the information about the calling part then an optimization of the program and / or the embedded system is performed.
  • the procedure described makes it possible to reduce the consumption of the stack in an embedded system taking into account assessment of all real-world conditions, such as unpredictable events, long-term behavior, etc., and, if necessary, to optimize the program and / or the embedded system.
  • a Call Tree is determined (a so-called. Call tree of Pro ⁇ program parts of the program) from the content of the stack, wherein the part is determined from the Call Tree, which calls the predefined function of the embedded system.
  • the value of the current stack pointer and the address of the called function set ⁇ (Program Counter) and, optionally, a time stamp of the function call, is determined. If this information is determined in a test environment ⁇ temporarily stored and evaluated later, the dynamic behavior of the program can be found in the embedded system regarding the use of the stack. On the basis of this information , weak points in the program or in the embedded system can be identified and remedied. From this data, both the consumption of the stack as a function of time and the call tree of those program parts can be rekon ⁇ strued, which have led to this observed consumption of the stack.
  • the call of the predefined function can also be seen as an indication that the stack space "limited" by the threshold value is not dimensioned large enough
  • expedient refinement after the call to the predefined function and the determination of the contents of the stack memory, the threshold value with a new address of the threshold moving closer to the upper address of the stack, and then re-running the program
  • the embedded system checks whether by a program part when reaching the new threshold again the default function is called. Based on this iterative approach, it can be determined which (maximum) area of the stack is actually used by the program running in the embedded system. A possible optimization may then be to increase the stack by changing the upper or lower address.
  • An increase in the address space of the stack may become necessary if the threshold value assumes the upper address of the original stack area and the specified function is called upon a re-run of the program in the embedded system.
  • a call to the predetermined function would indicate that the size of the stack for the expiry of the pre ⁇ given program is not sufficient. If, on the other hand, at a threshold value defined for the first time which is smaller than the upper address of the stack area, it is found that the predetermined function is not called when the program is running, the address space of the stack could also be reduced. The freed address space can then be used in the embedded system for other storage purposes.
  • An alternative possibility of optimization is to make a change in the interleaving depth of a number of interdependent (program) parts, wherein the change in the interleaving depth of interdependent program parts is preferably realized by a compiler.
  • the optimization comprises a change of the process in one or more parts of the program.
  • Fig. 1 is a schematic representation of a flow chart of the method according to the invention
  • Figure 2 is a schematic representation of the consumption of a stack in an embedded system over time.
  • the inventive method for optimizing the operation of a program in an embedded system is based on obtaining a reliable indication of the consumption of a stack of the embedded system under real conditions.
  • the stack is often formed by a delineated address space in a memory of the embedded system.
  • the size of the stack is initially defined by an address range having a lower (start) address and an upper (end) address.
  • elements or data can only be placed on top of the stack from above, ie beginning with the start address, and read only from there. This means that items are stacked on top of each other and taken off the stack in reverse order. This principle is called last-in-first-out principle.
  • a threshold value is represented by an address of the stack whose address is smaller than the upper address of the address range of the stack.
  • Fig. 1 shows the basic sequence of the invention
  • a threshold value SW for the stack is initially defined.
  • the threshold value SW for the stack is initially defined.
  • Threshold selected to be near the top (end) address of the stack At the end of the program in the embedded system is monitored whether the program reaches the repre ⁇ sented by the threshold address using the stack. In this case (step S2) becomes a predefined function of the embedded system called (step S3).
  • the predefined function is an error function with predefined functionality and is called a trap.
  • step S5 a call tree (a)
  • step S7 and S8 information is thus extracted and stored which represent the previously highest, used address of the stack (step S7) and the call tree CT, which is temporarily stored in step S8 for further evaluation.
  • step S6 after the triggering of a trap, the threshold value SW is increased, but this is not increased above the upper (end) address of the stack.
  • the increase of the threshold value SW ensures that the threshold value checked in step S2 is set to the now valid threshold value. This ends a loop of the procedure (end E).
  • the flow of the program in the embedded system can now begin again. If the now valid threshold value SW reached in step S2, in turn, as a new call of the prede ⁇ -defined function in step S3, etc. As a result, it can be determined whether the reserved for the execution of the program stack is sufficiently large. This is the case if the threshold is located below the upper (end) address, even after repeated increases, and no call is made to the predefined function.
  • an optimization could be to reduce the top (end) address of the stack, eg to the address of the threshold or at least one address higher. If, on the other hand, the upper (end) address is reached by the threshold value, without the program being able to run to its end as intended, then either the size of the stack memory is to be increased, for example by increasing the upper (end) address.
  • the optimization could include changing the nesting depth of the number of interdependent program parts. This is preferably done automatically by a compiler. Another optimization is to make a change to the process on one or more parts of the program, preferably manually by the programmer of the program.
  • the stack consumption can be determined specifically for specific scenarios. For example, the maximum stack consumption of individual program parts or the entire program can be determined. Furthermore, the call tree can be determined at the time when the valid threshold value was reached by the program and the predefined function was executed.
  • a minimum, maximum and average stack consumption of a single operating system process, including the call tree can be determined. This course is illustrated by way of example in FIG. 1, in which the stack usage SU is shown over the time t.
  • Stack consumption of a first process is shown as a function of the call of its functions f1, f2, f3, f4 and as a function of interrupt events il, i2.
  • Process 1 the stack consumption of a first process
  • Process 2 the stack consumption of a second process
  • Total a total stack consumption
  • the method of the invention takes into account real conditions, it is possible , to determine the stack usage of the Pro ⁇ program of the embedded system taking into account all existing in the real operating conditions, such as events, long-term behavior, etc., and to optimize the program or the embedded system if necessary.

Abstract

The invention relates to a method for the functional optimisation of the sequence of a program in an embedded system. The program uses, for the sequence thereof, a stack of the embedded system, which is formed by a limited address range in a memory of the embedded system, and the size of which is defined by an address range having a lower address and an upper address. In the method according to the invention, a threshold value (SW) is defined for the stack, which is represented by an address of the stack, wherein said address is less than the upper address of the address range of the stack. Monitoring takes place to determine whether the program running on the embedded system using the stack reaches the address represented by the threshold value (SW). When the threshold value (SW) is reached, a predefined function is called up, by means of which the content of the stack is read out. It is determined from the content of the stack what part of the program has caused the predefined function to be called up. Finally, optimisation of the program and/or of the embedded system is carried out using the information about the part calling up.

Description

Beschreibung description
Verfahren zur Funktionsoptimierung des Ablaufs eines Programms in einem eingebetteten System Method for optimizing the operation of a program in an embedded system
Die Erfindung betrifft ein Verfahren zur Funktionsoptimierung des Ablaufs eines Programms in einem eingebetteten System, wobei das Programm zu dessen Ablauf einen Stapelspeicher des eingebetteten Systems benutzt, der durch einen abgegrenzten Adressbereich in einem Speicher des eingebetteten Systems gebildet ist und dessen Größe durch einen Adressbereich mit einer unteren ( Start- ) Adresse und einer oberen (Ende- ) Adresse definiert ist. The invention relates to a method for optimizing the operation of a program in an embedded system, the program to its expiration uses a stack of the embedded system, which is formed by a delimited address range in a memory of the embedded system and its size by an address range with a lower (start) address and an upper (end) address is defined.
Beim Ablauf von Programmen in einem eingebetteten System (sog. Embedded Software System) ist es notwendig, den Verbrauch des Stapelspeichers durch das Programm während des Betriebs unter Kontrolle zu haben. Ein unkontrollierter Überlauf des Sta¬ pelspeichers könnte zu einem Reset des eingebetteten Systems mit einem unvorhersehbaren Fehlverhalten zur Folge haben. Um das Verhalten des Programms hinsichtlich der Verwendung des Stapelspeichers bei dessen Ablauf kontrollieren zu können, ist es notwendig, bei der Entwicklung des Programms eine verlässliche Messung des Verbrauchs des Stapelspeichers unter realen Be¬ dingungen durchzuführen. Dabei ist zu berücksichtigen, dass diese realen Bedingungen in der Regel dynamisch und When running programs in an embedded system (so-called embedded software system), it is necessary to have the program's consumption of the stack under control during operation. An uncontrolled overflow of Sta ¬ pelspeichers could have a reset of the embedded system with an unpredictable result wrongdoing. In order the behavior of the program to control at the end of which as regards the use of the stack, it is necessary to perform a reliable measurement of the consumption of the stack under real Be ¬ conditions in the development of the program. It should be remembered that these real conditions are usually dynamic and
nicht-deterministisch sind, beispielsweise aufgrund are non-deterministic, for example, due
nicht-vorhersagbarer Ereignisse, welche zu einem unbekannten, beliebigen Zeitpunkt eintreten und einen Interrupt des eingebetteten Systems auslösen können. Da Interrupts erheblichen Einfluss auf das Echtzeit-Verhalten des auf dem eingebetteten System ablaufenden Programms und damit den Verbrauch des Stapelspeichers haben können, müssen Interrupts bei der Ve¬ rifikation des Programmablaufs berücksichtigt werden. unpredictable events that can occur at an unknown, arbitrary time and trigger an interrupt of the embedded system. Since interrupts significant impact on the real-time behavior of the program running on the embedded system program and thus can have the use of the stack must be considered when interrupts Ve ¬ rifikation program flow.
Bekannte Verfahren führen in der Regel statische Analysen des Programms durch. Diese basieren auf dem von einem Compiler generierten Assembler oder Ob ekt-Code . Hierbei werden sog. Call Trees erstellt, welche Aufrufbäume von Programmteilen (Funk- tionen) des Programms darstellen. Dabei wird der Verbrauch des Stapelspeichers jedes Programmteils aufaddiert. Ein Nachteil dieser Vorgehensweise besteht darin, dass dynamische Effekte, wie z.B. Interrupts durch externe Events, ein Langzeitverhalten oder ein Task-Wechsel des Betriebssystems des eingebetteten Systems, nicht erfasst werden können. Es ist lediglich möglich, für die erfassten Call Trees eine Worst-Case-Betrachtung durchzuführen. Dabei wird ermittelt, welcher Verbrauch des Stapelspeichers maximal auftreten kann. Known methods usually perform static analyzes of the program. These are based on the compiler-generated assembler or ob ect code. Here, so-called call trees are created, which call trees of program parts (radio tions) of the program. In this case, the consumption of the stack of each program part is added up. A disadvantage of this approach is that dynamic effects, such as interrupts by external events, a long-term behavior or a task change of the operating system of the embedded system, can not be detected. It is only possible to carry out a worst-case analysis of the captured call trees. It is determined which consumption of the stack can occur maximum.
Die dynamische Auslastung des Stapelspeichers (sog. Stack) kann durch die sog. Stack-Pattern-Methode ermittelt werden. Es besteht jedoch keine Möglichkeit, einen Rückschluss auf den, die Stapelspeicher-Auslastung verursachenden Programmteil zurückzuschließen. Bei der Stack-Pattern-Methode wird der für den Stapelspeicher reservierte Adressbereich mit einem vorgegebenen Pattern (d.h. einem bekannten Datum) beschrieben (vorinitialisiert) . Anschließend wird während des Ablaufs des zu prüfenden Programms zyklisch die Eindringtiefe des genutzten Stapelbe¬ reichs in das vordefinierte Pattern ermittelt. Anhand dessen kann überprüft werden, wie viel von dem Stapelspeicher verbraucht wurde. Auch hierbei besteht das Problem, dass nicht feststellbar ist, welcher Programmteil des Programms den Verbrauch des Stapelspeichers verursacht hat. The dynamic load of the stack (so-called stack) can be determined by the so-called stack pattern method. However, there is no way to infer a conclusion about the part of the program that causes the stack memory usage. In the stack pattern method, the address space reserved for the stack memory is pre-initialized with a predetermined pattern (ie, a known date). The depth of penetration of the used Stapelbe ¬ realm is determined in the predefined pattern then during the course of the program to be checked cyclically. It can be used to check how much of the stack was consumed. Again, there is the problem that it is not possible to determine which program part of the program has caused the consumption of the stack.
Da mit den bekannten Verfahren eine Prüfung des eingebetteten Systems unter Realbedingungen nicht möglich ist, ist auch keine präzise Vorhersage des Verhaltens des Programms beim Ablauf in dem eingebetteten System hinsichtlich des tatsächlichen Verbrauchs des Stapelspeichers möglich. Es kann deshalb zu dem eingangs erwähnten, unvorhersehbaren Fehlverhalten des eingebetteten Systems kommen. Since it is not possible to test the embedded system under real conditions with the known methods, it is not possible to accurately predict the behavior of the program when running in the embedded system with regard to the actual consumption of the stack. It can therefore come to the aforementioned, unpredictable misconduct of the embedded system.
Es ist daher Aufgabe der vorliegenden Erfindung, ein Verfahren anzugeben, mit dem eine verbesserte Funktionsoptimierung des Ablaufs eines Programms in einem eingebetteten System ermöglicht wird, so dass im späteren realen Betrieb ein Überlauf eines Stapelspeichers des eingebetteten Systems mit hoher Sicherheit vermieden werden kann. It is therefore an object of the present invention to provide a method by which an improved function optimization of the flow of a program in an embedded system is made possible, so that in later real operation an overflow of a Stacked memory of the embedded system can be avoided with high security.
Diese Aufgabe wird gelöst durch ein Verfahren gemäß den Merkmalen des Patentanspruches 1. Vorteilhafte Ausgestaltungen ergeben sich aus den abhängigen Patentansprüchen. This object is achieved by a method according to the features of claim 1. Advantageous embodiments will be apparent from the dependent claims.
Die Erfindung schafft ein Verfahren zur Funktionsoptimierung des Ablaufs eines Programms in einem eingebetteten System, wobei das Programm zu dessen Ablauf einen Stapelspeicher des eingebetteten Systems benutzt, der durch einen abgegrenzten Adressbereich in einem Speicher des eingebetteten Systems gebildet ist und dessen Größe durch einen Adressbereich einer unteren ( Start- ) Adresse und einer oberen (Ende- ) Adresse definiert ist. Bei dem Verfahren wird erfindungsgemäß ein Schwellwert für den Stapelspeicher definiert, der durch eine Adresse des Stapelspeichers reprä¬ sentiert ist, wobei die Adresse kleiner ist als die obere Adresse des Adressbereichs des Stapelspeichers. Weiter wird überwacht, ob das auf dem eingebetteten System ablaufende Programm unter Nutzung des Stapelspeichers die durch den Schwellwert reprä¬ sentierte Adresse erreicht. Nutzung des Stapelspeichers bedeutet hierbei, dass in üblicher Weise beginnend bei der unteren Adresse Daten in den Stapelspeicher geschrieben werden, wobei Daten nur oben auf den Stapel gelegt und auch von dort wieder gelesen werden können. Beim Erreichen des Schwellwerts wird eine vordefinierte Funktion aufgerufen, durch die der Inhalt des Stapelspeichers ausgelesen wird. Die vordefinierte Funktion ist z.B. ein sog. Trap, d.h. eine Fehler-Funktion mit vordefinierter Funktionalität. Anschließend wird aus dem Inhalt des Stapelspeichers ermittelt, welcher Teil des Programms (Programmteil) den Aufruf der vordefinierten Funktion ausgelöst hat. Ein solcher Programmteil ist auch als Funktion des Programms bekannt. Anhand der Information über den aufrufenden Teil wird anschließend eine Optimierung des Programms und/oder des eingebetteten Systems durchgeführt. The invention provides a method for optimizing the operation of a program in an embedded system, wherein the program uses a stack of the embedded system, which is formed by a delimited address range in a memory of the embedded system and its size by an address range of a lower (Start) address and an upper (end) address is defined. In the method, a threshold value for the stack, is defined according to the invention, which is repre sented ¬ by an address of the stack in which the address is smaller than the upper address of the address range of the stack. Next, whether running on the embedded system program reaches the repre ¬ sented by the threshold address using the stack is monitored. Use of the stack means here that in the usual way starting at the lower address data is written to the stack, with data placed only on top of the stack and can be read from there again. Upon reaching the threshold, a predefined function is called which reads out the contents of the stack. The predefined function is eg a so-called trap, ie an error function with predefined functionality. Then it is determined from the contents of the stack which part of the program (program part) has triggered the call of the predefined function. Such a program part is also known as a function of the program. Based on the information about the calling part then an optimization of the program and / or the embedded system is performed.
Durch das beschriebene Vorgehen ist es möglich, den Verbrauch des Stapelspeichers in einem eingebetteten System unter Berück- sichtigung aller im Realbetrieb herrschenden Randbedingungen, wie z.B. nicht vorhersagbare Events, Langzeitverhalten usw., zu ermitteln, und bei Bedarf das Programm und/oder das eingebettete System zu optimieren. The procedure described makes it possible to reduce the consumption of the stack in an embedded system taking into account assessment of all real-world conditions, such as unpredictable events, long-term behavior, etc., and, if necessary, to optimize the program and / or the embedded system.
Gemäß einer zweckmäßigen Ausgestaltung wird aus dem Inhalt des Stapelspeichers ein Call Tree (ein sog. Aufrufbaum von Pro¬ grammteilen des Programms) ermittelt, wobei aus dem Call Tree derjenige Teil ermittelt wird, welcher die vordefinierte Funktion des eingebetteten Systems aufruft. Bei Kenntnis desjenigen Programmteils, welcher beim Ablauf des Programms zum Aufruf der vordefinierten Funktion führt, ist es möglich, Probleme im Programmablauf festzustellen und diese zu besei¬ tigen . According to an expedient embodiment, a Call Tree is determined (a so-called. Call tree of Pro ¬ program parts of the program) from the content of the stack, wherein the part is determined from the Call Tree, which calls the predefined function of the embedded system. With knowledge of that part of the program which executes during execution of the program to call the predefined function, it is possible to detect problems in the program sequence and this to besei ¬ term.
Zweckmäßigerweise werden aus dem Inhalt des Stapelspeichers der Wert des aktuellen Stack-Pointers und die Adresse der aufge¬ rufenen Funktion (Program Counter) und optional ein Zeitstempel des Funktionsaufrufs, ermittelt. Werden diese in einer Test¬ umgebung ermittelten Informationen zwischengespeichert und später ausgewertet, so kann das dynamische Verhalten des Programms in dem eingebetteten System hinsichtlich der Nutzung des Stapelspeichers festgestellt werden. Anhand dieser In¬ formationen können Schwachstellen im Programm oder in dem eingebetteten System erkannt und behoben werden. Aus diesen Daten kann sowohl der Verbrauch des Stapelspeichers als Funktion der Zeit als auch der Call Tree derjenigen Programmteile rekon¬ struiert werden, welche zu diesem festgestellten Verbrauch des Stapelspeichers geführt haben. Appropriately, from the contents of the stack the value of the current stack pointer and the address of the called function set ¬ (Program Counter) and, optionally, a time stamp of the function call, is determined. If this information is determined in a test environment ¬ temporarily stored and evaluated later, the dynamic behavior of the program can be found in the embedded system regarding the use of the stack. On the basis of this information , weak points in the program or in the embedded system can be identified and remedied. From this data, both the consumption of the stack as a function of time and the call tree of those program parts can be rekon ¬ strued, which have led to this observed consumption of the stack.
Der Aufruf der vordefinierten Funktion kann auch als Indiz dafür gesehen werden, dass der durch den Schwellwert „begrenzte" Stapelspeicher nicht groß genug dimensioniert ist. In einer weiteren, zweckmäßigen Ausgestaltung wird nach dem Aufrufen der vordefinierten Funktion und der Ermittlung des Inhalts des Stapelspeichers der Schwellwert erhöht, wobei eine neue Adresse des Schwellwerts näher an die obere Adresse des Stapelspeichers rückt. Anschließend wird bei einem erneuten Ablauf des Programms in dem eingebetteten System überprüft, ob durch einen Programmteil beim Erreichen des neuen Schwellwerts wieder die vorgegebene Funktion aufgerufen wird. Anhand dieser iterativen Vorgehensweise kann ermittelt werden, welcher (maximale) Bereich des Stapelspeichers tatsächlich durch das in dem eingebetteten System ablaufende Programm genutzt wird. Eine mögliche Optimierung kann dann darin bestehen, eine Vergrößerung des Stapelspeichers durch Änderung der oberen oder unteren Adresse vorzunehmen. Eine Vergrößerung des Adressraums des Stapelspeichers kann dann notwendig werden, wenn der Schwellwert die obere Adresse des ursprünglichen Stapelbereichs annimmt und bei einem erneuten Ablauf des Programms in dem eingebetteten System die vorgegebene Funktion aufgerufen wird. Ein Aufruf der vorgegebenen Funktion würde dann signalisieren, dass die Größe des Stapelspeichers für den Ablauf des vorge¬ gebenen Programms nicht ausreichend ist. Wurde andererseits bei einem erstmals definierten Schwellwert, der kleiner ist als die obere Adresse des Stapelbereichs, festgestellt, dass beim Ablauf des Programms die vorgegebene Funktion nicht aufgerufen wird, so könnte der Adressraum des Stapelspeichers auch verkleinert werden. Der frei werdende Adressraum kann dann in dem eingebetteten System für andere Speicherzwecke verwendet werden. Eine alternative Möglichkeit der Optimierung besteht darin, eine Änderung der Verschachtelungstiefe einer Anzahl an voneinander abhängigen ( Programm- ) Teilen vorzunehmen, wobei die Änderung der Verschachtelungstiefe der voneinander abhängigen Programmteile vorzugsweise durch einen Compiler realisiert wird. In einer weiteren Ausgestaltung umfasst die Optimierung eine Änderung des Ablaufs an einer oder mehreren Teilen des Programms. The call of the predefined function can also be seen as an indication that the stack space "limited" by the threshold value is not dimensioned large enough In a further, expedient refinement, after the call to the predefined function and the determination of the contents of the stack memory, the threshold value with a new address of the threshold moving closer to the upper address of the stack, and then re-running the program In the embedded system checks whether by a program part when reaching the new threshold again the default function is called. Based on this iterative approach, it can be determined which (maximum) area of the stack is actually used by the program running in the embedded system. A possible optimization may then be to increase the stack by changing the upper or lower address. An increase in the address space of the stack may become necessary if the threshold value assumes the upper address of the original stack area and the specified function is called upon a re-run of the program in the embedded system. A call to the predetermined function would indicate that the size of the stack for the expiry of the pre ¬ given program is not sufficient. If, on the other hand, at a threshold value defined for the first time which is smaller than the upper address of the stack area, it is found that the predetermined function is not called when the program is running, the address space of the stack could also be reduced. The freed address space can then be used in the embedded system for other storage purposes. An alternative possibility of optimization is to make a change in the interleaving depth of a number of interdependent (program) parts, wherein the change in the interleaving depth of interdependent program parts is preferably realized by a compiler. In a further embodiment, the optimization comprises a change of the process in one or more parts of the program.
Die Erfindung wird nachfolgend näher anhand eines Ausfüh¬ rungsbeispiels in der Zeichnung erläutert. Es zeigen: The invention is explained in more detail below with reference to an exporting ¬ approximately embodiment in the drawing. Show it:
Fig. 1 eine schematische Darstellung eines Ablaufdiagramms des erfindungsgemäßen Verfahrens, und Fig. 2 eine schematische Darstellung des Verbrauchs eines Stapelspeichers in einem eingebetteten System über die Zeit . Das erfindungsgemäße Verfahren zur Funktionsoptimierung des Ablaufs eines Programms in einem eingebetteten System basiert darauf, eine verlässliche Angabe über den Verbrauch eines Stapelspeichers des eingebetteten Systems unter Re- al-Bedingungen zu erhalten. Bei einem solchen eingebetteten System ist der Stapelspeicher häufig durch einen abgegrenzten Adressbereich in einem Speicher des eingebetteten Systems gebildet. Die Größe des Stapelspeichers ist initial durch einen Adressbereich mit einer unteren ( Start- ) Adresse und einer oberen (Ende- ) Adresse definiert. In einer dem Fachmann bekannten Weise können Elemente oder Daten dabei nur von oben, d.h. beginnend mit der Start-Adresse, auf den Stapel gelegt und auch nur von dort wieder gelesen werden. Dies bedeutet, Elemente werden übereinander gestapelt und in umgekehrter Reihenfolge vom Stapel genommen. Dieses Prinzip wird Last In-First Out-Prinzip genannt. Fig. 1 is a schematic representation of a flow chart of the method according to the invention, and Figure 2 is a schematic representation of the consumption of a stack in an embedded system over time. The inventive method for optimizing the operation of a program in an embedded system is based on obtaining a reliable indication of the consumption of a stack of the embedded system under real conditions. In such an embedded system, the stack is often formed by a delineated address space in a memory of the embedded system. The size of the stack is initially defined by an address range having a lower (start) address and an upper (end) address. In a manner known to those skilled in the art, elements or data can only be placed on top of the stack from above, ie beginning with the start address, and read only from there. This means that items are stacked on top of each other and taken off the stack in reverse order. This principle is called last-in-first-out principle.
Bei der Durchführung einer Messung des Verbrauchs des Stapelspeichers (sog. Stack-Verbrauch) können mit dem erfindungsgemäßen Verfahren dynamische und nicht-deterministische Ereignisse berücksichtigt werden. Das Verfahren basiert auf der Definition von Schwellwerten für den Stapelspeicher, wobei ein Schwellwert durch eine Adresse des Stapelspeichers repräsentiert ist, dessen Adresse kleiner ist als die obere Adresse des Adressbereichs des Stapelspeichers. Fig. 1 zeigt den prinzipiellen Ablauf des erfindungsgemäßenWhen carrying out a measurement of the consumption of the stack (so-called stack consumption), dynamic and non-deterministic events can be taken into account with the method according to the invention. The method is based on the definition of thresholds for the stack memory, wherein a threshold value is represented by an address of the stack whose address is smaller than the upper address of the address range of the stack. Fig. 1 shows the basic sequence of the invention
Verfahrens. Mit S ist der Start des Verfahrens gekennzeichnet. In einem Verfahrensschritt Sl wird zunächst ein Schwellwert SW für den Stapelspeicher definiert. Vorzugsweise wird der Process. S marks the start of the process. In a method step S1, a threshold value SW for the stack is initially defined. Preferably, the
Schwellwert derart gewählt, dass dieser nahe der oberen (En- de-)Adresse des Stapelspeichers ist. Beim Ablauf des Programms in dem eingebetteten System wird überwacht, ob das Programm unter Nutzung des Stapelspeichers die durch den Schwellwert reprä¬ sentierte Adresse erreicht. In diesem Fall (Schritt S2) wird eine vordefinierte Funktion des eingebetteten Systems aufgerufen (Schritt S3) . Die vordefinierte Funktion ist eine Feh¬ ler-Funktion mit vordefinierter Funktionalität und wird als Trap bezeichnet . Threshold selected to be near the top (end) address of the stack. At the end of the program in the embedded system is monitored whether the program reaches the repre ¬ sented by the threshold address using the stack. In this case (step S2) becomes a predefined function of the embedded system called (step S3). The predefined function is an error function with predefined functionality and is called a trap.
Durch den Aufruf der vorgegebenen Funktion werden gemäß den Schritten S4 und S5 der Inhalt des Stapelspeichers ermittelt, um festzustellen, welcher Programmteil des Programms den Aufruf der vordefinierten Funktion ausgelöst hat. Weiter wird gemäß Schritt S5 aus dem Inhalt des Stapelspeichers ein Call Tree (einBy calling the predetermined function, the content of the stack is determined according to steps S4 and S5 to determine which program part of the program has triggered the call of the predefined function. Further, in step S5, a call tree (a
Aufrufbaum) ermittelt, wobei insbesondere aus diesem festge¬ stellt werden kann, welcher die vordefinierte Funktion auf¬ gerufen hat. In den Schritten S7 und S8 werden somit Informationen extrahiert und gespeichert, welche die bislang höchste, genutzte Adresse des Stapelspeichers repräsentieren (Schritt S7) sowie der Call Tree CT, der in Schritt S8 zur weiteren Auswertung zwischengespeichert wird. Call tree), whereby Festge particular this can be ¬ represents which has called the predefined function on ¬. In steps S7 and S8, information is thus extracted and stored which represent the previously highest, used address of the stack (step S7) and the call tree CT, which is temporarily stored in step S8 for further evaluation.
Gemäß Schritt S6 erfolgt nach dem Auslösen eines Traps eine Erhöhung des Schwellwerts SW, wobei dieser nicht über die obere (Ende- ) Adresse des Stapelspeichers erhöht wird. Die Erhöhung des Schwellwerts SW sorgt dafür, dass der in Schritt S2 überprüfte Schwellwert auf den nunmehr gültigen Schwellwert gesetzt wird. Damit endet eine Schleife des Verfahrens (Ende E) . Der Ablauf des Programms in dem eingebetteten System kann nunmehr erneut beginnen. Wird der nunmehr gültige Schwellwert SW in Schritt S2 wiederum erreicht, so erfolgt ein erneuter Aufruf der vorde¬ finierten Funktion gemäß Schritt S3, usw. Im Ergebnis kann festgestellt werden, ob der für den Ablauf des Programms reservierte Stapelspeicher ausreichend groß ist. Dies ist dann der Fall, wenn der Schwellwert - auch nach mehrmaligem Erhöhen - unterhalb der oberen (Ende- ) Adresse gelegen ist und kein Aufruf der vordefinierten Funktion erfolgt. In diesem Fall könnte eine Optimierung darin bestehen, die obere (Ende- ) Adresse des Stapelspeichers zu verringern, z.B. auf die Adresse des Schwellwerts oder mindestens eine Adresse höher. Wird andererseits durch den Schwellwert die obere (Ende- ) Adresse erreicht, ohne dass das Programm bestimmungsgemäß bis zu seinem Ende ablaufen kann, so ist entweder die Größe des Stapelspeichers zu erhöhen, indem beispielsweise die obere (Ende- ) Adresse erhöht wird. Ebenso könnte die Optimierung eine Änderung der Ver- schachtelungstiefe der Anzahl an voneinander abhängigen Programmteilen umfassen. Dies erfolgt vorzugsweise automatisiert durch einen Compiler. Eine weitere Optimierung besteht darin, eine Änderung des Ablaufs an einer oder mehreren Teilen des Programms vorzunehmen, wobei dies vorzugsweise manuell durch den Programmierer des Programms erfolgt. According to step S6, after the triggering of a trap, the threshold value SW is increased, but this is not increased above the upper (end) address of the stack. The increase of the threshold value SW ensures that the threshold value checked in step S2 is set to the now valid threshold value. This ends a loop of the procedure (end E). The flow of the program in the embedded system can now begin again. If the now valid threshold value SW reached in step S2, in turn, as a new call of the prede ¬-defined function in step S3, etc. As a result, it can be determined whether the reserved for the execution of the program stack is sufficiently large. This is the case if the threshold is located below the upper (end) address, even after repeated increases, and no call is made to the predefined function. In this case, an optimization could be to reduce the top (end) address of the stack, eg to the address of the threshold or at least one address higher. If, on the other hand, the upper (end) address is reached by the threshold value, without the program being able to run to its end as intended, then either the size of the stack memory is to be increased, for example by increasing the upper (end) address. Likewise, the optimization could include changing the nesting depth of the number of interdependent program parts. This is preferably done automatically by a compiler. Another optimization is to make a change to the process on one or more parts of the program, preferably manually by the programmer of the program.
Ebenso ist es möglich, aus dem Inhalt des Stapelspeichers den Wert des aktuellen Stack-Pointers und die Adresse der aufgerufenen Funktion (Program Counter) , und optional einen Zeitstempel des Funktionsaufrufs zu ermitteln. Aus diesen Daten kann sowohl der Stack-Verbrauch als Funktion der Zeit als auch ein Call Tree derjenigen Funktionen ermittelt werden, welche zu diesem Stack-Verbrauch geführt haben. It is also possible to determine from the contents of the stack the value of the current stack pointer and the address of the called function (Program Counter), and optionally a timestamp of the function call. From these data, both the stack consumption as a function of time and a call tree of those functions can be determined, which led to this stack consumption.
Aus den im Rahmen des Verfahrens ermittelten Daten lässt sich der Stack-Verbrauch gezielt für bestimmte Szenarien bestimmen. Beispielsweise kann der maximale Stack-Verbrauch einzelner Programmteile oder auch des gesamten Programms ermittelt werden. Weiterhin kann der Call Tree zu dem Zeitpunkt ermittelt werden, zu dem der gültige Schwellwert durch das Programm erreicht wurde und die vordefinierte Funktion zum Ablauf gebracht wurde. From the data determined in the process, the stack consumption can be determined specifically for specific scenarios. For example, the maximum stack consumption of individual program parts or the entire program can be determined. Furthermore, the call tree can be determined at the time when the valid threshold value was reached by the program and the predefined function was executed.
Weiterhin lassen sich ein minimaler, maximaler und durchschnittlicher Stack-Verbrauch eines einzelnen Betriebssys- tem-Prozesses, einschließlich des Call Trees, ermitteln. Dieser Verlauf ist beispielhaft in Fig. 1 dargestellt, in der die Stack-Nutzung SU über die Zeit t dargestellt ist. Der Furthermore, a minimum, maximum and average stack consumption of a single operating system process, including the call tree, can be determined. This course is illustrated by way of example in FIG. 1, in which the stack usage SU is shown over the time t. Of the
Stack-Verbrauch eines ersten Prozesses („Prozess 1") ist dabei in Abhängigkeit des Aufrufs seiner Funktionen fl, f2, f3, f4 und in Abhängigkeit von Interrupt-Events il, i2 dargestellt. Analog hierzu ist der Stack-Verbrauch eines zweiten Prozesses („Prozess 2") dargestellt, der ebenfalls in dem eingebetteten System läuft. Hieraus ergibt sich ein Gesamt-Stackverbrauch („Total"), wobei hieraus ein Maximalwert (max) des Stack-Verbrauchs, ein Mit¬ telwert (avg) und ein Minimalwert (min) des Ge- samt-Stackverbrauchs „Total" dargestellt sind. Dadurch, dass das erfindungsgemäße Verfahren Real-Bedingungen berücksichtigt, ist es möglich, den Stack-Verbrauch des Pro¬ gramms des eingebetteten Systems unter Berücksichtigung aller im Realbetrieb herrschenden Randbedingungen, wie z.B. Events, Langzeitverhalten usw., zu ermitteln und bei Bedarf das Programm bzw. das eingebettete System zu optimieren. Stack consumption of a first process ("process 1") is shown as a function of the call of its functions f1, f2, f3, f4 and as a function of interrupt events il, i2. Analogously, the stack consumption of a second process ( "Process 2"), which also runs in the embedded system. This results in a total stack consumption ("Total"), where From this, a maximum value (max) of the stack consumption, an With ¬ average value (avg) and a minimum value (min) of the overall velvet stack usage "Total" are illustrated. As a result, the method of the invention takes into account real conditions, it is possible , to determine the stack usage of the Pro ¬ program of the embedded system taking into account all existing in the real operating conditions, such as events, long-term behavior, etc., and to optimize the program or the embedded system if necessary.

Claims

Patentansprüche claims
1. Verfahren zur Funktionsoptimierung des Ablaufs eines Programms in einem eingebetteten System, wobei das Programm zu dessen Ablauf einen Stapelspeicher des eingebetteten Systems benutzt, der durch einen abgegrenzten Adressbereich in einem Speicher des eingebetteten Systems gebildet ist und dessen Größe durch einen Adressbereich mit einer unteren Adresse und einer oberen Adresse definiert ist, bei dem A method for optimizing the operation of a program in an embedded system, wherein the program to its expiration uses a stack of the embedded system, which is formed by a delimited address range in a memory of the embedded system and its size by an address range with a lower address and an upper address is defined in which
- ein Schwellwert (SW) für den Stapelspeicher definiert wird, der durch eine Adresse des Stapelspeichers repräsentiert ist, wobei die Adresse kleiner ist als die obere Adresse des Adressbereichs des Stapelspeichers; - a threshold value (SW) is defined for the stack memory, which is represented by an address of the stack, the address being smaller than the upper address of the address area of the stack;
überwacht wird, ob das auf dem eingebetteten System ab- laufende Programm unter Nutzung des Stapelspeichers die durch den Schwellwert (SW) repräsentierte Adresse erreicht; beim Erreichen des Schwellwerts (SW) eine vordefinierte Funktion aufgerufen wird, durch die der Inhalt des Stapelspeichers ausgelesen wird;  monitoring whether the program running on the embedded system, using the stack, reaches the address represented by the threshold value (SW); upon reaching the threshold value (SW) a predefined function is called, by which the content of the stack is read out;
- aus dem Inhalt des Stapelspeichers ermittelt wird, welcher Teil des Programms den Aufruf der vordefinierten Funktion ausgelöst hat; und - It is determined from the contents of the stack, which part of the program has triggered the call of the predefined function; and
anhand der Information über den aufrufenden Teil eine Optimierung des Programms und/oder des eingebetteten Systems durchgeführt wird.  an optimization of the program and / or the embedded system is performed on the basis of the information about the calling part.
2. Verfahren nach Anspruch 1, dadurch gekennzeichnet, dass aus dem Inhalt des Stapelspeichers ein Call Tree ermittelt wird, wobei aus dem Call Tree derjenige Teil ermittelt wird, welcher die vordefinierte Funktion aufruft. 2. The method according to claim 1, characterized in that a call tree is determined from the contents of the stack, wherein from the call tree that part is determined which calls the predefined function.
3. Verfahren nach Anspruch 1 oder 2, dadurch gekennzeichnet, dass aus dem Inhalt des Stapelspeichers der Wert des aktuellen Stack-Pointers und die Adresse der aufgerufenen Funktion (Program Counter) , und optional ein Zeitstempel des Funkti¬ onsaufrufs, ermittelt werden. 3. The method of claim 1 or 2, characterized in that from the contents of the stack, the value of the current stack pointer and the address of the called function (Program Counter), and optionally a time stamp of Func ¬ onsaufrufs be determined.
4. Verfahren nach einem der vorhergehenden Ansprüche, dadurch gekennzeichnet, dass nach dem Aufrufen der vordefinierten Funktion und der Ermittlung des Inhalts des Stapelspeichers der Schwellwert (SW) erhöht wird, wobei eine neue Adresse des Schwellwerts näher an die obere Adresse des Stapelspeichers rückt . 4. The method according to any one of the preceding claims, characterized in that after the call of the predefined function and the determination of the contents of the stack of the threshold value (SW) is increased, with a new address of the threshold moves closer to the upper address of the stack.
5. Verfahren nach einem der vorhergehenden Ansprüche, dadurch gekennzeichnet, dass die Optimierung eine Vergrößerung des Stapelspeichers durch Änderung der oberen oder unteren Adresse umfasst . 5. The method according to any one of the preceding claims, characterized in that the optimization comprises an enlargement of the stack by changing the upper or lower address.
6. Verfahren nach einem der vorhergehenden Ansprüche, dadurch gekennzeichnet, dass die Optimierung eine Änderung der Ver- schachtelungstiefe einer Anzahl an voneinander abhängigen ( Programm- ) teilen durch einen Compiler umfasst. 6. The method according to any one of the preceding claims, characterized in that the optimization comprises a change of the nesting depth of a number of interdependent (program) parts by a compiler.
7. Verfahren nach einem der vorhergehenden Ansprüche, dadurch gekennzeichnet, dass die Optimierung eine Änderung des Ablaufs an einer oder mehreren Teilen des Programms umfasst. 7. The method according to any one of the preceding claims, characterized in that the optimization comprises a change of the process in one or more parts of the program.
PCT/EP2011/071126 2010-11-29 2011-11-28 Method for the functional optimisation of the sequence of a program in an embedded system WO2012072550A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
DE102010062110A DE102010062110A1 (en) 2010-11-29 2010-11-29 Method for optimizing the operation of a program in an embedded system
DE102010062110.2 2010-11-29

Publications (1)

Publication Number Publication Date
WO2012072550A1 true WO2012072550A1 (en) 2012-06-07

Family

ID=45047782

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/EP2011/071126 WO2012072550A1 (en) 2010-11-29 2011-11-28 Method for the functional optimisation of the sequence of a program in an embedded system

Country Status (2)

Country Link
DE (1) DE102010062110A1 (en)
WO (1) WO2012072550A1 (en)

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090217297A1 (en) * 2008-02-22 2009-08-27 Microsoft Corporation Building call tree branches

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090217297A1 (en) * 2008-02-22 2009-08-27 Microsoft Corporation Building call tree branches

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
"StackAnalyzer: Stack Usage Analysis", 22 April 2010 (2010-04-22), http://www.absint.com/stackanalyzer/, pages 1 - 2, XP055018517, Retrieved from the Internet <URL:http://web.archive.org/web/20100430183234/http://www.absint.com/stackanalyzer/> [retrieved on 20120206] *

Also Published As

Publication number Publication date
DE102010062110A1 (en) 2012-05-31

Similar Documents

Publication Publication Date Title
DE112006003926B4 (en) Peripheral device for a programmable logic controller
WO2009021789A1 (en) Method and apparatus for protection of a program against monitoring flow manipulation and against incorrect program running
EP1815308A1 (en) Method for managing a time-limited license on a computer application that can be run on a network component
DE10235564A1 (en) Watchdog circuit for microprocessor or microcontroller monitoring, has means for checking the watchdog circuit itself by resetting it and then executing a number of wait loops such that a processor monitoring time is exceeded
EP3446216A1 (en) Real-time environment and programmable logic controller
EP1303809A2 (en) Method and device for measuring the execution time of a task in a real time system
WO2006045754A1 (en) Method, operational system and computing unit for executing a computer program
DE112011100168T5 (en) Collect diagnostic data in a computing environment
WO2012062595A1 (en) Method and apparatus for assessing software parallelization
WO2012072550A1 (en) Method for the functional optimisation of the sequence of a program in an embedded system
DE102008022302A1 (en) Electronic computing device for determining an execution time of a task and program
EP2990941B1 (en) Computer-implemented method for generating a control device program codes and related report management environment
DE102004046288A1 (en) Method for processing a computer program on a computer system
WO2004042592A2 (en) Method for the secure checking of a memory region of a microcontroller in a control device and control device with a protected mikrocontroller
DE102015221892A1 (en) Determination of maximum latency
EP2652665A1 (en) Portable data storage medium with control error counter
WO2007039371A2 (en) Method and device for the computer-assisted analysis of the reliability of a technical system
DE19926467C1 (en) Computer system operating method has each individual program command of loaded computer program checked before program execution
DE10229817B4 (en) Method and device for storing a computer program in a program memory of a control device
EP3388944A1 (en) Method for error detection within an operating system
EP2569763A1 (en) Method for the computer-assisted monitoring of the functional performance of a technical system
WO2021115963A1 (en) Method and apparatus for controlling an iot device by means of a program code
WO2019243122A1 (en) Method for quantifying the reliability of a control function; control device; computer program; storage medium; and data stream
WO2000002107A2 (en) Method and device for designing the control of an overall process
WO2015018429A1 (en) Generation of a data record for an electrical automation device

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 11788452

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 11788452

Country of ref document: EP

Kind code of ref document: A1