How long has this been happening? How long is the computer on before it restarts? Does it happen while you're in the middle of a program or does it happen randomly, even if the computer is idle? Have you tried doing a system restore prior to the date that it started acting up? Does it do the same thing in safe mode? Does it give you a prompt telling you it's shutting down without any option to stop it?
I'd need more information to really give you a diagnosis. When a computer restarts itself, especially XP, it could actually be giving you a page fault beforehand, but it happens so fast, it barely blips on the screen for you to see. It could also be hardware related. And it could also be a virus but before we dive into that territory, I always like to make sure it's not something else first. A lot of people immediately jump to that conclusion and most of the time, it's not the case.