These words often have the same meaning, but they are used differently.

With the definite article:
All comes before the definite article: All the time

Whole comes after the definite article: The whole time

With a possessive adjective:
All comes before a possessive adjective: All my life

Whole comes after a possessive adjective: My whole life

With a singular noun:
Whole can only be used after a definite article: The whole country (not 'Whole country')

With Plural Nouns:
They have different meanings:

All exams were affected. = Every exam was affected.
Whole exams were affected. = This doesn't mean that every exam was affected, but that some were affected completely.

With uncountable nouns:
We generally use all. We can say 'the whole of the' before an uncountable noun.