The wide applications of cyber-physical systems (CPS) call for effective design strategies that optimize the performance of both computing units and physical plants. We study the task scheduling problem for a class of CPS whose behaviors are regulated by feedback control laws. We codesign the control law and the task scheduling algorithm for predictable performance and power consumption for both the computing and the physical systems. We use a typical example, multiple inverted pendulums controlled by one processor, to illustrate our method.