Yeah, you got it. There isn't much I can add.
But as far as I know the OS is serving the libraries and they get just linked.
The reason for this is, the programmers who develop the system specific implementations know their own system best.
Implementing an fopen()
isn't just asking the Hard Disk for a lane to its stuff. (you probably know)
You have to respect many circumstances of other implementations which are working with File descriptors. And maybe you have to rely on something happening in a specific function on your OS what for the generell behaving isn't needed. But in your enviroment this keeps it all running.
Thats also why the C standard says changing the source code of standard librarys results in undefined behavior even if the function it self still serves the same behavior (tried to find the cite for you but wasn't able, sorry.)
So at all its a optimisation thing. There could be generell implementation but as mostly the whole OS is based on thoose implementations, every OS is interested in making them run the best for their own Case.
(probably not the only one but I'm not that deep in OS development as I could name another)
printf()
ormalloc()
or about thoose asCreateThread()
? – Lalondeprintf()
, etc. and they need system calls for the implementation of such functions. – Toluene