First of all back up all your stuff. If the mac is running painfully slow, with the spinning beachball appearing all of the time then one thing to consider is that the hard disk may be packing up.
Apple is running a recall on certain iMac's made in 2011. You can check if you're affected
here.
While errant processes can slow a machine down, they should never really affect the speed of the user interface much. In virtually all cases of painfully slow macs I've had lately it's been down to a failing hard disk.