But if you want to make a lock by all means make a lock, just don't go and reinvent the chip architecture...
People who take on task of writing such library, and develop it to the point it's a language-wide standard, usually know what they're doing (or learn on the job :)
Popularity of such library helps test it thoroughly on many platforms in various conditions, so there's a high chance the bugs will be spotted and fixed.
It's more like "if you don't need to, don't invent your own [x]." People who like to invent [x] are usually smart enough to understand why that warning is there to begin with, and don't tend to argue with it.
It's "be competent before you invent it, because it's hard". And if you aren't, then let someone who is do the inventing.
so yes - invent your own synchronization primitives. please.
just dont believe they are correct without being serious about trying to prove they are. and dont hold up your whole project for self-enrichment.
but try to layer as much in as you can.
developers these days are so productive, until they fall down and cant get up. and then they are completely useless.