tailieunhanh - Model-Based Design for Embedded Systems- Part 8

Model-Based Design for Embedded Systems- P8: This book contains information obtained from authentic and highly regarded sources. Reasonable efforts have been made to publish reliable data and information, but the author and publisher cannot assume responsibility for the validity of all materials or the consequences of their use. | 46 Model-Based Design for Embedded Systems Consideration of Task Switches In modern embedded systems software performance simulation has to handle task switching and multiple interrupts. Cooperative task scheduling can already be handled by the previously mentioned approach since the presented cache model is able to cope with nonpreemptive task switches. Interrupts and cooperative and nonpreemptive task scheduling can be handled similarly because the task preemption is usually implemented by using software interrupts. Therefore the incorporation of interrupts is discussed in the following. Software interrupts had to be included in the SystemC model. This has been achieved by the automatic insertion of dedicated preemption points after cycle calculation. This approach provides an integration of different user-defined task scheduling policies and a task switch generates a software interrupt. Since the cycle calculation is completed before a task switch is executed and a global cache and branch prediction model is used no other changes are necessary. A minor deviation of the cycle count for certain processes can occur because of the actual task switch that is carried out with a small delay caused by the projection of the task preemption at the binarycode level to the C C source-code level. But nevertheless the cumulative cycle count is still correct. The accuracy can be increased by the insertion of the cycle calculation code after each C C statement. If the additional delay caused by the context switch itself has to be included the binary code of the context switch routine can be treated like any other code. Preemption of Software Tasks For the modeling of unconditional time delays there is the function wait sc_time in SystemC. The call of wait At by a SystemC thread at the simulation time t suspends the calling thread until the simulation time t At is reached and after that it continues its execution with the proceeding instruction. The time that At .