(Synchronization is the act of coordiniating two of more program to achieve some goal - note that the goal may benefit only one program at the expense of another...)
Well, if there is one CPU in the computer, there is no way that the computer can run multiple programs at the same time.
But often, the program run by the users of a (fast) computer system are not very "CPU intensive" (requires the CPU to perform many instructions).
Some often run programs are editors (like vi, emacs, etc), that spend most of the time waiting for user's input 9type a key)
In these and many other cases, the CPU can be used to run multiple programs "at the same time" but executing instructions from different programs for very short intervals in rapid succession.
The computer system will incorporate a timer device that periodically generates an interrupt signal (say once every 10 milli second - the period is programmable).
The system is depicted in the following picture:
(1) Acknowledge the interrupt (2) save the context in the CPU into the PCB at the head of the Ready Queue (3) remove the PCB at the head of the Ready Queue and insert it at the tail of the Ready Queue (4) restore the context using the PCB at the head of the Ready QueueThe Interrupt Base Register will contain the starting address of the above interrupt handling routine.
So the above interrupt handling routine will be run when a timer interrupt is received.
The result is that program P1 (the running program) is suspended and its PCB put to the tail of the Ready Queue.
The PCB of program P2 will become the new head of the Ready Queue and its PCB data will be used to restore the context (registers) in the CPU.
The result is that program P3 will run after the interrupt handling routine finishes execution.
That state is depicted in the following figure:
The result is that each program will be run for a short amount of time - the timer that sends out interrupt signals will "pace" the speed that the CPU is being switched between the various programs.