A multi-task control template has been established for diesel engine control system in this paper. By analyzing the function requirements and control strategies of electronic diesel engine control system, the data flow diagram has been obtained. Based on the mechanisms and characteristics of the RTOS as well as the design methods of real-time system software, modules in data flow graph has been divided further. So that the multi-tasks of the control system have been drawn. Then each task's properties have been designed. Afterwards, every task and the embedded RTOS have been transplanted into Freescale MPC5554 microcontroller. After that the multi-tasks have been tested and optimized in a Hardware-in-the-Loop Simulation (HILS) system of dSPACE AUTOBOX. The results show good reusability and real-time performance and it can increase the efficiency of the diesel engine control software development.