"Warm bloodedness is believed to have first evolved among the cynodonts [an animal of the order Therapsida - mammal like reptiles], a late but successful group of mammal-like reptiles from which the mammals evolved."
http://www.uky.edu/KGS/education/Permian.htm
Mammal-like reptiles were the dominant terrestrial animals by the middle Permian period. There was a great mass extinction event at the end of the Triassic when they went extinct, and the dinosaurs became dominant.
But, just before the extinction of the mammal-like reptiles, some of them had "evolved to become primitive mammals (subclass Prototheria)." They were tiny insectivores.
"While mammal-like reptiles were extinct by the time the dinosaurs really took off, there was an overlap period with the first meat eating dinosaurs, which would have been faster and bigger predators." See picture of cynodont.
http://www.exn.ca/Dinosaurs/story.asp?id=2000032151&name=creatures
"As soon as the dinosaurs died out, mammals by default were the dominant terrestrial creatures," "but they didn't reach any dinosaur's size for about ten million years."
BREAKING NEWS!!! UPDATE!!! Today's New Scientist magazine says that it has just been discovered that there actually WAS a species of large mammals living at the same time as dinosaurs. However, the species died out (possibly before the dinosaurs) and had no decendents.
http://www.newscientist.com/article.ns?id=dn6874