I have only recently installed Ubuntu 16.04 LTS in my machine. It is dual booted alongside Windows 10. I have an NVidia graphic card, Intel i5 7700 and 8gb RAM. Changing intel_idle.max_cstate = 1 did not help my problem.
The problem could be that the default open source driver is insufficient or ineffective for the machine.
Switch over from open source driver Xorg to proprietary drivers.
Under Software & Updates, go to Additional Drivers, and select both proprietary drivers(One in NVIDIA Corporation and one in Unknown).
'Using NVIDIA binary driver - version 384.90 from nvidia 384 (proprietary, tested)' and 'Using Processor microcode firmware for Intel CPUs from intel-microcode (proprietary)' are the two drivers to be selected. You might have a different driver that's proprietary under NVIDIA Corporation.
Apply changes and enter sudo reboot in terminal. This solved my problem.
In this picture, I have switched from open source to proprietary. Additional Drivers, Software and Updates