First of all critical section applies only to parallel execution, and it is a piece of code that cannot be executed by more than one thread / process at given time. It occurs when two or more threads or processes want to write into the same location at once, which potentially can cause incorrect state of the data or deadlock.
Even so innocent looking piece of code as i += 1
has to be protected in parallel world -- you have to remember that execution of thread or process can be suspended at any time by OS.
The basic mechanism of synchronization are mutexes and monitors.
With semaphores one can limit access to resources.