WO2018042935A1 - 電子制御装置、解析システム - Google Patents

電子制御装置、解析システム Download PDF

Info

Publication number
WO2018042935A1
WO2018042935A1 PCT/JP2017/026375 JP2017026375W WO2018042935A1 WO 2018042935 A1 WO2018042935 A1 WO 2018042935A1 JP 2017026375 W JP2017026375 W JP 2017026375W WO 2018042935 A1 WO2018042935 A1 WO 2018042935A1
Authority
WO
WIPO (PCT)
Prior art keywords
cpu
counter
electronic control
log
unit
Prior art date
Application number
PCT/JP2017/026375
Other languages
English (en)
French (fr)
Inventor
拓 下沢
朋仁 蛯名
博史 峯
Original Assignee
日立オートモティブシステムズ株式会社
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 日立オートモティブシステムズ株式会社 filed Critical 日立オートモティブシステムズ株式会社
Publication of WO2018042935A1 publication Critical patent/WO2018042935A1/ja

Links

Images

Classifications

    • BPERFORMING OPERATIONS; TRANSPORTING
    • B60VEHICLES IN GENERAL
    • B60RVEHICLES, VEHICLE FITTINGS, OR VEHICLE PARTS, NOT OTHERWISE PROVIDED FOR
    • B60R16/00Electric or fluid circuits specially adapted for vehicles and not otherwise provided for; Arrangement of elements of electric or fluid circuits specially adapted for vehicles and not otherwise provided for
    • B60R16/02Electric or fluid circuits specially adapted for vehicles and not otherwise provided for; Arrangement of elements of electric or fluid circuits specially adapted for vehicles and not otherwise provided for electric constitutive elements
    • 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/52Program synchronisation; Mutual exclusion, e.g. by means of semaphores

