Railways tracks are divided in subsections of 500m. In the colonial days when British imperial units were used, it was 500 yards. Now it is 500 metres.
At the end of a track section there is a signal!
Now Indian Railways follows a four coded signal system:-
1 RED :- Means STOP
2...
more... YELLOW :- Means PROCEED with a Maximum permissible speed not exceeding 15kmph
3 DOUBLE YELLOW:- Usually it means PROCEED and with reducing your speed slightly as it is most likely that you will encounter a yellow in the next section. However there is no hard and fast rule here as trains can encounter a green in the next signal as well.
4 GREEN:- Means PROCEED All is clear.
Now as to what happens and how to the signal operate:-
If there is no train on the next three sequence, that is if the next three track sections are clear, you get a GREEN!
If there is no train on the next two sequence, that is if the next two sections are clear, you get a DOUBLE YELLOW!
If there is no train on the next sequence, that is if only the earlier section is clear, then there is a YELLOW!
If there is a train in the next sequence, that is if there is no track sequnce ahead free, you get a RED!
Earlier IR would follow the three light sequence, Red, Yellow and Green.
This would mean that loco pilots could never heave a sigh of relief, as you never knew when your GREEN would would turn to YELLOW
Now with the four signal sequence, and better LOCOs like WAP4s, 5s and 7s with faster releasing brakes, pilots also have an extra 500m to brake as there is an extra DOUBLE-YELLOW to warn you of an impending YELLOW!
This also means that train speeds have also increased as the pilots have an extra one section to brake on or speed on!
Hoped it helped!