CPU cycle / Clock cycle

Do you manually figure out how many CPU cycles are needed for each task before writing the code for real time system?

No. What is it you are trying to do?