| Tn this paper, RTW is introduced first, including the code generation procedure and the architecture of generated code. Next, this paper discusses how to make the generated code run in Red Hat Linux 9.0. Especially, the method and implementation of how to download generated code to target machine automatically are researched. So, a real-time simulation platform based on simulink/RTW~Linux is successfully built. After that, to achieve the goal of real-time simulation, Linux is amply analyzed as an operating system with source code in memory management, timer interrupt and process scheduling. Three methods are put forward to improve real-time performance of user' program: setting the process' scheduling policy, shutting down the swap area and locking the memory. At the same time, from the view of real-time control of simulation program, two real-time control ways, which are interval timer and single process, are studied. At last, using a simulink model named F-14 and choosing the actual error of simulation step as the typical real-time performance measure, the improving effect of the methods discussed above to real-time simulation performance is measured and analyzed under different simulation steps. The results show that the simulation platform supports real-time simulation with minimum step of 10ms under interval timer real-time control way, and real-time simulation with minimum step of 1ms under single process real-time control way. |