5 ms·
Surely constructs like scope guards etc. are useful in kernel development as well?
by petters 9y ago
Surely constructs like scope guards etc. are useful in kernel development as well?
- rjeli 9y agoC compilers have scope guard extensions. http://echorand.me/site/notes/articles/c_cleanup/cleanup_attribute_c.html http://echorand.me/site/notes/articles/c_cleanup/cleanup_att... Systemd uses it: https://github.com/systemd/systemd/blob/5809f340fd7e5e6c76e229059c50d92e1f57e8d8/src/basic/alloc-util.h#L50-L54 https://github.com/systemd/systemd/blob/5809f340fd7e5e6c76e2...
- pjmlp 9y agoLanguage extensions is the keyword here. Some people rather use official language features.
- auvrw 9y agopart of making a new operating system could be getting to muck with the language features ... ... i suppose this project is locked into G-standard C++ and with lots of good reasons (e.g. toolchain). although i'm an anti-C++ person, i suppose the sorts of tools available internal to Alphabet make it much more manageable. anyway, for an example of the original premise: i'm slowly learning some things about plan 9 C via 9front.. there are some departures from ANSI C, including additional features like (completely undocumented, except for the relatively compact source) operator overloading. equally important for the type of person that finds C++ too busy, some features (e.g. certain preprocessor features) are removed.
- naasking 9y agoExceptions and even RAII should never be used in a microkernel. This might be useful in a monolothic kernel, but that's not the context here.
- jensa1948 9y agoI can see points against exceptions, but generally RAII has nothing to with exceptions, so what is the point against this? It makes managing any resource with acquire/release semantics very easy. It also prevents errors when the code is modified later because you cannot forget to call cleanup code as it is done automatically. I have no experience with kernel programming, but acquire/release seems to be something that is done in the kernel.
- naasking 9y ago> It makes managing any resource with acquire/release semantics very easy. Agreed. But microkernels generally don't acquire or release resources. Most people arguing against this point seem to have a monolithic kernel mindset, but microkernels are a whole different beast. If a kernel owns any kind of resources, that leaves the whole system vulnerable to denial of service attacks. Therefore, microkernels have long since adopted designs where the kernel does not own or allocate anything, and all resources belong to processes (which incidentally makes identifying misbehaving processes easy, something not easy on UNIX kernels). Any data the kernel requires for its operation is allocated at boot time and lives until the system halts.