The difference between TIMES and DUP in assembly language
Both are used for repeating stuff, but the dup operator can only be used in conjunction with data directives like db, dw, and friends (like NASM documentation puts it); whereas times is a prefix that can repeat anything that can legally follow it such as assembly instructions and assembler directives.
The lines TIMES 510-($-$$) db 0 and db 510-($-$$) DUP (0) will produce the very same output, but depending on the exact implementation (and especially judging by an assembler that I wrote), times could be a tiny bit slower as the repeat is on the outside of the db directive whereas dup lives within. (dup can easily translate into a very fast rep stosb).
The questions answered
I know what TIMES does, but it's not mentioned in my x86 book by Mazidi (Pearson Publication). Any idea why?
If that book uses MASM as its assembler then times is not part of the language.
And what is the meaning of the $ sign exactly? Different sites have different information about $.
In many assemblers the $ symbol represents the current offset address within the current code section. Be aware that some assemblers will use a single dot . for this purpose.
The address for the current code section in turn is represented by the $$ symbol.
And is the line TIMES 510-($-$$) db 0 absolutely necessary even if my bootloader code is of 512 bytes in size?
If you know for a fact that your bootloader code contains 510 bytes, so leaving 2 bytes for the mandatory signature, then of course it is not required to include this line.
However it is almost always better to leave this line where it is because if you bootloader code exceeds 510 bytes the formula 510-($-$$) will evaluate to a negative number that the times prefix will warn you about. And as we all know: warnings are our friends.
The formula explained
If you develop your bootloader code using an ORG 7C00h directive (which is the preferred way), then both the '$$' and '$' symbols start from 7C00h. As the code generation progresses the '$$' symbol remains fixed, but the '$' symbol gets ever higher values assigned to it. Once enough code was generated and the padding towards the mandatory signature must happen, it is the difference $-$$ that tells us how many bytes we had since code start. Because the signature must reside at offset 510, the subsequent difference 510-($-$$) tells us how many bytes the padding must be. The times 510-($-$$) db 0 line then does the actual padding.