Definitions

  • the present invention relates to an electronic control device and an analysis system.
  • Patent Document 1 discloses a method of accessing a time register and calculating a waiting time as a difference between the current time and the acquired time.
  • An electronic control device is an electronic control device including a plurality of CPU cores and a shared resource, and each of the CPU cores can use the shared resource exclusively by exclusive control.
  • an update counter storage unit for storing a counter value
  • a log storage unit for storing a log of a program executed by the CPU core, and changing the counter value when the CPU core accesses the shared resource
  • the log including the counter value is stored in the log storage unit.
  • a counter recording unit for recording.
  • An analysis system includes the electronic control device according to the first aspect and an analysis device, and the analysis device stores the log stored in the log storage unit of the electronic control device.
  • An input log collection unit a storage unit for storing conversion information for converting the count value into real time, and using the conversion information, the counter value input to the log collection unit is converted into real time.
  • the overhead for recording the waiting time can be reduced.
  • Diagram showing the configuration of the analysis system The figure which shows the operation example of the electronic control unit
  • FIG. 1 is a diagram showing a configuration of an electronic control device 100 and an analysis system 1 according to the present invention.
  • the analysis system 1 includes an electronic control device 100 and an analysis device 200.
  • the electronic control device 100 is, for example, an ECU (Electronic Control Unit).
  • the electronic control device 100 includes a first CPU 160, a second CPU 170, a shared resource 110 that can be used by these two CPUs, a memory 130 that is a main storage device, a timer 120 that has current time information, and a log output unit 180.
  • the first CPU 160 and the second CPU 170 are collectively referred to as “CPU”.
  • the shared resource 110 is a partial area of the memory 130, a physical memory independent of the memory 130, or a hardware register of any CPU.
  • the shared resource 110 can be accessed from the first CPU 160 and the second CPU 170, and the shared resource 110 is exclusively used by one of the CPUs by exclusive control described later.
  • the shared resource 110 includes a storage unit that stores a lock variable 111 and task information 112.
  • the lock variable 111 is a variable indicating the state of exclusive control. For example, in the present embodiment that takes values of “zero” and “1”, the state where the lock variable 111 is “0” indicates which of the shared resources 110 is The CPU is not controlled exclusively, i.e., is not exclusively used.
  • the state in which the lock variable 111 is “1” is a state in which the shared resource 110 is exclusively controlled by any CPU, that is, is exclusively used.
  • the task information 112 is a variable indicating the identifier of the latest task dedicated to the shared resource 110.
  • the lock variable 111 is finally set to “1”
  • the identifier of the task being executed in the CPU that occupied the shared resource 110 is stored as the task information 112. If the CPU that executed the task cannot be specified only by the task identifier, information specifying the CPU that executed the task is also included in the task information 112 as identification information.
  • the above-described task means a process executed by the CPU, and is called a job, a process, a thread, or the like depending on the processing system.
  • Each of the first CPU 160 and the second CPU 170 is an individual CPU, and each has a CPU core. That is, the electronic control device 100 is a device having a so-called multiprocessor configuration including a plurality of physical CPUs.
  • the first CPU 160 operates as a first lock acquisition unit 161 and a first counter recording unit 162 by developing and executing a program (not shown) in the memory 130.
  • the second CPU 170 operates as the second lock acquisition unit 171 and the second counter recording unit 172 by developing and executing a program (not shown) in the memory 130.
  • the first CPU 160 and the second CPU 170 temporarily use the shared resource 110 as follows.
  • the value of the lock variable 111 is confirmed. If the lock variable 111 is “zero” when the CPU confirms, the CPU rewrites the lock variable 111 to “1” to use the shared resource 110 exclusively, and when the use ends, sets the lock variable 111 to “1”. Rewrite from zero to zero. If the lock variable 111 is “1” when the CPU confirms, the CPU accesses the lock variable 111 every predetermined time and continues to access until the lock variable 111 is changed to “zero”. The time interval at which the CPU accesses the lock variable 111 is known, and a time conversion table 212 described later is created in advance based on this time interval.
  • spin lock the exclusive control method that repeats access until the shared resource 110 is successfully occupied until the lock variable 111 becomes “zero” in the above example.
  • spin count the number of attempts to occupy the shared resource 110 in the spin lock, that is, the second and subsequent times when the value of the lock variable 111 is confirmed. For example, if the lock variable 111 is “zero” for the first time when the lock variable 111 is confirmed, the number of spins is zero, and if it is “zero” for the first time after the lock variable 111 is confirmed, the number of spins is two.
  • lock wait time the time from when the value of the lock variable 111 is confirmed for the first time until “1” can be assigned to the lock variable 111.
  • lock acquisition exclusive control of the shared resource 110 by rewriting the lock variable 111 from “zero” to “1” is also referred to as “lock acquisition”.
  • the first lock acquisition unit 161 and the second lock acquisition unit 171 perform this lock acquisition.
  • the first lock acquisition unit 161 operates when the first CPU 160 uses the shared resource 110
  • the second lock acquisition unit 171 operates when the second CPU 170 uses the shared resource 110.
  • the confirmation of the lock variable 111 by the first lock acquisition unit 161 and the second lock acquisition unit 171 and the substitution of “1” when the lock variable 111 is “zero” are atomically performed as a TEST-and-SET instruction. Executed. That is, the confirmation of the variable and the assignment to the variable are executed without being interrupted as a series of operations from other CPUs.
  • the timer 120 is hardware that manages time.
  • the timer 120 includes a time register 121 that indicates time information.
  • the time information may be an absolute time, or may be a relative time with a predetermined time such as a time when the power source of the electronic control device 100 is turned on, for example, zero.
  • the memory 130 is a storage device and holds programs and data executed by the CPU.
  • the memory 130 includes an update counter storage unit 140 and a log storage unit 150 as its functions.
  • the shared resource 110, the memory 130, and the timer 120 may each be hardware independent of the CPU on the electronic control device 100, or on a single semiconductor chip such as a SoC (System-on-Chip). May be integrated.
  • SoC System-on-Chip
  • a first counter 141 and a second counter 142 are stored in the update counter storage unit 140.
  • the first counter 141 is a counter value updated by the first CPU 160 and indicates the number of spins of the first CPU 160.
  • the second counter 142 is a counter value updated by the second CPU 170 and indicates the number of spins of the second CPU 170.
  • the initial values of the first counter 141 and the second counter 142 are zero, and each is incremented by one by updating.
  • the log storage unit 150 includes a first buffer 151 and a second buffer 152.
  • the first buffer 151 stores a log of the program executed by the first CPU 160.
  • the second buffer 152 stores a log of a program executed by the second CPU 170.
  • the log stored in the log storage unit 150 is output to the analysis apparatus 200 via the log output unit 180 described later.
  • the log output unit 180 is an interface that communicates with the log collection unit 270 of the analysis apparatus 200.
  • the log output unit 180 is, for example, a debugging interface such as JTAG or a communication interface corresponding to CAN (CarAreaNetwork) or IEEE802.3.
  • the log output unit 180 outputs a log to the analysis device 200 in response to a request from the analysis device 200 or at regular time intervals.
  • the analysis device 200 is, for example, a computer including a memory 210, a log analysis unit 220, a display unit 230, a CPU 260, and a log collection unit 270.
  • the memory 210 stores a collection buffer 211 in which logs of each CPU of the electronic control device 100 are aggregated, a time conversion table 212 indicating the relationship between the number of spins and time, and an analysis result 213 output by the log analysis unit 220.
  • the log analysis unit 220 analyzes the log stored in the collection buffer 211 using the time conversion table 212. In other words, the log analysis unit 220 converts the lock waiting time recorded as the number of spins into real time.
  • the result analyzed by the log analysis unit 220 is stored in the memory 210 as the analysis result 213 and displayed on the display unit 230.
  • the display unit 230 displays the log stored in the collection buffer 211 and the analysis result 213 output by the log analysis unit 220.
  • the display unit 230 may be a device that outputs information to be displayed on a display device connected to the analysis device 200.
  • the CPU 260 is an arithmetic device that operates the analysis device 200.
  • the architecture, the number of cores, the number of sockets, the operation speed, etc. of the CPU 260 are not particularly limited.
  • the log collection unit 270 is an interface that communicates with the log output unit 180 of the electronic control device 100.
  • the log collection unit 270 is, for example, a debugging interface such as JTAG or a communication interface corresponding to CAN or IEEE802.3.
  • the log collection unit 270 stores the log received from the electronic control device 100 in the collection buffer 211.
  • FIG. 2 shows tasks executed by the first CPU 160 and the second CPU 170, and lock acquisition. Time passes from the left to the right in the figure.
  • the numbers shown at the top of FIG. 2 indicate the time obtained from the time register 121.
  • Logs stored in the first buffer 151 and the second buffer 152 which will be described later with reference to FIGS. 3 and 4, are logs obtained by the operation shown in FIG.
  • exclusive control of the shared resource 110 that is executed a plurality of times, that is, lock acquisition will be referred to as lock L, lock M, lock N,. .
  • the first CPU 160 executes task A from time 850 to time 910, an interrupt R is generated at time 880, and the interrupt R continues until time 900.
  • the first CPU 160 starts acquiring the lock L at time 860, starts acquiring lock N at time 885, and starts acquiring lock O slightly before time 900.
  • Second CPU 170 executes task B from time 840 to time 920, interrupt Q occurs at time 870, and interrupt Q continues until time 890.
  • the second CPU 170 starts acquiring the lock M at time 880, and after using the shared resource 110 after the acquisition of the lock M, the second CPU 170 ends the use of the shared resource 110 after the time 885 has passed.
  • the number of spins at that time is 300, and the task that has used the shared resource 110 before that is the interrupt Q.
  • Other lock acquisitions that is, the number of spins of lock L, lock M, and lock O are zero. If the number of spins is zero, the lock is acquired immediately.
  • FIG. 3 and 4 are diagrams illustrating examples of information stored in the first buffer 151 and the second buffer 152.
  • FIG. Here, information stored in the first buffer 151 and the second buffer 152 when the operation shown in FIG. 2 is performed is shown. Since the first buffer 151 and the second buffer 152 have the same configuration, the first buffer 151 will be described as a representative.
  • the first buffer 151 stores a log composed of one or a plurality of records. Each record in the first buffer 151 includes five fields: event type 311, event content 312, time stamp 313, waiting time 314, and task information 315. Each record in the first buffer 151 corresponds to each event of a program executed in the first CPU 160.
  • event type 311 field the type of event that has occurred, for example, “task start”, “lock acquisition”, etc., is stored.
  • event content 312 the object of the event that has occurred, for example, “task A”, “interrupt R”, or the like is stored. For example, if the event type is “task start” and the event content 312 is “task A”, the log represents an event that the execution of the task A is started in the CPU.
  • the time stamp 313 field stores information about the time at which the event occurred.
  • the time information is obtained from the time register 121 of the timer 120.
  • the waiting time 314 field stores information indicating the lock waiting time obtained from the first counter 141, that is, the number of spins.
  • the field of the task information 315 stores the value of the task information 112 when the lock acquisition is successful when the number of spins is 1 or more.
  • a value stored in a certain field may be referred to as a field name.
  • “the value stored in the field of the event type 311 is xx” may be described as “the event type 311 is xx”.
  • the time stamp 313 field is not recorded under the following conditions. That is, if the event type 311 is “lock acquisition” and the waiting time 314 is zero (0), no value is recorded in the field of the time stamp 313. In other cases, that is, when the first CPU 160 can acquire the lock in the second and subsequent accesses, a value is recorded in the field of the time stamp 313. This is because when the lock acquisition waiting time is zero, it is not necessary to record the time, and the overhead required for recording the time is large. In the example shown in FIGS. 3 and 4, the time stamp 313 is not recorded in the event of the locks L, M, and O in which the waiting time 314 is zero.
  • the field of the waiting time 314 is recorded when the event type 311 is “lock acquisition”. That is, when the event type 311 is other than “lock acquisition”, no value is recorded in the waiting time 314 field. As described above, since the number of spins is stored in the field of the waiting time 314, it is impossible to record in an event other than “lock acquisition” in which no spin can occur. In the example shown in FIGS. 3 and 4, the task information 315 is recorded only for an event of lock N in which the waiting time 314 is not zero.
  • a value is recorded in the field of the task information 315 when the event type 311 is “lock acquisition” and the waiting time 314 is other than zero, that is, when the first CPU 160 can acquire the lock in the second and subsequent accesses. . In other cases, no value is recorded in the field of the task information 315. This is because when the lock acquisition waiting time is zero, it is not necessary to identify the task that has used the shared resource 110 immediately before.
  • the first buffer 151 and the second buffer are described as simple tables. However, a structure like a ring buffer may be used, and a variable for actual data storage. Long records may be used.
  • FIG. 5 is a diagram illustrating an example of the time conversion table 212.
  • the time conversion table 212 is a correspondence table between the number of spins stored in the waiting time field in the first buffer 151 and the second buffer 152 and the real time, and includes fields of a waiting time 321 and a real time 322.
  • the waiting time 321 field stores a waiting time, that is, the number of spins
  • the real time 322 field stores a real time value corresponding to the waiting time (spin number) value stored in the waiting time 321.
  • the information stored in the time conversion table 212 may be information other than the table format shown in FIG. That is, any format of information may be stored in the time conversion table 212 as long as the information appropriately represents the relationship between the number of spins and real time.
  • FIG. 6 is a diagram illustrating an example of the analysis result 213 output from the log analysis unit 220 of the analysis apparatus 200.
  • the analysis result 213 is information obtained by analyzing the log stored in the collection buffer 211, and describes details of the lock acquisition event in which the waiting time has occurred. Each record constituting the analysis result 213 corresponds to a lock acquisition event.
  • the analysis result 213 includes seven fields of a processing CPU 331, a generation processing 332, a lock 333, a time stamp 334, an actual waiting time 335, a cause CPU 336, and a cause processing 337.
  • the field of the processing CPU 331 stores the identifier or name of the CPU in which the lock acquisition event has occurred.
  • the field of the generation process 332 stores the name of the task or interrupt process that generated the lock acquisition event.
  • the name of the lock set for convenience is stored.
  • the time stamp 334 field stores information on the time when the lock acquisition event occurred.
  • the waiting time until lock acquisition converted using the time conversion table 212 is stored.
  • the field of the cause CPU 336 stores the identifier or name of the CPU that caused the wait in the lock acquisition.
  • the field of the cause process 337 stores the identifier of the task that caused the wait in the lock acquisition.
  • the CPU and task that caused the wait are the CPU that held the lock and the task that the CPU was executing when attempting to acquire the lock in the event.
  • the CPU and task causing the waiting are identified from the task information 112.
  • the first record in FIG. 6 will be specifically described. This record is generated based on the log of the fourth record in FIG. In order for the first CPU 160 to acquire the lock N at time 185, a wait of 300 spins occurred. Therefore, in the analysis result 213, “first CPU” is stored in the processing CPU 331, “interrupt R” is generated in the generation processing 332, “lock N” is stored in the lock 333, and “185” is stored in the time stamp 334. Also, 300 spins corresponds to 1201 microseconds according to the time conversion table 212, and therefore "1201 microseconds" is stored in the field of the actual waiting time 335.
  • the task that used the shared resource 110 immediately before is the interrupt Q, and since the task was executed by the second CPU 170, “second CPU” is stored in the field of the cause CPU 336, and “interrupt Q” is stored in the field of the cause process 337. Is done.
  • the first CPU 160 acquires a lock using the first lock acquisition unit 161 and records a log relating to the acquired lock in the first buffer 151 using the first counter recording unit 162.
  • the second CPU 170 acquires a lock using the second lock acquisition unit 171 and records a log related to the acquired lock in the second buffer 152 using the second counter recording unit 172.
  • the log output unit 180 outputs the log stored in the log storage unit 150 to the analysis device 200.
  • the CPU 260 of the analysis device 200 causes the log analysis unit 220 to analyze the log output from the electronic control device 100.
  • the result analyzed by the log analysis unit 220 is stored in the memory 210 as the analysis result 213 and displayed on the display unit 230.
  • the operation of acquiring the lock and the operation of storing the log related to the lock in the first CPU 160 will be described with reference to FIG. 7, and the operation of the log analysis unit 220 will be described with reference to FIG. Note that the operation of acquiring the lock in the second CPU 170 and the operation of storing the log related to the lock are the same as the operation of the first CPU 160, and thus description thereof is omitted.
  • step S400 the counter value of the first counter 141 is reset to zero.
  • step S401 in order to use the shared resource 110, an attempt is made to acquire a lock using the TEST-and-SET command described above.
  • step S402 it is determined whether or not the lock acquisition in step S401 is successful. If it is determined that the lock acquisition is successful, the process proceeds to step S406. If it is determined that the lock acquisition is not successful, the process proceeds to step S403.
  • step S403 the counter value of the first counter 141 is incremented, that is, incremented by one.
  • step S404 it is determined whether or not the counter value of the first counter 141 is “1”.
  • the process proceeds to step S405.
  • step S405 a time stamp is acquired from the time register 121, and the process returns to step S401.
  • step S406 which is executed when acquisition of the lock is successful, it is determined whether or not the counter value of the first counter 141 is zero. If it is determined that it is zero, the process proceeds to step S407, and if it is determined that it is not zero, the process proceeds to step S408.
  • step S407 the following information is recorded in the first counter recording unit 162 with the first buffer 151 as a recording target. That is, the type of event currently being executed in the first CPU 160, that is, “lock acquisition”, the content of the event, and the counter value of the first counter 141 are recorded.
  • step S408 the following information is recorded in the first counter recording unit 162 with the first buffer 151 as a recording target. That is, the type of event currently being executed in the first CPU 160, the content of the event, the counter value of the first counter 141, the time stamp acquired in step S405, and the task information 112 are recorded.
  • step S409 which is executed when the execution of step S407 or step S408 is completed, information on the task currently being executed in the first CPU 160 is stored in the task information 112, and the flowchart shown in FIG.
  • FIG. 8 is a flowchart showing the operation of the log analysis unit 220 that analyzes the log collected in the collection buffer 211 and outputs the analysis result 213.
  • the execution subject of each step described below is the CPU 260 of the analysis apparatus 200.
  • step S501 one of the CPUs whose logs are stored in the collection buffer 211 is selected as a processing target, and the process proceeds to step S502.
  • step S509 the processing between step S501 and step S509, that is, the processing from step S502 to step S508 is executed for all the CPUs whose logs are stored in the collection buffer 211.
  • step S502 any log of the CPU selected as the processing target is selected as the processing target, and the process proceeds to step S503.
  • the processing from step S502 to step S508, that is, the processing from step S503 to step S507 is executed for all the logs of the processing target CPU.
  • step S503 it is determined whether or not the event type 311 of the log to be processed is “lock acquisition”. If it is determined that it is “lock acquisition”, the process proceeds to step S504, and if it is determined otherwise. Advances to step S508.
  • step S504 it is determined whether or not the waiting time of the log to be processed is “1” or more. If it is determined that it is “1” or more, the process proceeds to step S505, otherwise it is determined to be zero. If so, the process proceeds to step S508. In step S505, the CPU that has executed the task is identified based on the field value of the task information 315 of the log to be processed. In subsequent step S506, the value of the waiting time 314 field of the processing target log is converted into real time using the time conversion table 212, and the process proceeds to step S507.
  • step S507 information on the processing target log is recorded in the analysis result 213.
  • the values recorded in the fields of the analysis result 213 are as follows.
  • the processing CPU 331 is the name of the CPU that is currently processed in the loop of steps S502 to S508.
  • the value of the generation process 332 is the value of the event content 312 in the log immediately before the log to be processed.
  • the value of the lock 333 is the value of the event content 312 in the processing target log.
  • the value of the time stamp 334 is the value of the time stamp 331 in the processing target log.
  • the value of the actual waiting time 335 is the actual time calculated in step S506.
  • the value of the cause CPU 336 is the name of the CPU specified in step S505.
  • the value of the cause process 337 is the value of the task information 315 in the processing target log.
  • step S508 it is determined whether or not all logs of the processing target CPU are set as processing targets. If it is determined that there is an unprocessed log, the process returns to step S503 with any of the unprocessed logs being processed, and if it is determined that all logs have been processed, the process proceeds to step S509. In step S509, it is determined whether or not all CPUs whose logs are stored in the collection buffer 211 have been processed. If it is determined that there is an unprocessed CPU, one of the unprocessed CPUs is set as the processing target, and the process returns to step S502. If it is determined that all CPUs have been processed, the flowchart of FIG.
  • the electronic control device 100 includes a plurality of CPUs, that is, a first CPU 160 and a second CPU 170, and a shared resource 110. Each of the CPUs can exclusively use the shared resource 110 by exclusive control. Each of the CPUs includes an update counter storage unit 140 in which a counter value is stored, and a log storage unit 150 in which a log of a program executed by the first CPU 160 and the second CPU 170 including a count value that has been counted is stored.
  • the CPU updates the counter value stored in the update counter storage unit 140 when the CPU accesses the shared resource 110, that is, the first lock acquisition unit 161 and the second lock acquisition unit 171;
  • a counter record that records a log including the counter value stored in the update counter storage unit 140 in the log storage unit 150 Units, that is, a first counter recording unit 162 and a second counter recording unit 172.
  • the electronic control unit 100 updates the counter value when the shared resource 110 is exclusively controlled by another CPU, that is, when the lock variable 111 is “1”. . Therefore, the occurrence of access can be recorded in the update counter storage unit 140 as an update of the counter value without causing overhead due to access to the timer 120.
  • the counter value stored in the update counter storage unit 140 represents the number of times after the second attempt to acquire the lock, that is, the number of spins.
  • the electronic control device 100 does not access the timer 120 with a large overhead and does not access the update counter storage unit.
  • the count value stored in 140 is stored in the log storage unit 150. Therefore, the overhead for recording the log is small.
  • the waiting time is calculated by acquiring a time from the timer at the start and end of the waiting time and calculating the difference between the two times as the waiting time. Access is made twice. The time required to acquire the time is longer than the time required to acquire the lock, and the time is acquired twice, so there is a problem that the overhead for calculating the waiting time is increased.
  • the waiting time can be recorded without causing such a problem.
  • the CPU of the electronic control unit 100 reads the counter stored in the update counter storage unit 140 every time the CPU accesses the shared resource 110 and executes a predetermined processing unit, that is, every time a spin lock is executed. Change the value. Therefore, by recording the number of executions of the spin lock whose execution interval and execution time are known, the waiting time can be recorded without accessing a timer with a large overhead.
  • the electronic control device 100 includes a timer 120 that holds time information.
  • the time information is acquired from the timer 120, and a log further including the time information is stored in the log storage unit 150. To store. Therefore, it is possible to record the time when the waiting time occurs while hiding the overhead of access to the timer 120.
  • the fact that the counter has been updated means that the shared resource 110 is being used by another CPU, and the CPU attempting to acquire the lock tries to acquire the lock again after a predetermined time has elapsed. Therefore, even if the CPU that attempted to acquire the lock accesses the timer 120, at least a part of the overhead is hidden.
  • This effect is significant when at least one of the first CPU 160 and the second CPU 170 has the following characteristics. That is, the effect is remarkable when the CPU has a feature of issuing an instruction to stop the CPU for a certain period of time in order to prevent the bus from being occupied during spinning.
  • the shared resource 110 includes an identification information storage unit that stores identification information for identifying processing executed by the CPU, that is, an area for storing task information 112.
  • the counter recording units that is, the first counter recording unit 162 and the second counter recording unit 172, when the CPU exclusively controls the shared resource 110 in the second and subsequent accesses, identify information, that is, task information 112 from the identification information storage unit.
  • the log further including the task information 112 is stored in the log storage unit 150. Therefore, it is possible to record in the log storage unit 150 the identification information of the process that caused the waiting time, that is, the process that previously used the shared resource 110.
  • the counter update unit 161 sets the identification information in the identification information storage unit based on processing executed by the CPU. Update. Since the task information 112 stores information on the task that uses the shared resource 110, when a certain CPU cannot use the shared resource 110, the process that caused the problem, that is, the shared resource 110 is used before. It is possible to specify the processing that has been performed.
  • the analysis system 1 includes an electronic control device 100 and an analysis device 200.
  • the analysis device 200 stores a log collection unit 270 to which information stored in the log storage unit 150 of the electronic control device 100 is input, and conversion information for converting the counter value into real time, for example, a time conversion table 212.
  • a storage unit that is, a memory 210, and a log analysis unit 220 that converts the counter value input to the log collection unit 270 into real time using the conversion information. Therefore, the analysis device 200 can convert the counter value recorded by the electronic control device 100 into real time. That is, the analysis system 1 records the waiting time based on the exclusive control of the shared resource 110 as the number of spins to reduce the overhead during recording, and converts the recorded number of spins to real time using the analysis device 200. Can do.
  • the time acquired from the timer 120 may be stored in the waiting time 314 of the first buffer 151 and the second buffer 152. That is, the time stamp may be acquired from the time register 121 and stored in step S408 in FIG.
  • the analysis apparatus 200 calculates the actual time that is waited for lock acquisition by calculating the difference between the time stored in the time stamp 313 and the time stored in the waiting time 314.
  • the analysis apparatus 200 has the first advantage that it is not necessary to provide the time conversion table 212, and the second advantage that more accurate waiting time calculation can be performed. Except when the waiting time becomes zero, even if the time is obtained by accessing the time register 121, the influence of the overhead is relatively small and the demerit is small.
  • the first counter 141 may be stored in a register of the first CPU 160 or a memory (not shown) provided in the first CPU 160.
  • the second counter 142 may be stored in a register of the second CPU 170 or a memory (not shown) provided in the second CPU 170. According to the second modification, rewriting is performed in the same CPU capable of high-speed access, so that the overhead of initialization and update of the counter value can be reduced.
  • the first counter 141 may not be provided independently, and the first buffer 151 may also serve as the first counter 141. In this case, instead of initializing and updating the counter value stored in the first counter 141, the first lock acquisition unit 161 writes zero, which is the initial value of the counter, in the waiting time 314 field of the first buffer 151. ,Update.
  • the second counter 142 may not be provided independently, and the second buffer 152 may also serve as the second counter 142.
  • the electronic control device 100 may include three or more CPUs. Further, the electronic control apparatus 100 may include one CPU that is housed in a single package and has a plurality of cores. A plurality of cores contained in a single package may be the same or different. Furthermore, the architecture and operation speed of each CPU core may be the same or different.
  • the memory 130 may be independent for each CPU.
  • the log storage unit 150 and the update counter storage unit 140 exist in the memory 130 for each CPU.
  • the configuration may be divided into a non-volatile memory that holds a program and a volatile memory that holds data.
  • the electronic control device 100 includes a third CPU, and the third CPU is at least one of the first lock acquisition unit 161, the first counter recording unit 162, the second lock acquisition unit 171, and the second counter recording unit 172. May be executed. Further, at least one of the first lock acquisition unit 161, the first counter recording unit 162, the second lock acquisition unit 171, and the second counter recording unit 172 may be executed by a hardware circuit.
  • the first embodiment described above may be further modified as follows.
  • the electronic control device 100 may include a plurality of timers and refer to different timers for each CPU. In this case, correction processing is performed, such as recording the difference in the value of the time register 121 used by each CPU.
  • the first counter recording unit 162 and the second counter recording unit 172 do not have to record the task information 112 in step S408 of FIG. In this case, the first lock acquisition unit 161 and the second lock acquisition unit 171 do not have to update the task information 112 in step S409 in FIG. 7, and the first buffer 151 and the second buffer 152 have the task information 315. This field may not be provided.
  • the first lock acquisition unit 161 and the second lock acquisition unit 171 may not acquire the time stamp regardless of the counter value. That is, if step S403 in FIG. 7 is executed, the process may return to step S401 without evaluating the counter value.
  • the electronic control device 100 may include a plurality of shared resources 110. In this case, each shared resource 110 includes a lock variable 111 and task information 112 independently.
  • FIGS. 1-10 A second embodiment of the electronic control device will be described with reference to FIGS.
  • the same components as those in the first embodiment are denoted by the same reference numerals, and different points will be mainly described. Points that are not particularly described are the same as those in the first embodiment.
  • the present embodiment differs from the first embodiment mainly in that the electronic control device includes a diagnostic unit that converts the count value to the real time.
  • FIG. 9 is a diagram illustrating a configuration of the electronic control device 100A according to the second embodiment.
  • the log output unit 180 is deleted from the configuration of the electronic control apparatus 100 in the first embodiment, and the diagnosis unit 900 is added.
  • the memory 130 further stores a time conversion table 212 and an analysis result 213. The configuration and operation not particularly described are the same as those in the first embodiment.
  • the diagnosis unit 900 represents a function realized by one of the first CPU 160 and the second CPU 170 executing a program stored in a ROM (not shown) as a functional block.
  • the diagnosis unit 900 analyzes the log stored in the log storage unit 150.
  • the diagnosis unit 900 detects an abnormality by analysis, for example, when the waiting time is longer than a predetermined time, the diagnosis unit 900 executes a predetermined abnormality process.
  • the diagnosis unit 900 operates when a predetermined time elapses or when a predetermined event that requires diagnosis occurs.
  • FIG. 10 is a flowchart showing the operation of the diagnosis unit 900 according to the second embodiment.
  • the execution subject of each step described below is either the first CPU 160 or the second CPU 170.
  • this execution subject is referred to as “CPU”. Since the processing up to step S507 is the same as that of the log analysis unit 220, description thereof is omitted. When the execution of step S507 is completed, step S521 is executed.
  • step S521 it is determined whether or not the actual time converted in step S506 is a predetermined value or more. If it is determined that the value is equal to or greater than the predetermined value, the process proceeds to step S522. In step S522, predetermined abnormality processing is executed, and the flow proceeds to step S508.
  • the abnormality process is, for example, a transition to an execution state with a minimum configuration or a restart of the electronic control device 100 when the number of times of abnormality detection is counted and a predetermined threshold value is reached.
  • the electronic control unit 100A uses the conversion information for converting the count value to time, for example, a storage unit that stores the time conversion table 212, that is, the memory 130, and the time conversion table 212 to convert the counter value into real time.
  • An analysis unit for conversion that is, a diagnosis unit 900 is provided. Therefore, the electronic control device 100A can convert the counter value into real time without using the analysis device 200. Thereby, as shown to step S521 of FIG. 10, the diagnosis using the converted real time can be performed.
  • the second embodiment may be modified as follows.
  • the diagnosis unit 900 may use other than the calculated waiting time for diagnosis. For example, if the task that caused the wait is not a predetermined task, it may be determined that some abnormality in the execution order has occurred, and this may be diagnosed as an abnormality.
  • the diagnosis unit 900 may not record the analysis result in the memory 130.
  • the electronic control device 100A may further include a log output unit 180.
  • FIGS. 1-10 A third embodiment of the electronic control device will be described with reference to FIGS.
  • the same components as those in the first embodiment are denoted by the same reference numerals, and different points will be mainly described. Points that are not particularly described are the same as those in the first embodiment.
  • This embodiment differs from the first embodiment mainly in that the number of executions of the basic block is counted instead of the number of spins.
  • a basic block is a program execution unit and does not include branching or merging. Since the basic block does not include branching or merging, the execution time of the basic block is constant if the execution environment, that is, the CPU, the memory, and the like are the same. In the present embodiment, description will be made using three basic blocks (A, B, C). The execution time in the electronic control device 100 of each basic block is known.
  • each of the first counter 141 and the second counter 142 includes three counters (A, B, C) corresponding to the basic blocks A, B, C, respectively.
  • the information stored as the time conversion table 212 is different from that in the first embodiment.
  • a program stored in a ROM (not shown) of the electronic control device 100 is different from that in the first embodiment, and operations of the first lock acquisition unit 161 and the second lock acquisition unit 171 are different from those in the first embodiment.
  • FIG. 11 is a diagram showing an example of the structure of the first buffer 151 in the present embodiment.
  • the configuration of the fields constituting the first buffer 151 is the same as that of the first embodiment, and the values stored in the waiting time 314 field are different. That is, the values of the counter A, the counter B, and the counter C stored in the first counter 141 are stored in the waiting time 314 field. The other points are the same as in the first embodiment.
  • the basic block A is executed three times
  • the basic block B is executed once
  • the basic block C is executed twice.
  • the configuration of the second buffer 152 and the information stored in the second buffer 152 are the same as those of the first buffer 151.
  • FIG. 12 is a diagram illustrating an example of the time conversion table 212A.
  • Time corresponding to each basic block is recorded in the time conversion table 212A.
  • the time conversion table 212A includes a basic block number 323 field and a time 324 field.
  • the identifier of the basic block or the name of the basic block is stored.
  • the time 324 field stores the time required for one execution of the basic block.
  • the lock acquisition unit that is, the first lock acquisition unit 161 and the second lock acquisition unit 171 acquired the lock using the TEST-and-SET command in the first embodiment, but in the third embodiment, A LockLinked instruction (hereinafter referred to as “LL instruction”) and a Store Conditional instruction (hereinafter referred to as “SC instruction”) are used to acquire a lock.
  • LL instruction LockLinked instruction
  • SC instruction Store Conditional instruction
  • the LL instruction is an instruction that loads a specified memory area and simultaneously generates a “link” for the area. This “link” disappears when another CPU writes to the same area.
  • the SC instruction is an instruction for storing a value only when a “link” remains in a specified memory area. Confirmation of the “link” remaining in the SC instruction means the following. That is, the fact that “link” remains indicates that another CPU is not writing to the same area between the LL instruction and the SC instruction. In other words, this guarantees the atomicity of reading and writing, that is, that reading and writing succeed as an integral part.
  • FIG. 13 is a flowchart illustrating a lock acquisition operation and a log recording operation related to lock acquisition by the first CPU 160 according to the third embodiment.
  • step S451 is the basic block A
  • step S454 is the basic block B
  • step S455 is the basic block C.
  • the counter corresponding to each basic block is updated.
  • the flowchart shown in FIG. 13 corresponds to FIG. 7 in the first embodiment. Hereinafter, differences from FIG. 7 will be mainly described.
  • step S400A the counters A to C of the first counter 141 are reset to zero, and the process proceeds to step S451.
  • step S451 the lock variable 111 is read using the LL instruction, and the process proceeds to step S452.
  • step S452 the counter A is incremented, that is, the counter value is incremented by 1, and the process proceeds to step S453.
  • step S453 it is determined whether or not the lock variable 111 read in step S451 is zero.
  • the CPU proceeds to step S455 when determining that it is zero, and proceeds to step S454 when determining that it is not zero.
  • step S454 the link generated in step S451 is discarded.
  • the counter B is incremented and the process proceeds to step S404A.
  • step S404A it is determined whether or not the sum of the counter values of the counter B and the counter C is “1”. If it is determined that the counter value is “1”, the process proceeds to step S405. If it is determined that the counter value is other than “1”, the process returns to step S451.
  • step S405 a time stamp is acquired from the time register 121, and the process returns to step S451.
  • step S455 “1” is written to the lock variable 111 using the SC instruction.
  • step S456 the counter C is incremented.
  • step S457 it is determined whether or not the writing in step S455 is successful. If it is determined that the writing has succeeded, the process proceeds to step S406A. If it is determined that the writing has failed, the process proceeds to step S404A.
  • step S406A it is determined whether or not the counter value of counter B is zero. If it is determined that it is zero, the process proceeds to step S407, and if it is determined that it is not zero, the process proceeds to step S408. Since the processing after step S407 is the same as that of the first embodiment, the description thereof is omitted.
  • the counter update unit that is, the first lock acquisition unit 161 and the second lock acquisition unit 171 access the shared resource 110
  • each time a predetermined processing unit is executed that is, each basic block is executed.
  • the counter update unit that is, the first lock acquisition unit 161 and the second lock acquisition unit 171 change the counter value of the counter B or the counter C when the shared resource 110 is exclusively controlled by another CPU. . Therefore, it is possible to record the number of times the shared resource 110 has been accessed but cannot be exclusively controlled.
  • the shared resource 110 is exclusively controlled by another CPU, it is determined that it is zero in step S453, and step S457 described later. There are two ways to determine that writing has failed. By using the sum of the counter values of the counter B and the counter C, it is possible to record the number of times that the exclusive control could not be performed.
  • step S404A by determining whether the sum of the counter values of the counter B and the counter C is “1”, in any case, the time is acquired in the first case where the exclusive control could not be performed. As in the first embodiment, it is possible to obtain the effect of recording the time when the waiting time occurs while concealing the overhead.
  • the number of executions of the basic block is counted.
  • the number of processes with a finer granularity may be counted, or the number of processes with a coarser granularity may be counted.
  • a configuration in which counting is performed for each instruction of the CPU as a fine granularity can be considered.
  • the log storage unit 150 stores the execution time for each instruction of the CPU.
  • it is desirable to use a hardware circuit such as a CPU because it is extremely overhead to realize this by software. According to the method of counting for each instruction by hardware, there is no need to change the software so as to count the number of executions for each basic block, and an effect of relatively reducing overhead can be obtained.
  • a counter may be mounted as one or a plurality of registers of the CPU, and the corresponding counter may be added when the CPU executes a specific instruction.
  • the waiting time 314 recorded in the log storage unit 150 in step S407 and step S408 in FIG. 7 is a counter value read from the hardware. In this case as well, an effect of further reducing the overhead can be obtained in addition to the function and effect of the first embodiment.
  • the program is stored in a ROM (not shown), the program may be stored in the memory 130.
  • the electronic control device 100 may include an input / output interface (not shown), and when necessary, a program may be read from another device via a medium that can be used by the input / output interface and the electronic control device 100.
  • the medium refers to, for example, a storage medium that can be attached to and detached from the input / output interface, or a communication medium, that is, a wired, wireless, or optical network, or a carrier wave or digital signal that propagates through the network.
  • part or all of the functions realized by the program may be realized by a hardware circuit or FPGA.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Mechanical Engineering (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

電子制御装置は、複数のCPUコアと、共有資源とを備える電子制御装置であって、CPUコアのそれぞれは排他制御により共有資源を独占して使用可能であり、カウンタ値が格納される更新カウンタ格納部と、CPUコアが実行したプログラムのログが格納されるログ格納部と、CPUコアが共有資源にアクセスしたときに、カウンタ値を変化させるカウンタ更新部と、CPUコアが共有資源にアクセスしたときに、共有資源が他のCPUコアにより排他制御されていない場合には、カウンタ値を含むログをログ格納部に記録するカウンタ記録部とをさらに備える。

Description

電子制御装置、解析システム
 本発明は、電子制御装置、および解析システムに関する。
 複数のCPUが協調して動作する電子制御装置においては、複数のCPUが共有する資源へのアクセスの排他制御が必要になる。あるCPUが共有資源を使用している場合は、他のCPUは先のCPUの使用が完了するまでは共有資源を使用できず、待ち時間が生じる。この待ち時間の発生は、電子制御装置の処理能力を低下させるため、待ち時間を生じさせないことが望ましい。そのためには待ち時間の原因の解析が必要であり、解析のために待ち時間をログとして記録することが求められる。
 特許文献1には、時刻レジスタにアクセスし、現在時刻と取得した時刻との差分として待ち時間を算出する手法が開示されている。
国際公開第2012/132017号
 特許文献1に記載されている発明では、待ち時間の記録のためのオーバーヘッドが大きい。
 本発明の第1の態様による電子制御装置は、複数のCPUコアと、共有資源とを備える電子制御装置であって、前記CPUコアのそれぞれは排他制御により前記共有資源を独占して使用可能であり、カウンタ値が格納される更新カウンタ格納部と、前記CPUコアが実行したプログラムのログが格納されるログ格納部と、前記CPUコアが前記共有資源にアクセスしたときに、前記カウンタ値を変化させるカウンタ更新部と、前記CPUコアが前記共有資源にアクセスしたときに、前記共有資源が他のCPUコアにより排他制御されていない場合には、前記カウンタ値を含む前記ログを前記ログ格納部に記録するカウンタ記録部とをさらに備える。
 本発明の第2の態様による解析システムは、第1の態様の電子制御装置と、解析装置と、を備え、前記解析装置は、前記電子制御装置の前記ログ格納部に格納された前記ログが入力されるログ収集部と、前記カウント値を実時間に換算するための換算情報を格納する記憶部と、前記換算情報を用いて、前記ログ収集部に入力された前記カウンタ値を実時間に換算する解析部と、を備える。
 本発明によれば、待ち時間の記録のためのオーバーヘッドを減らすことができる。
解析システムの構成を示す図 電子制御装置の動作例を示す図 第1バッファの一例を示す図 第2バッファの一例を示す図 時間変換テーブルの一例を示す図 解析結果の一例を示す図 電子制御装置の動作を表すフローチャート ログ解析の動作を表すフローチャート 第2の実施の形態における電子制御装置の構成を示す図 第2の実施の形態における電子制御装置の動作を表すフローチャート 第3の実施の形態における第1バッファの一例を示す図 第3の実施の形態における時間変換テーブルの一例を示す図 第3の実施の形態における電子制御装置の動作を表すフローチャート
(第1の実施の形態)
 以下、図1~図8を参照して、電子制御装置の第1の実施の形態を説明する。
 図1は、本発明に係る電子制御装置100、および解析システム1の構成を示す図である。解析システム1は、電子制御装置100と、解析装置200とから構成される。
 電子制御装置100は、たとえばECU(ElectronicControl Unit)である。電子制御装置100は、第1CPU160と、第2CPU170と、これら2つのCPUが使用可能な共有資源110と、主記憶装置であるメモリ130と、現在時刻の情報を有するタイマ120と、ログ出力部180とを備える。以下では、第1CPU160と第2CPU170とをまとめて、「CPU」とも呼ぶ。
 共有資源110は、メモリ130の一部の領域、メモリ130とは独立した物理メモリ、またはいずれかのCPUのハードウエアレジスタである。共有資源110は、第1CPU160および第2CPU170からアクセスが可能であり、後述する排他制御によりいずれかのCPUにより共有資源110が専有される。共有資源110は、ロック変数111、およびタスク情報112が格納される記憶部を備える。
 ロック変数111は、排他制御の状態を示す変数であり、たとえば「ゼロ」と「1」の値をとる本実施の形態では、ロック変数111が「0」の状態とは、共有資源110がいずれのCPUによっても排他制御されていない、すなわち専有されていない状態である。また、ロック変数111が「1」の状態とは、共有資源110がいずれかのCPUによって排他制御されている、すなわち専有されている状態である。
 タスク情報112は、共有資源110を専有した最新のタスクの識別子を示す変数である。換言すると、ロック変数111が最後に「1」に設定された際に、共有資源110を占有したCPUにおいて実行されていたタスクの識別子がタスク情報112として保存される。なお、タスクの識別子だけではそのタスクを実行したCPUを特定できない場合は、そのタスクを実行したCPUを特定する情報も識別情報としてタスク情報112に含まれる。なお上述したタスクとは、CPUが実行する処理を意味しており、処理系によってジョブ、プロセス、スレッドなどと呼ばれる。
 第1CPU160および第2CPU170のそれぞれは、個別のCPUであり、それぞれがCPUコアを有する。すなわち電子制御装置100は、複数の物理CPUを備えるいわゆるマルチプロセッサ構成を有する装置である。第1CPU160は、不図示のプログラムをメモリ130に展開して実行することにより、第1ロック取得部161および第1カウンタ記録部162として動作する。第2CPU170は、不図示のプログラムをメモリ130に展開して実行することにより、第2ロック取得部171および第2カウンタ記録部172として動作する。第1CPU160および第2CPU170は、以下のように共有資源110を一時的に専有して使用する。
 CPU,すなわち第1CPU160および第2CPU170は、共有資源110を使用する必要が生じると、まずロック変数111の値を確認する。CPUが確認した際にロック変数111が「ゼロ」であれば、CPUはロック変数111を「1」に書き換えて共有資源110を専有して使用し、使用が終了するとロック変数111を「1」から「ゼロ」に書き換える。CPUが確認した際にロック変数111が「1」であった場合は、そのCPUは所定時間ごとにロック変数111にアクセスし、ロック変数111が「ゼロ」に変更されるまでアクセスを続ける。なお、CPUがロック変数111にアクセスする時間間隔は既知であり、この時間間隔に基づき後述する時間変換テーブル212があらかじめ作成されている。
 このように、共有資源110の専有に成功するまで、上記の例ではロック変数111が「ゼロ」になるまで、アクセスを繰り返す排他制御方式は「スピンロック」と呼ばれる。本実施の形態では、スピンロックにおける共有資源110の専有を試みた回数、すなわちロック変数111の値を確認した2回目以降の回数を「スピン回数」と呼ぶ。たとえば、ロック変数111を確認した初回で「ゼロ」であった場合はスピン回数はゼロであり、ロック変数111を確認した3回目で初めて「ゼロ」であった場合はスピン回数は2である。また、共有資源110を使用するために、初回にロック変数111の値を確認してからロック変数111に「1」を代入できるまでの時間を「ロック待ち時間」と呼ぶ。さらに、ロック変数111を「ゼロ」から「1」に書き換えて共有資源110を排他制御することを「ロック取得」とも呼ぶ。
 このロック取得を行うのが、第1ロック取得部161および第2ロック取得部171である。第1ロック取得部161は第1CPU160が共有資源110を使用する場合に動作し、第2ロック取得部171は第2CPU170が共有資源110を使用する場合に動作する。第1ロック取得部161および第2ロック取得部171による、ロック変数111の確認、およびロック変数111が「ゼロ」であった場合の「1」の代入は、TEST-and-SET命令としてアトミックに実行される。すなわち、変数の確認と変数への代入は他のCPUからは一連の動作として割り込まれることなく実行される。
 第1カウンタ記録部162、および第2カウンタ記録部172は、第1ロック取得部161および第2ロック取得部171によるロック取得後に、ロック変数111の値などを第1バッファ151および第2バッファ152に格納する。第1カウンタ記録部162、および第2カウンタ記録部172の動作は後に詳述する。
 タイマ120は、時刻を管理するハードウェアである。タイマ120は、時刻情報を示す時刻レジスタ121を備える。時刻情報は、絶対時刻であってもよいし、電子制御装置100の電源がオンにされた時点など所定の時刻を基準、たとえばゼロとする相対時刻であってもよい。
 メモリ130は、記憶装置であり、CPUによって実行されるプログラム及びデータが保持される。メモリ130は、その機能として更新カウンタ格納部140と、ログ格納部150とを備える。なお、共有資源110、メモリ130、およびタイマ120は、それぞれ電子制御装置100上のCPUと独立したハードウェアであってもよいし、SoC(System-on-Chip)のように一つの半導体チップ上に統合されていてもよい。
 更新カウンタ格納部140には、第1カウンタ141、および第2カウンタ142が格納される。第1カウンタ141は、第1CPU160により更新されるカウンタ値であり、第1CPU160のスピン回数を示す。第2カウンタ142は、第2CPU170により更新されるカウンタ値であり、第2CPU170のスピン回数を示す。第1カウンタ141、および第2カウンタ142の初期値はゼロであり、更新によりそれぞれ1ずつ増加される。
 ログ格納部150は、第1バッファ151、および第2バッファ152を備える。第1バッファ151には第1CPU160が実行したプログラムのログが格納される。第2バッファ152には第2CPU170が実行したプログラムのログが格納される。ログ格納部150に格納されたログは、後述するログ出力部180を経由して解析装置200に出力される。
 ログ出力部180は、解析装置200のログ収集部270と通信を行うインタフェースである。ログ出力部180はたとえば、JTAGなどのデバッグ用インタフェース、またはCAN(CarAreaNetwork)やIEEE802.3に対応する通信インタフェースである。ログ出力部180は、解析装置200からの要求に応じて、または一定時間ごとに解析装置200にログを出力する。
(解析装置の構成)
 解析装置200は、メモリ210と、ログ解析部220と、表示部230と、CPU260と、ログ収集部270とを備える、たとえばコンピュータである。メモリ210には、電子制御装置100の各CPUのログが集約される収集バッファ211、スピン回数と時間の関係を示す時間変換テーブル212、およびログ解析部220により出力される解析結果213が格納される。
 ログ解析部220は、収集バッファ211に格納されるログを時間変換テーブル212を用いて解析する。換言するとログ解析部220は、スピン回数として記録されているロック待ち時間を実時間に変換する。ログ解析部220が解析した結果は、解析結果213としてメモリ210に格納されるとともに表示部230に表示される。
 表示部230は、収集バッファ211に格納されるログ、およびログ解析部220により出力された解析結果213を表示する。ただし表示部230は、解析装置200に接続された表示装置に表示すべき情報を出力する装置であってもよい。CPU260は、解析装置200を動作させる演算装置である。CPU260のアーキテクチャ、コア数、ソケット数、動作速度等は特に限定されない。
 ログ収集部270は、電子制御装置100のログ出力部180と通信を行うインタフェースである。ログ収集部270はたとえば、JTAGなどのデバッグ用インタフェース、またはCANやIEEE802.3に対応する通信インタフェースである。ログ収集部270は、電子制御装置100から受信するログを収集バッファ211に格納する。
(動作例)
 図2を用いて第1CPU160および第2CPU170の動作例を説明する。図2に示すタイムチャートは、第1CPU160および第2CPU170が実行するタスク、およびロック取得を示している。図示左から右に向かって時間が経過している。図2の上部に示す数字は時刻レジスタ121から得られる時刻を示している。後に図3、図4を用いて説明する、第1バッファ151、および第2バッファ152に格納されるログは図2に示す動作により得られたログである。なお以下では、複数回実行される共有資源110の排他制御、すなわちロック取得のそれぞれを便宜的に区別するために、実行される順番に、ロックL,ロックM,ロックN、・・・と呼ぶ。
 第1CPU160は、時刻850から時刻910までの間タスクAを実行しており、時刻880に割り込みRが発生し、時刻900まで割り込みRが継続する。第1CPU160は、時刻860にロックLの取得を開始し、時刻885にロックNの取得を開始し、時刻900の少し前にロックOの取得を開始している。第2CPU170は、時刻840から時刻920までの間タスクBを実行しており、時刻870に割り込みQが発生し、時刻890まで割り込みQが継続する。第2CPU170は、時刻880にロックMの取得を開始し、ロックMの取得後は共有資源110を使用して時刻885を経過した後に共有資源110の使用を終了した。また、第1CPU160のロックNの取得に関して、その時のスピン回数は300であり、その前に共有資源110を使用していたタスクは割り込みQである。それ以外のロック取得、すなわちロックL,ロックM,ロックOのスピン回数はゼロである。スピン回数がゼロの場合はロックの取得は即座に行われる。
(バッファの構成)
 図3、および図4は、第1バッファ151、および第2バッファ152に格納される情報の一例を示す図である。ここでは、図2に示す動作が行われた際に、第1バッファ151、および第2バッファ152に格納される情報を示している。第1バッファ151、および第2バッファ152の構成は同一なので、代表して第1バッファ151を説明する。第1バッファ151には、1または複数のレコードから構成されるログが格納される。第1バッファ151の各レコードは、イベント種類311、イベント内容312、タイムスタンプ313、待ち時間314、タスク情報315の5つのフィールドを備える。第1バッファ151の各レコードが、第1CPU160において実行されるプログラムの各イベントに対応する。
 イベント種類311のフィールドには、発生したイベントの種類、たとえば「タスク開始」、「ロック取得」などが格納される。イベント内容312のフィールドには、発生したイベントの対象、たとえば「タスクA」「割り込みR」などが格納される。たとえばイベント種類が「タスク開始」、イベント内容312が「タスクA」であれば、そのログは、そのCPUにおいてタスクAの実行が開始された、というイベントを表している。
 タイムスタンプ313のフィールドには、イベントが発生した時刻の情報が格納される。時刻情報は、タイマ120の時刻レジスタ121から得られる。待ち時間314のフィールドには、第1カウンタ141から得られるロック待ち時間を示す情報、すなわちスピン回数が格納される。タスク情報315のフィールドには、スピン回数が1以上であるときにロック取得に成功した際のタスク情報112の値が格納される。以下では、あるフィールドに格納された値をフィールドの名称で呼ぶことがある。たとえば「イベント種類311のフィールドに格納された値がxx」であることを、「イベント種類311がxx」と記載することがある。
 各レコードのフィールドには、特定の条件で記録される、または特定の条件で記録されないものがある。
 タイムスタンプ313のフィールドには、以下の条件で記録がされない。すなわち、イベント種類311が「ロック取得」であり待ち時間314がゼロ(0)の場合は、タイムスタンプ313のフィールドには値が記録されない。それ以外の場合、すなわち第1CPU160が二回目以降のアクセスでロック取得できた場合に、タイムスタンプ313のフィールドには値が記録される。ロック取得の待ち時間がゼロの場合は時刻を記録する必要性に乏しく、さらに時刻の記録に要するオーバーヘッドが大きいからである。図3、および図4に示す例では、待ち時間314がゼロであるロックL,M,Oのイベントではタイムスタンプ313が記録されていない。
 待ち時間314のフィールドには、イベント種類311が「ロック取得」である場合に記録される。すなわち、イベント種類311が「ロック取得」以外の場合は、待ち時間314のフィールドには値が記録されない。前述のとおり、待ち時間314のフィールドにはスピン回数が格納されるので、スピンが発生しえない「ロック取得」以外のイベントでは記録が不可能だからである。図3および図4に示す例では、待ち時間314がゼロではないロックNのイベントのみタスク情報315が記録される。
 タスク情報315のフィールドには、イベント種類311が「ロック取得」であり待ち時間314がゼロ以外である場合、すなわち第1CPU160が二回目以降のアクセスでロック取得できた場合に、値が記録される。それ以外の場合はタスク情報315のフィールドには値が記録されない。ロック取得の待ち時間がゼロの場合は、直前に共有資源110を使用していたタスクを特定する必要性が乏しいからである。
 なお、図2と図3においては、第1バッファ151および第2バッファを単純な表として記載しているが、リングバッファのような構造であってもよく、また実際のデータ格納には、可変長のレコードを用いてもよい。
(時間変換テーブル)
 図5は、時間変換テーブル212の一例を示す図である。時間変換テーブル212は、第1バッファ151や第2バッファ152における待ち時間のフィールドに格納されたスピン回数と実時間の対応表であり、待ち時間321、実時間322のフィールドを備える。待ち時間321のフィールドには、待ち時間すなわちスピン回数が格納され、実時間322のフィールドには、待ち時間321に格納された待ち時間(スピン回数)の値に対応する実時間の値が格納される。図5には、待ち時間がゼロであれば実時間もゼロであり、待ち時間が「1」であれば実時間は「5マイクロ秒」であり、待ち時間が「1+n」であれば実時間は「5+4*nマイクロ秒」であることが示されている。
 たとえば図2および図3に示したロックNについて、時間変換テーブル212を用いることで以下のことがわかる。ロックNは、図3の待ち時間314に格納されている待ち時間の値が300、すなわち1+299であるため、ロックNを取得するのに要した実時間は5+4*299=1201マイクロ秒である。さらに、ロックNの取得を開始したのが時刻885なので、時刻885から1201マイクロ秒経過したときにロックNが取得されたことがわかる。
 なお、時間変換テーブル212に格納される情報は、図5に示したようなテーブル形式以外の情報であってもよい。すなわち、スピン回数と実時間の関係を適切に表す情報であれば、どのような形式の情報を時間変換テーブル212に格納してもよい。
(解析結果)
 図6は、解析装置200のログ解析部220が出力する解析結果213の一例を示す図である。解析結果213には、収集バッファ211に格納されたログを解析して得られた情報であって、待ち時間の発生したロック取得イベントの詳細が記される。解析結果213を構成するレコードのそれぞれはロック取得イベントにそれぞれ対応する。解析結果213は、処理CPU331と、発生処理332と、ロック333と、タイムスタンプ334と、実待ち時間335と、原因CPU336と、原因処理337との7つのフィールドから構成される。
 処理CPU331のフィールドには、そのロック取得イベントが発生したCPUの識別子、または名称が格納される。発生処理332のフィールドには、そのロック取得イベントを発生させたタスクもしくは割り込み処理の名称が格納される。ロック333のフィールドには、便宜的に設定したロックの名称が格納される。タイムスタンプ334のフィールドには、そのロック取得イベントが発生した時刻の情報が格納される。実待ち時間335のフィールドには、時間変換テーブル212を用いて変換されたロック取得までの待ち時間が格納される。原因CPU336のフィールドには、ロック取得において待ちの原因となったCPUの識別子または名称が格納される。原因処理337のフィールドには、ロック取得において待ちの原因となったタスクの識別子が格納される。待ちの原因となったCPU及びタスクとは、そのイベントにおいてロック取得を試みた際に、そのロックを保持していたCPUとそのCPUが実行していたタスクである。待ちの原因となったCPU及びタスクは、タスク情報112から特定される。
 図6の1レコード目を具体的に説明する。このレコードは、図3における4レコード目のログに基づき生成されている。第1CPU160が時刻185にロックNを取得するために、スピン回数300の待ちが発生した。そのため解析結果213では、処理CPU331に「第1CPU」、発生処理332に「割り込みR」、ロック333に「ロックN」、タイムスタンプ334に「185」が格納される。また、300回のスピンは、時間変換テーブル212によると1201マイクロ秒に相当するので、実待ち時間335のフィールドには「1201マイクロ秒」が格納される。直前に共有資源110を使用したタスクは割り込みQであり、そのタスクは第2CPU170により実行されたので、原因CPU336のフィールドには「第2CPU」、原因処理337のフィールドには「割り込みQ」が格納される。
(解析システム1の動作概要)
 解析システム1の動作概要を説明する。解析システム1の動作は、ログの収集と解析に大別される。ログの収集は電子制御装置100により実行され、ログの解析は解析装置200により実行される。
 電子制御装置100の第1CPU160および第2CPU170は、不図示のプログラムを実行することによりそれぞれソフトウエアを動作させる。これらのソフトウエアは、共有資源110の使用を必要とする。第1CPU160および第2CPU170は、ソフトウエアのイベントのログをログ格納部150に格納する。格納されるログは、タスクの実行開始と終了、割り込み処理の開始と終了、そして共有資源110を使用するためのロックの取得処理などである。本実施の形態では、ロックの取得処理のログに注目しているので、それ以外のログの記録処理の説明は省略する。
 第1CPU160は、第1ロック取得部161を用いてロックを取得し、取得したロックに関するログを第1カウンタ記録部162を用いて第1バッファ151に記録する。第2CPU170は、第2ロック取得部171を用いてロックを取得し、取得したロックに関するログを第2カウンタ記録部172を用いて第2バッファ152に記録する。ログ出力部180は、ログ格納部150に格納されたログを解析装置200に出力する。
 解析装置200のCPU260は、電子制御装置100から出力されたログをログ解析部220に解析させる。ログ解析部220が解析した結果は、解析結果213としてメモリ210に格納されるとともに表示部230に表示される。
 以下では、図7を用いて第1CPU160におけるロック取得の動作、およびロックに関するログの格納の動作を説明し、図8を用いてログ解析部220の動作を説明する。なお、第2CPU170におけるロック取得の動作、およびロックに関するログの格納の動作は、第1CPU160の動作と同様なので説明を省略する。
(ロック取得と記録のフローチャート)
 図7を用いて、第1CPU160による、ロック取得動作およびロック取得に関するログ記録動作を説明する。以下に説明する各ステップの実行主体は、第1CPU160である。
 ステップS400では、第1カウンタ141のカウンタ値をゼロにリセットする。続くステップS401では共有資源110を使用するために、前述のTEST-and-SET命令を用いてロックの取得を試みる。続くステップS402ではステップS401におけるロック取得が成功したか否かを判断し、成功したと判断する場合はステップS406に進み、失敗したと判断する場合はステップS403に進む。
 ステップS403では第1カウンタ141のカウンタ値をインクリメント、すなわち1増加させる。続くステップS404では、第1カウンタ141のカウンタ値が「1」であるか否かを判断する。カウンタ値が「1」であると判断する場合、すなわちステップS400が実行された後にステップS402で初めて否定判断された場合はステップS405に進む。カウンタ値が「1」以外であると判断する場合、すなわちステップS400が実行された後にステップS402で否定判断されたのが2回目以降である場合はステップS401に戻る。ステップS405では、時刻レジスタ121からタイムスタンプを取得し、ステップS401に戻る。
 ロックの取得に成功すると実行されるステップS406では、第1カウンタ141のカウンタ値がゼロであるか否かを判断する。ゼロであると判断する場合はステップS407に進み、ゼロ以外であると判断する場合はステップS408に進む。
 ステップS407では、第1バッファ151を記録対象として、以下の情報を第1カウンタ記録部162に記録させる。すなわち、第1CPU160において現在実行されているイベントの種類、すなわち「ロック取得」、イベントの内容、および第1カウンタ141のカウンタ値を記録させる。ステップS408では、第1バッファ151を記録対象として、以下の情報を第1カウンタ記録部162に記録させる。すなわち、第1CPU160において現在実行されているイベントの種類、イベントの内容、第1カウンタ141のカウンタ値、ステップS405において取得したタイムスタンプ、およびタスク情報112を記録させる。
 ステップS407またはステップS408の実行が終了すると実行されるステップS409では、タスク情報112に第1CPU160において現在実行されているタスクの情報を格納し、図7に示すフローチャートを終了する。
(ログ解析のフローチャート)
 図8は、収集バッファ211に収集されたログを解析し、解析結果213を出力するログ解析部220の動作を表すフローチャートである。以下に説明する各ステップの実行主体は解析装置200のCPU260である。
 ステップS501では、収集バッファ211にログが収納されているいずれかのCPUを処理対象として選択してステップS502に進む。後述するように、ステップS501とステップS509の間、すなわちステップS502~ステップS508の処理を、収集バッファ211にログが収納されている全てのCPUについて実行する。
 ステップS502では、処理対象に選択されたCPUのいずれかのログを処理対象として選択してステップS503に進む。後述するように、ステップS502とステップS508の間、すなわちステップS503~ステップS507の処理を、処理対象のCPUの全てのログについて実行する。
 ステップS503では、処理対象のログのイベント種類311が「ロック取得」であるか否かを判断し、「ロック取得」であると判断する場合はステップS504に進み、それ以外であると判断する場合はステップS508に進む。
 ステップS504では、処理対象のログの待ち時間が「1」以上であるか否かを判断し、「1」以上であると判断する場合はステップS505に進み、それ以外、すなわちゼロであると判断する場合はステップS508に進む。
 ステップS505では、処理対象のログのタスク情報315のフィールドの値に基づきそのタスクを実行していたCPUを特定する。続くステップS506では、処理対象のログの待ち時間314のフィールドの値を、時間変換テーブル212を用いて実時間に変換してステップS507に進む。
 ステップS507では、処理対象のログの情報を解析結果213に記録する。このとき解析結果213の各フィールドに記録する値は、以下のとおりである。処理CPU331は、ステップS502~S508のループにおいて現在処理対象のCPUの名称である。発生処理332の値は、処理対象のログの直前のログにおけるイベント内容312の値である。ロック333の値は、処理対象のログにおけるイベント内容312の値である。タイムスタンプ334の値は、処理対象のログにおけるタイムスタンプ331の値である。実待ち時間335の値は、ステップS506において算出された実時間である。原因CPU336の値は、ステップS505において特定されたCPUの名称である。原因処理337の値は、処理対象のログにおけるタスク情報315の値である。
 続くステップS508では、処理対象のCPUの全てのログを処理対象としたか否かを判断する。未処理のログがあると判断する場合は未処理のログのいずれかを処理対象としてステップS503に戻り、全てのログを処理したと判断する場合はステップS509に進む。
 ステップS509では、収集バッファ211にログが格納されている全てのCPUを処理対象としたか否かを判断する。未処理のCPUがあると判断する場合は未処理のCPUのいずれかを処理対象としてステップS502に戻り、全てのCPUを処理したと判断する場合は図8のフローチャートを終了する。
 上述した第1の実施の形態によれば、次の作用効果が得られる。
(1)電子制御装置100は、複数のCPU、すなわち第1CPU160および第2CPU170と、共有資源110とを備える。CPUのそれぞれは、排他制御により共有資源110を独占して使用可能である。CPUのそれぞれは、カウンタ値が格納される更新カウンタ格納部140と、カウントが完了したカウント値を含む、第1CPU160および第2CPU170が実行したプログラムのログが格納されるログ格納部150とを備える。CPUは、CPUが共有資源110にアクセスしたときに、更新カウンタ格納部140に格納されたカウンタ値を更新させるカウンタ更新部、すなわち第1ロック取得部161および第2ロック取得部171と、CPUが共有資源110にアクセスしたときに、共有資源110が他のCPUにより排他制御されていない場合には、更新カウンタ格納部140に格納されたカウンタ値を含むログをログ格納部150に記録するカウンタ記録部、すなわち第1カウンタ記録部162および第2カウンタ記録部172とを備える。
 電子制御装置100は、CPUが共有資源110にアクセスしたときに、共有資源110が他のCPUにより排他制御されている場合、すなわちロック変数111が「1」の場合にはカウンタの値を更新する。そのため、タイマ120へのアクセスによるオーバーヘッドを生じさせることなく、アクセスが生じたことをカウンタ値の更新として更新カウンタ格納部140に記録することができる。なお、更新カウンタ格納部140に格納されるカウンタ値は、ロック取得を試みた2回目以降の回数、すなわちスピン回数を表す。
 また電子制御装置100は、共有資源110が他のCPUにより排他制御されていない場合、すなわちロック変数111がゼロの場合には、オーバーヘッドの大きいタイマ120へのアクセスを行うことなく、更新カウンタ格納部140に格納されたカウント値をログ格納部150に格納する。そのため、ログを記録するためのオーバーヘッドが小さい。この利点は特に、待ち時間がゼロであった場合に顕著である。たとえば待ち時間の算出は、待ち時間の開始時と終了時にそれぞれタイマから時刻を取得し、2つの時刻の差を待ち時間として算出する手法が広く行われているが、この手法ではタイマ120へのアクセスが2回行われる。時刻の取得に要する時間はロックの取得に要する時間よりも長く、さらに時刻の取得が2回も行われるため、待ち時間の算出のオーバーヘッドが大きくなってしまう問題がある。しかし本発明によればこのような問題を生じさせることなく、待ち時間を記録することができる。
(2)電子制御装置100のCPUは、CPUが共有資源110にアクセスして所定の処理単位を実行する毎に、すなわちスピンロックが実行されるごとに更新カウンタ格納部140に格納されたカウンタの値を変化させる。
 そのため、実行間隔および実行時間が既知であるスピンロックの実行回数を記録することで、オーバーヘッドの大きいタイマへのアクセスを行うことなく、待ち時間を記録することができる。
(3)電子制御装置100は、時刻情報を保持するタイマ120を備える。CPUが共有資源110に一回目にアクセスしたときに、共有資源110が他のCPUにより排他制御されている場合は、時刻情報をタイマ120から取得し、時刻情報をさらに含むログをログ格納部150に格納する。
 そのため、タイマ120へのアクセスのオーバーヘッドを隠蔽しつつ、待ち時間が生じた時刻を記録することができる。カウンタが更新されたことは、共有資源110が他のCPUにより使用されており、ロック取得を試みたCPUは所定時間の経過後に再度ロック取得を試みることを意味する。そのため、ロック取得を試みたCPUがタイマ120へアクセスしても、そのオーバーヘッドは少なくとも一部が隠蔽されることになる。この効果は、第1CPU160および第2CPU170の少なくとも一方が、以下の特徴を有する場合に顕著である。すなわち、CPUが、スピン時にバス占有を防ぐためにCPUを一定時間停止する命令を発行する特徴を有する場合に効果が顕著である。
(4)共有資源110は、CPUが実行している処理を識別する識別情報を格納する識別情報格納部、すなわちタスク情報112を記憶する領域を備える。カウンタ記録部、すなわち第1カウンタ記録部162および第2カウンタ記録部172は、CPUが2回目以降のアクセスで共有資源110を排他制御した場合に、識別情報格納部から識別情報、すなわちタスク情報112を取得し、タスク情報112をさらに含むログをログ格納部150に格納する。
 そのため、待ち時間を発生させた処理、すなわち従前に共有資源110を使用していた処理の識別情報をログ格納部150に記録することができる。
(5)カウンタ更新部、すなわち第1ロック取得部161および第2ロック取得部171は、共有資源110を排他制御した場合に、CPUが実行している処理に基づき識別情報格納部の識別情報を更新する。
 タスク情報112に共有資源110を使用しているタスクの情報を格納するので、あるCPUが共有資源110を使用できなかった場合に、その原因となっていた処理、すなわち従前に共有資源110を使用していた処理を特定させることが可能となる。
(6)解析システム1は、電子制御装置100と、解析装置200とを備える。解析装置200は、電子制御装置100のログ格納部150に格納された情報が入力されるログ収集部270と、カウンタ値を実時間に換算するための換算情報、たとえば時間変換テーブル212を格納する記憶部、すなわちメモリ210と、換算情報を用いて、ログ収集部270に入力されたカウンタ値を実時間に換算するログ解析部220と、を備える。
 そのため解析装置200は、電子制御装置100が記録したカウンタ値を実時間に変換できる。すなわち解析システム1は、共有資源110の排他制御による待ち時間をスピン回数として記録することで記録時のオーバーヘッドを低減しつつ、その記録したスピン回数を解析装置200を用いて実時間に変換することができる。
(変形例1)
 第1バッファ151および第2バッファ152の待ち時間314には、タイマ120から取得した時刻を格納してもよい。すなわち図7のステップS408において、時刻レジスタ121からタイムスタンプを取得して格納してもよい。この場合は、解析装置200は、タイムスタンプ313に格納された時刻と待ち時間314に格納された時刻との差を演算することによりロック取得のために待機した実時間を算出する。
 この変形例1によれば、解析装置200は時間変換テーブル212を備える必要がないという第1の利点、およびより正確な待ち時間算出を行うことができるという第2の利点を有する。なお、待ち時間がゼロとなる場合以外は、時刻レジスタ121にアクセスして時刻を取得してもそのオーバーヘッドの影響は相対的に小さく、デメリットは小さい。
(変形例2)
 第1カウンタ141は、第1CPU160のレジスタや第1CPU160が備える不図示のメモリに格納されてもよい。同様に第2カウンタ142は、第2CPU170のレジスタや第2CPU170が備える不図示のメモリに格納されてもよい。
 この変形例2によれば、高速なアクセスが可能な同一CPU内で書き換えが行われるので、カウンタ値の初期化および更新のオーバーヘッドを低減することができる。
(変形例3)
 第1カウンタ141が独立して設けられず、第1バッファ151が第1カウンタ141の役割も兼ねてよい。この場合は第1ロック取得部161は、第1カウンタ141に格納されるカウンタ値を初期化および更新する代わりに、第1バッファ151の待ち時間314のフィールドにカウンタの初期値であるゼロを書き込み、更新する。同様に第2カウンタ142が独立して設けられず、第2バッファ152が第2カウンタ142の役割も兼ねてよい。
(変形例4)
 電子制御装置100は、3つ以上のCPUを備えてもよい。また電子制御装置100は、単一のパッケージに収められ複数のコアを有するCPUを1つ備えてもよい。単一のパッケージに収められ複数のコアは、同一であってもよいし異なっていてもよい。さらに、各CPUコアのアーキテクチャ及び動作速度は同一であってもよいし、異なっていてもよい。
(変形例5)
 メモリ130は、CPUごとに独立していてもよい。この場合には、ログ格納部150および更新カウンタ格納部140には、それぞれのCPUごとのメモリ130に存在する。さらに、プログラムを保持する不揮発性メモリとデータを保持する揮発性メモリに分かれている構成であってもよい。
(変形例6)
 電子制御装置100が第3のCPUを備え、その第3のCPUが第1ロック取得部161、第1カウンタ記録部162、第2ロック取得部171、および第2カウンタ記録部172の少なくとも1つを実行してもよい。また、第1ロック取得部161、第1カウンタ記録部162、第2ロック取得部171、および第2カウンタ記録部172の少なくとも1つが、ハードウエア回路により実行されてもよい。
(その他の変形例)
 上述した第1の実施の形態をさらに以下のように変形してもよい。
(1)電子制御装置100がタイマを複数備え、CPUごとに異なるタイマを参照してもよい。この場合は、各CPUの用いている時刻レジスタ121の値の差を記録するなど、補正処理を行う。
(2)第1カウンタ記録部162および第2カウンタ記録部172は、図7のステップS408においてタスク情報112を記録しなくてもよい。この場合は、第1ロック取得部161および第2ロック取得部171は、図7のステップS409におけるタスク情報112の更新を実行しなくてよく、第1バッファ151および第2バッファ152がタスク情報315のフィールドを備えなくてもよい。
(3)第1ロック取得部161および第2ロック取得部171は、カウンタ値にかかわらずタイムスタンプを取得しなくてもよい。すなわち、図7のステップS403を実行したらカウンタ値を評価することなくステップS401に戻ってもよい。
(4)電子制御装置100は、共有資源110を複数備えてもよい。この場合、それぞれの共有資源110はロック変数111およびタスク情報112を独立して備える。
(第2の実施の形態)
 図9~図10を参照して、電子制御装置の第2の実施の形態を説明する。以下の説明では、第1の実施の形態と同じ構成要素には同じ符号を付して相違点を主に説明する。特に説明しない点については、第1の実施の形態と同じである。本実施の形態では、主に、電子制御装置がカウント値から実時間への換算を行う診断部を備える点で、第1の実施の形態と異なる。
 図9は、第2の実施の形態における電子制御装置100Aの構成を示す図である。電子制御装置100Aは、第1の実施の形態における電子制御装置100の構成からログ出力部180が削除され、診断部900が追加される。また、メモリ130には時間変換テーブル212および解析結果213がさらに格納される。特に説明しない構成、および動作は第1の実施の形態と同様である。
 診断部900は、第1CPU160および第2CPU170のいずれかが不図示のROMに格納されたプログラムを実行することにより実現される機能を機能ブロックとして表したものである。診断部900は、ログ格納部150に格納されたログを解析する。診断部900は、解析により異常を検出すると、たとえば待ち時間が所定の時間よりも長い場合は、所定の異常時処理を実行する。診断部900は、一定の時間が経過すると、または診断を要するような所定の事象が発生すると動作する。
(診断部のフローチャート)
 図10は第2の実施の形態における診断部900の動作を表すフローチャートである。以下では、図8に示したログ解析部220の動作を表したフローチャートとの差異を説明する。以下に説明する各ステップの実行主体は、第1CPU160および第2CPU170のいずれかである。以下ではこの実行主体を「CPU」とする。
 ステップS507までの処理はログ解析部220と同様なので説明を省略する。ステップS507の実行が完了すると、ステップS521を実行する。
 ステップS521では、ステップS506において変換した実時間が所定値以上であるか否かを判断する。所定値以上であると判断する場合はステップS522に進み、所定値未満であると判断する場合はステップS508に進む。
 ステップS522では所定の異常時処理を実行してステップS508に進む。異常時処理とはたとえば、最小構成の実行状態への移行、または異常検出した回数をカウントし所定の閾値に達した場合の電子制御装置100の再起動などである。
 上述した第2の実施の形態によれば、次の作用効果が得られる。
(1)電子制御装置100Aは、カウント値を時間に換算するための換算情報、たとえば時間変換テーブル212を格納する記憶部、すなわちメモリ130と、時間変換テーブル212を用いてカウンタ値を実時間に換算する解析部、すなわち診断部900と、を備える。
 そのため電子制御装置100Aは、解析装置200を用いることなくカウンタ値を実時間に換算することができる。これにより、図10のステップS521に示したように、換算した実時間を用いた診断を実行できる。
(第2の実施の形態の変形例)
 第2の実施の形態を以下のように変形してもよい。
(1)診断部900は、算出した待ち時間以外を診断に利用してもよい。たとえば、待ちの原因となったタスクが所定のものでなかった場合に、何らかの実行順序の異常が起きたと判定して、これを異常として診断してもよい。
(2)診断部900は、解析結果をメモリ130に記録しなくてもよい。
(3)電子制御装置100Aは、ログ出力部180をさらに備えてもよい。
(第3の実施の形態)
 図11~図13を参照して、電子制御装置の第3の実施の形態を説明する。以下の説明では、第1の実施の形態と同じ構成要素には同じ符号を付して相違点を主に説明する。特に説明しない点については、第1の実施の形態と同じである。本実施の形態では、主に、スピン回数ではなくベーシックブロックの実行回数をカウントする点で、第1の実施の形態と異なる。
(ベーシックブロック)
 ベーシックブロックとは、プログラムの実行単位であって、その単位中に分岐もしくは合流を含まないものである。ベーシックブロックは分岐や合流を含まないので、実行する環境、すなわちCPUやメモリ等が同一であれば、ベーシックブロックの実行時間は一定である。本実施の形態では3つのベーシックブロック(A,B,C)を用いて説明する。それぞれのベーシックブロックの電子制御装置100における実行時間は既知である。
(構成)
 解析システム1のハードウエア構成は第1の実施の形態と同様である。ただし第1カウンタ141と第2カウンタ142のそれぞれは、ベーシックブロックA,B,Cにそれぞれ対応する3つのカウンタ(A,B,C)を備える。また時間変換テーブル212として格納される情報が第1の実施の形態と異なる。さらに電子制御装置100の不図示のROMに格納されるプログラムが第1の実施の形態と異なり、第1ロック取得部161および第2ロック取得部171の動作が第1の実施の形態と異なる。
 図11は、本実施の形態における第1バッファ151の構造の一例を示した図である。第1バッファ151を構成するフィールドの構成は第1の実施の形態と同様であり、待ち時間314のフィールドに格納される値が異なる。すなわち待ち時間314のフィールドには、第1カウンタ141に格納されるカウンタA,カウンタB,カウンタCの値が格納される。これ以外の点は第1の実施の形態と同様である。図11に示す例では、ロックMの取得時に、ベーシックブロックAが3回、ベーシックブロックBが1回、ベーシックブロックCが2回実行されたことを示している。第2バッファ152の構成、および第2バッファ152に格納される情報は第1バッファ151と同様である。
 図12は、時間変換テーブル212Aの一例を示す図である。時間変換テーブル212Aには、それぞれのベーシックブロックに対応する時間が記録される。具体的には時間変換テーブル212Aは、ベーシックブロック番号323のフィールドと、時間324のフィールドとを備える。ベーシックブロック番号323のフィールドには、ベーシックブロックの識別子またはベーシックブロックの名称が格納される。時間324のフィールドには、ベーシックブロックの1回の実行に要する時間が格納される。
 なお、図11と図12に示す例によれば、各ベーシックブロックの実行時間から、ロックMの取得のための待ち時間は、3*20+1*38+2*19=136マイクロ秒と算出される。
(ロック取得部の動作)
 ロック取得部、すなわち第1ロック取得部161および第2ロック取得部171は、第1の実施の形態では、TEST-and-SET命令を用いてロックを取得したが、第3の実施の形態では、LoadLinked命令(以下、「LL命令」と呼ぶ)、およびStore Conditional命令(以下、「SC命令」と呼ぶ)を用いてロックを取得する。
 LL命令とは、指定されたメモリ領域をロードすると同時に、その領域に対して「リンク」を生成する命令である。この「リンク」は、他のCPUが同じ領域に書き込みを行うと消滅する。SC命令とは、指定されたメモリ領域に対して「リンク」が残存している場合に限り、値をストアする命令である。SC命令における「リンク」の残存の確認は、以下のことを意味する。すなわち、「リンク」が残存していることは、LL命令からSC命令までの間に、他のCPUが同じ領域に書き込みを行っていないことを示している。すなわちこれにより、読み込みと書き込みのアトミシティの保証、つまり読み込みと書き込みが不可分の一体として成功したことが保証される。
(フローチャート)
 図13は、第3の実施の形態における第1CPU160による、ロック取得動作およびロック取得に関するログ記録動作を示すフローチャートである。図13に示すように、ステップS451がベーシックブロックA、ステップS454がベーシックブロックB、ステップS455がベーシックブロックCである。それぞれのベーシックブロックを実行すると、各ベーシックブロックに対応するカウンタを更新する。図13に示すフローチャートは、第1の実施の形態における図7に相当する。以下では主に図7との相違点を説明する。
 ステップS400Aでは、第1カウンタ141のカウンタA~Cをゼロにリセットし、ステップS451に進む。ステップS451ではLL命令を用いてロック変数111を読出してステップS452に進む。ステップS452ではカウンタAをインクリメント、すなわちカウンタ値を1増加させてステップS453に進む。
 ステップS453では、ステップS451において読みだしたロック変数111がゼロであったか否かを判断する。CPUは、ゼロであると判断する場合はステップS455に進み、ゼロでないと判断する場合はステップS454に進む。
 ステップS454では、ステップS451において生成したリンクを破棄する。続くステップS403Aでは、カウンタBをインクリメントしてステップS404Aに進む。ステップS404AではカウンタBとカウンタCのカウンタ値の和が「1」であるか否かを判断する。カウンタ値が「1」であると判断する場合はステップS405に進み、カウンタ値が「1」以外であると判断する場合はステップS451に戻る。ステップS405では、時刻レジスタ121からタイムスタンプを取得し、ステップS451に戻る。
 ステップS455では、SC命令を用いてロック変数111に「1」を書き込む。続くステップS456では、カウンタCをインクリメントする。続くステップS457ではステップS455における書き込みが成功したか否かを判断し、成功したと判断する場合はステップS406Aに進み、失敗したと判断する場合はステップS404Aに進む。ステップS406Aでは、カウンタBのカウンタ値がゼロであるか否かを判断する。ゼロであると判断する場合はステップS407に進み、ゼロ以外であると判断する場合はステップS408に進む。
ステップS407以降の処理は第1の実施の形態と同様なので説明を省略する。
 上述した第3の実施の形態によれば、次の作用効果が得られる。
(1)カウンタ更新部、すなわち第1ロック取得部161および第2ロック取得部171は、共有資源110にアクセスしたときに、所定の処理単位が実行される毎に、すなわち各ベーシックブロックが実行されるごとに更新カウンタ格納部140に格納された、それぞれのベーシックブロックに対応するカウンタの値を更新させる。
 そのため、実行間隔および実行時間が既知であるベーシックブロックの実行回数を記録することで、オーバーヘッドの大きいタイマへのアクセスを行うことなく、待ち時間を記録することができる。
(2)カウンタ更新部、すなわち第1ロック取得部161および第2ロック取得部171は、共有資源110が他のCPUにより排他制御されている場合に、カウンタBまたはカウンタCのカウンタ値を変化させる。そのため、共有資源110にアクセスしたが排他制御できなかった回数を記録することができる。
第1の実施の形態と異なり、第3の実施の形態では、共有資源110が他のCPUにより排他制御されている場合には、ステップS453でゼロであると判断する場合と、後述のステップS457で書き込みが失敗したと判断する場合の二通りがある。カウンタBとカウンタCのカウンタ値の和を用いることで、排他制御できなかった回数を記録することができる。
また、ステップS404Aにおいては、カウンタBとカウンタCのカウンタ値の和「1」であるかと判断することにより、いずれの場合によったとしても、排他制御できなかった1回目の場合に時刻を取得することができ、第1の実施形態と同様に、オーバーヘッドを隠蔽しつつ待ち時間が生じた時刻を記録する効果を得ることができる。
(変形例)
 第3の実施の形態では、ベーシックブロックの実行回数をカウントしたが、これより細かい粒度での処理の回数をカウントしてもよいし、荒い粒度での処理の回数をカウントしてもよい。例えば、細かい粒度でのカウントとして、CPUの命令ごとにカウントする構成が考えられる。この場合は、ログ格納部150には、CPUの各命令ごとの実行時間が格納されることになる。また、命令ごとにカウントする場合は、ソフトウェアでこれを実現することは極めてオーバーヘッドが高いため、CPU等のハードウェア回路を用いてカウントすることが望ましい。ハードウェアによる命令ごとの計数を行う方法によれば、ベーシックブロックごとの実行回数を計数するようにソフトウェアを変更する必要がなく、相対的にオーバーヘッドを減らす効果が得られる。
 なお、第1の実施形態においても、更新カウンタ格納部140に格納されたカウンタのインクリメント処理はソフトウェアで行う必要はない。たとえば、CPUの一つまたは複数のレジスタとしてカウンタが実装され、CPUが特定の命令を実行した場合に、対応するカウンタが加算される形であってもよい。この場合はたとえば、図7のステップS407およびステップS408においてログ格納部150に記録される待ち時間314は、ハードウェアから読みだしたカウンタの値となる。この場合も、第1の実施の形態の作用効果に加えて、オーバーヘッドをさらに減らす効果が得られる。
 プログラムは不図示のROMに格納されるとしたが、プログラムはメモリ130に格納されていてもよい。また、電子制御装置100が不図示の入出力インタフェースを備え、必要なときに入出力インタフェースと電子制御装置100が利用可能な媒体を介して、他の装置からプログラムが読み込まれてもよい。ここで媒体とは、例えば入出力インタフェースに着脱可能な記憶媒体、または通信媒体、すなわち有線、無線、光などのネットワーク、または当該ネットワークを伝搬する搬送波やディジタル信号、を指す。また、プログラムにより実現される機能の一部または全部がハードウエア回路やFPGAにより実現されてもよい。
 上述した各実施の形態および変形例は、それぞれ組み合わせてもよい。
 上記では、種々の実施の形態および変形例を説明したが、本発明はこれらの内容に限定されるものではない。本発明の技術的思想の範囲内で考えられるその他の態様も本発明の範囲内に含まれる。
 次の優先権基礎出願の開示内容は引用文としてここに組み込まれる。
 日本国特許出願2016年第169607号(2016年8月31日出願)
1 … 解析システム
100、100A … 電子制御装置
110 … 共有資源
111 … ロック変数
112 … タスク情報
120 … タイマ
140 … 更新カウンタ格納部
150 … ログ格納部
160 … 第1CPU
161 … 第1ロック取得部
162 … 第1カウンタ記録部
170 … 第2CPU
171 … 第2ロック取得部
172 … 第2カウンタ記録部
200 … 解析装置
211 … 収集バッファ
212、212A … 時間変換テーブル
220 … ログ解析部
230 … 表示部
900 … 診断部

Claims (8)

  1.  複数のCPUコアと、共有資源とを備える電子制御装置であって、
     前記CPUコアのそれぞれは排他制御により前記共有資源を独占して使用可能であり、
     カウンタ値が格納される更新カウンタ格納部と、
     前記CPUコアが実行したプログラムのログが格納されるログ格納部と、
     前記CPUコアが前記共有資源にアクセスしたときに、前記カウンタ値を変化させるカウンタ更新部と、
     前記CPUコアが前記共有資源にアクセスしたときに、前記共有資源が他のCPUコアにより排他制御されていない場合には、前記カウンタ値を含む前記ログを前記ログ格納部に記録するカウンタ記録部とをさらに備える電子制御装置。
  2.  請求項1に記載の電子制御装置であって、
     前記カウンタ更新部は、前記CPUコアが前記共有資源にアクセスしたときに前記共有資源が他のCPUにより排他制御されている場合に、前記カウンタ値を変化させる電子制御装置。
  3.  請求項1に記載の電子制御装置であって、
     前記カウンタ更新部は、前記CPUコアが前記共有資源にアクセスして所定の処理単位を実行する毎に、前記カウンタ値を変化させる電子制御装置。
  4.  請求項1に記載の電子制御装置であって、
     時刻情報を保持するタイマを更に備え、
     前記カウンタ記録部は、前記CPUコアが前記共有資源に一回目にアクセスしたときに、前記共有資源が他のCPUコアにより排他制御されている場合は、時刻情報を前記タイマから取得し、前記時刻情報をさらに含む前記ログを前記ログ格納部に格納する電子制御装置。
  5.  請求項1に記載の電子制御装置であって、
     前記共有資源は、前記CPUコアが実行している処理を識別する識別情報を格納する識別情報格納部を備え、
     前記カウンタ記録部は、前記CPUコアが二回目以降のアクセスで前記共有資源を排他制御した場合に、前記識別情報格納部から前記識別情報を取得し、前記識別情報をさらに含む前記ログを前記ログ格納部に格納する電子制御装置。
  6.  請求項5に記載の電子制御装置であって、
     前記カウンタ更新部は、前記CPUコアが前記共有資源を排他制御した場合に、前記CPUコアが実行している処理に基づき前記識別情報格納部の前記識別情報を更新する電子制御装置。
  7.  請求項1から請求項6までのいずれか一項に記載の電子制御装置であって、
     前記カウンタ値を時間に換算するための換算情報を格納する記憶部と、
     前記換算情報を用いて前記カウンタ値を実時間に換算する解析部と、を備える電子制御装置。
  8.  請求項1から請求項6までのいずれか一項に記載の電子制御装置と、解析装置と、を備える解析システムであって、
     前記解析装置は、
     前記電子制御装置の前記ログ格納部に格納された前記ログが入力されるログ収集部と、
     前記カウンタ値を実時間に換算するための換算情報を格納する記憶部と、
     前記換算情報を用いて、前記ログ収集部に入力された前記カウンタ値を実時間に換算する解析部と、を備える解析システム。
PCT/JP2017/026375 2016-08-31 2017-07-20 電子制御装置、解析システム WO2018042935A1 (ja)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
JP2016-169607 2016-08-31
JP2016169607A JP6666216B2 (ja) 2016-08-31 2016-08-31 電子制御装置、解析システム

Publications (1)

Publication Number Publication Date
WO2018042935A1 true WO2018042935A1 (ja) 2018-03-08

Family

ID=61300769

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/JP2017/026375 WO2018042935A1 (ja) 2016-08-31 2017-07-20 電子制御装置、解析システム

Country Status (2)

Country Link
JP (1) JP6666216B2 (ja)
WO (1) WO2018042935A1 (ja)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2023019077A (ja) * 2021-07-28 2023-02-09 日立Astemo株式会社 車載処理装置
JP7448585B2 (ja) * 2022-05-31 2024-03-12 トヨタ自動車株式会社 情報処理装置、情報処理方法、及び情報処理プログラム

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH0566972A (ja) * 1991-09-06 1993-03-19 Nippon Telegr & Teleph Corp <Ntt> ロツク区間の自動解析方法と平均命令実行時間の計算方法
JPH05257902A (ja) * 1992-03-10 1993-10-08 Fujitsu Ltd 処理プログラム・モードにおけるロック獲得処理方式
JPH1185574A (ja) * 1997-09-11 1999-03-30 Nec Corp ロック動作測定方法
JP2001084235A (ja) * 1999-09-10 2001-03-30 Nec Corp ロック粒度統計情報を利用した排他制御方法及びプログラムを記録した機械読み取り可能な記録媒体
JP2001297008A (ja) * 1999-11-22 2001-10-26 Sun Microsyst Inc オブジェクトごとのロック履歴に基づくロック方針選択方法および装置
JP2009251871A (ja) * 2008-04-04 2009-10-29 Nec Corp 競合分析装置、競合分析方法、およびプログラム

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP6009518B2 (ja) * 2014-10-15 2016-10-19 三菱電機株式会社 電子制御装置

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH0566972A (ja) * 1991-09-06 1993-03-19 Nippon Telegr & Teleph Corp <Ntt> ロツク区間の自動解析方法と平均命令実行時間の計算方法
JPH05257902A (ja) * 1992-03-10 1993-10-08 Fujitsu Ltd 処理プログラム・モードにおけるロック獲得処理方式
JPH1185574A (ja) * 1997-09-11 1999-03-30 Nec Corp ロック動作測定方法
JP2001084235A (ja) * 1999-09-10 2001-03-30 Nec Corp ロック粒度統計情報を利用した排他制御方法及びプログラムを記録した機械読み取り可能な記録媒体
JP2001297008A (ja) * 1999-11-22 2001-10-26 Sun Microsyst Inc オブジェクトごとのロック履歴に基づくロック方針選択方法および装置
JP2009251871A (ja) * 2008-04-04 2009-10-29 Nec Corp 競合分析装置、競合分析方法、およびプログラム

Also Published As

Publication number Publication date
JP2018036864A (ja) 2018-03-08
JP6666216B2 (ja) 2020-03-13

Similar Documents

Publication Publication Date Title
US8978017B2 (en) Profiling operating context
US9996394B2 (en) Scheduling accelerator tasks on accelerators using graphs
US9703670B2 (en) Performance state machine control with aggregation insertion
US9128749B1 (en) Method and system for lock free statistics collection
US9760411B2 (en) Switching a locking mode of an object in a multi-thread program
US20140365833A1 (en) Capturing trace information using annotated trace output
US20140215483A1 (en) Resource-usage totalizing method, and resource-usage totalizing device
WO2018042935A1 (ja) 電子制御装置、解析システム
US9009537B2 (en) Diagnostic data capture in a computing environment
US20130305012A1 (en) Implementation of counters using trace hardware
US8966323B2 (en) Monitoring multiple data transfers
CN107451038B (zh) 硬件事件采集方法、处理器和计算系统
US20210081297A1 (en) Trace-data processing device
US8762126B2 (en) Analyzing simulated operation of a computer
US10956303B2 (en) Trace data representation
US11645124B2 (en) Program execution control method and vehicle control device
JP2004192052A (ja) ソフトウェア処理方法およびソフトウェア処理システム
CN111078449B (zh) 信息处理方法、信息处理装置及终端设备
CN109634766B (zh) 提升数据流机运行效率的方法、装置、设备及存储介质
KR102651864B1 (ko) 하드웨어 액세스 카운터 및 다중 스레드 처리를 조정하기 위한 이벤트 생성
US8584143B2 (en) Collection access in a parallel environment
CN110955546B (zh) 一种内存地址监控方法、装置及电子设备
US11347505B2 (en) Processor performance monitor that logs reasons for reservation loss
JP2005165825A (ja) トレース情報記録装置
WO2017019054A1 (en) Systems and methods facilitating multi-word atomic operation support for system on chip environments

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: 17845945

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: 17845945

Country of ref document: EP

Kind code of ref document: A1