Hacker News new | ask | show | jobs
by mikeash 4059 days ago
If your use of atomics consists entirely of calling functions provided in a library as part of the OS, what's wrong with calling them "OS atomic functions"? That is what they are. The fact that you can accomplish the "atomic" part without the "OS functions" part doesn't change the fact that, as written, the article discusses the "OS functions" part.
1 comments

Well, it looks like Apple named this particular API "OS atomics", a name which makes me cringe a bit.

But, a few points:

1. There is historically a distinction between "operating system" and "shared library shipping with the operating system". I think I am losing this battle though.

2. On a number of platforms (not sure if Apple's "OS atomics" concept counts here), the atomic wrappers are not even functions in a shared library. They may be declared inline in a header file. Or they may be compiler intrinsics, where the compiler doesn't generate any function call in any circumstances. Is that an "OS function"? Not really.

In either case #1 or case #2, I think "OS atomics" is a dumb name. We are really talking about CPU features, not OS features. If it doesn't generate a trap into kernel mode that doesn't very much sound like the OS doing the work.

Calling it "the OS" sounds more like a fundamental misunderstanding of dynamic linking and what it is. I hear so many variants of this core misunderstanding all over the place. Thinking that spinlocks need kernel help is one such manifestation.

#1 sounds like a pretty minority viewpoint. OSes these days are a lot more than just the kernel and things that call into the kernel. If you do a fresh install of the OS then I think what you find on the disk afterwards can all be reasonably referred to as "the OS."

#2 does not apply here. This particular API isn't implemented inline, or with compiler intrinsics, or assembly. They're actual calls.

If you're talking about the general concept of atomics, then I agree that "OS atomics" is a dumb name. But we're not talking about that. We're talking about a specific API that happens to implement that general concept. That specific API is part of the OS.