This paper proposes a control method for allowing aggregates of thermostatically controlled loads to provide synthetic inertia and primary frequency regulation services to the grid. The proposed control framework is fully distributed and basically consists in the modification of the thermostat logic as a function of the grid frequency. Three strategies are considered: in the first one, the load aggregate provides synthetic inertia by varying its active power demand proportionally to the frequency rate of change; in the second one, the load aggregate provides primary frequency regulation by varying its power demand proportionally to frequency; in the third one, the two services are combined. The performances of the proposed control solutions are analyzed in the forecasted scenario of the electric power system of Sardinia in 2030, characterized by a huge installation of wind and photovoltaic generation and no coil and combustible oil power plants. The considered load aggregate is composed by domestic refrigerators and water heaters. Results prove the effectiveness of the proposed approach and show that, in the particular case of refrigerators and water heaters, the contribution to the frequency regulation is more significant in the case of positive frequency variations. Finally, the correlation between the regulation performances and the level of penetration of the load aggregate with respect to the system total load is evaluated.