Model Predictive Control (MPC) is one of the most successful techniques adopted in industry to control multivariable systems in an optimized way under constraints on input and output variables. In MPC, the manipulated inputs are computed in real-time by solving a mathematical programming problem, most frequently a Quadratic Program (QP). I will first introduce the basic concepts of MPC, showing how it can be used as the control component of a cyber-physical system (CPS). Since most CPS's run under fast sampling and limited CPU and memory resources, I will then cover methods to solve QP's within a CPS with high throughput, using simple code and executing arithmetic operations under limited machine precision, and with tight estimates of execution time, and show extensions to solve mixed-integer QPs. Finally, I will also show how MPC based on hybrid dynamical models can be used as an effective tool for control of cyber-physical systems.