A Real-time Energy-Saving Mechanism in Internet of Vehicles Systems