There is no data on exact user base, except where Apple occasionally chooses to release it. We can estimate based on two different sets of data though: (1) percent market share, and (2) total PC sales.
OS X market share % globally has steadfast been under 10%. Today, it is about 7% (source: http://marketshare.hitslink.com/ope...=8&qpcustomd=0&qpsp=2012&qpnp=1&qptimeframe=Y). Back in SL's hay-day, it was about 5% (source: http://marketshare.hitslink.com/ope...=8&qpcustomd=0&qpsp=2008&qpnp=3&qptimeframe=Y). In the US, this marketshare increase has been more substantial, but we're talking about profits so the global scale is more appropriate. Computer sales in general increases from approx 300 million in 2008/9 to approx 350 million in 2012. Source: Gartner.
Thus, Apple sold about 15million copies of SL, and about 25million copies of L/ML (taking into account the same 1 or 2 year period of time. It's worth mentioning that Apple has toutes themselves that their install base was close to 60million recently. However, I think this counts every OS X machine ever sold that is still alive. While this number is impressive, it's not accurate for purposes of this study because not every user upgrades; in fact, most are not even eligible to upgrade. There is a shocking amount of PowerPC users still out there.
Therefore, in terms of profits: 15mil x $129 per copy = almost $2billion in SLs heyday. 25mil x $20 = $500mil today. It is also worth noting that not every copy sold comes from a software upgrade sale. A large percent probable comes bundled with hardware sales, but we can assume that is part of the cost of the hardware.
Conclusion: Apple is making WAY less money selling OSX. However, they more than make up for it by selling songs, movies, tv shows, apps, and icloud services which tie together certain apple apps and content. All in all, itunes is their cashcow for the foreseeable future. In this era of Apple, they have not ever been shy about canibilizing their own sales. This is very clear from the data above, where they chose to sacrifice OS X profits to get more people into iCloud and more iOS-based hardware.
TL;DR - I do have my numbers strait. I'm right. You're wrong.
No you are not you got your numbers wrong again, sl did not cost $129. In addition it's a huge percentage of the user base, the vast majority actually, that updated to sl, lion, and ml. In 2012 it was reported in early adoption studies that 44% was already on lion on 60 million user base. That has grown to close to 70% by now easily.
http://news.cnet.com/8301-13579_3-57450454-37/apples-mac-base-hits-66m-users-40-percent-on-lion/
That is surely close to 50 mil users times 20 dollars, and it's actually a billion not half a billion as you calculated.
Get this, apple is making boatloads of money on os x. And with the "features" they introduced in mountain lion, especially, it was really money for nothing.