I need to go to France twice, for a total duration of 40 days, but separated. The first time I am going to stay a week in Paris, probably in May, maybe around the end of April, and the second time in August. I've heard the validity of a Schengen visa can last up to 6 months and the total duration cannot exceed 90 days. Is it 90 days altogether or 90 days starting the first day you enter France?
Do I need 2 visas?
Probably not. If you are a national of an "Annex II" country, you don't need any visa. Otherwise, you should mention both trips when you apply for your visa and you should be given a single visa that covers both trips.
If they give you a visa that covers only your first trip, then you'll need to apply for a second visa.
Is it 90 days altogether or 90 days starting the first day you enter France?
It's 90 days of actual presence in the Schengen area. If you spend 8 days in France and then leave for two months and then spend another 32 days in France, that counts as 40 days. On the other hand, if you've just spent 60 days in Spain or any other Schengen country, you won't be able to spend 40 days in France. For more information, see How does the Schengen 90/180 rule work?
When you apply for a Schengen visa for the first time, there is a tendency to give you just the days for your first itinerary and just one entry. As your travel history in Schengen builds up, there is a tendency to give you a longer validity period and more entries, all the way to a long-term, multiple-entry visa.
So if you apply for your first visa with plans to visit in April and August, they might give you just the April and tell you to reapply for August. But you can't really influence that, except by giving details of both trips in the first application.