The register storage class is used as a
hint to the compiler that a variable is heavily used and access to it
should be optimised if possible. Variables are usually stored in
normal memory (RAM) and passed back and forth to the computers
processor as needed, the speed the data is sent at is pretty fast but
can be improved on. Almost all computer processors contain
cpu registers, these are memory slots on the
actual processor, storing data there gets rid of the overhead of
retrieving the data from normal memory. This memory is quite small
compared to normal memory though so only a few variables can be stored
there. GCC will always make use of registers by deciding what
variables it thinks will be accessed often, this works well but will
never be perfect because GCC doesn't know the purpose of your program.
By using the register keyword you can tell GCC what
needs to be optimised.
One problem with placing a variable into a cpu register is
that you can't get a pointer to it, pointers can only point to
normal memory. Because of this restriction GCC will ignore the
register keyword on variables whos address is
taken at any point in the program.
The resulting program will contain a request, on creation of
the variable that it be placed in a cpu register, the operating system
may ignore or honour this request.