Ex-railway signaler here.

To expand on the article the most fundamental principle in railway signaling is the block section. That is a length of track for which there can only ever be one train inside it at any time. The length of the block section is typically decided upon by at the very minimum accommodating the train that would be the slowest to brake from its top speed at that location. However in practice most block sections are much longer because it reduces the need for extra signal boxes and line side equipment which results in a cost saving. For example in the UK the longest block section is 26 miles between Carnforth and Settle junction. The flipside to have having longer block sections is that you massively reduce the amount of trains the can run on that line and there have been major problems in the UK where block section lengths were increased in the 70s and 80s to reduce costs, but now with increasing demand they can't run extra trains.

Around railway stations and busy junctions block sections can be quite short, sometimes just a bit longer than the trains that run on those lines. So you might wonder how a train going at full speed could stop within its block section? In those cases there are mechanisms in place to prevent trains going faster than they should. In the UK a system called TPWS is used to control this speed of trains. If a train goes over a TPWS balun too fast then the brakes will be applied and a lot of paper work will have to be completed.

The three main systems used to actually control the movement the trains are absolute block, route relay interlocking and computer-based/solid state interlocking.

In absolute block the signals in adjacent signal boxes use a device known as a block instrument to protect the line between them. Using a bell messaging system the signaller at one box will ask the signaller at the next box if a train can enter their section, if so that signaller will turn a handle on the block instrument which will allow the first signaler to clear their starter signal to allow the train to enter that section. That signal is called the starter because it is at the start of the next section. It's worth noting absolute block is just a method of working and you could control it using old-fashioned mechanical levers, or modern switched control panels. Likewise the signals could be semaphores or electric lights.

Root relay interlocking was developed in the 1930s and uses huge numbers of relays to control the safety of railway operations. Track circuits indicate the presence of trains which will prevent conflicting train movements. An interesting thing to note that in the British railway rulebook is that under absolute block the signallers primary purpose is to ensure the safety of trains, whereas with route relay interlocking their primary purposes to keep the trains running on time. Route relay interlocking takes away the safety responsibility from the signaler. RRI signals are controlled using a vertical panel that shows a diagram of the railway tracks under control with buttons placed at the junctions between each block section. To set a route for the train the signaller simply presses the buttons at the start of the section and end of the section and if that's allowed by the relays then the section will light up and the points and signals will be set appropriately for the train.

Computer based interlocking, also known as solid state interlocking in the UK, is just basically route relay interlocking but now the logic is controlled by computers and instead of standing in front of a big panel the signaller now sits at a computer terminal.

One of the biggest advantages of computer-based interlocking is that it allows for the development of moving block sections. What this means is that physical block sections are replaced with virtual ones which are the length of the stopping distance of each particular train in that area. This means that each train has exactly the right amount of stopping distance in front of it. That allows for more trains to run on the same line.

Edit: Forgot to mention token block working which is an extension of absolute block working where a bi-directional single line is in operation. In addition to the normal signaling equipment, there is also a token machine in each signal box. In each machine there is a supply of tokens which look like big brass keys. The two token machines are linked so that only one token between them can be removed at any time. When a driver is about to enter the section they will be given a token which will be given up at the signal box at the other end and inserted into the token machine there. If you've ever seen the driver handing over a something that looks like a leather handbag with a massive metal loop for a handle then that's what's going on. Even though only one token is ever needed to go down the line, typically there might be a total of 20 or 30 tokens between the machines this is to allow for when there are a lot of trains going in the same direction repeatedly. Although it is rare there have been occasions where all the tokens ended up at one end, so a signaling engineer has to come out and remove some tokens and take them back to the other box.