It is a bit more complicated than that. I don't know precisely what strategy MacOS X uses. This has been an active area of research in computer science for 40 years or so. There isn't a cut and dried answer. It depends.
Here is a brief introduction: http://reviews.cnet.com/8301-13727_7-20048484-263.html
Here are even more details: http://osxbook.com