3 ms·
As a noob observing..Many of them seem to have names nothing like what their actual purpose is
by simooooo 9y ago
As a noob observing..Many of them seem to have names nothing like what their actual purpose is
- LeonM 9y agoA dead comment by user 'simoooo': > As a noob observing..Many of them seem to have names nothing like what their actual purpose is Having worked a bit with low level kernel stuff (porting a unix OS to a new platform), I understand his observation. Even after working with the kernel for a while, many names don't really make sense. Mandatory quote of Phil Karlton: > There are only two hard things in Computer Science: cache invalidation and naming things.
- nikomen 9y agoOut of curiosity, do you know of any examples of seemingly misnamed objects in the kernel?
- hyper_reality 9y agoNot exactly an object 'inside' the kernel, but I was recently caught out by the fact that /proc/net/snmp doesn't have much to do with the SNMP protocol. Rather it tracks socket statistics for IP, ICMP, TCP, and UDP, and is one of the sources of information for the netstat utility.
- roblabla 9y agoMy recent venture in the filesystem have been somewhat fun. The problem isn't so much misnamed objects, and more that the kernel is filled with seemingly undocumented, arcane, old things. `sb_bread` isn't some kind of food, but the "SuperBlock Buffer Read" method, and `brelse` means "Buffer Release" (and not, somethingsomething else, as I initially thought). BH means Buffer Head. The meaning and usage of Buffer Head has changed a lot across Linux versions. It's the basic unit of IO operations, but nowadays most users would use a bio for most of what you would have used a buffer head in the past. When you're working on filesystems you'll have to use BHs to talk to the hard drive though. Linux FS infrastructure and Ext2 share a lot of names. For instance, ext2 and linux both have superblocks, inodes, blocks, etc. They are... logically the same, but at the same time they're very different - one lives purely on the disk, the other provides functions to the kernel. This makes conversation very complicated, when talking about the superblock, you have to mention which superblock you're talking about, because that's not always obvious from context.
- slrz 9y agoNames like brelse, bread, namei and so on have a long history in Unix kernels and file systems. That history forms people's expectations. If you provide a namei operation in your code, you better call it namei and not make up some other, ostensibly more clear, identifier for it.
- pwaivers 9y agoWhich leads to one of my favorite programming jokes: > There are only two hard things in Computer Science: cache invalidation, naming things, and off-by-one errors.
- thezoq2 9y agoA professor of mine said something along the lines of "If something isn't confusing enough, give it multiple names"
- dang 9y agoIn the future, try vouching for a dead comment (click on its timestamp to go to its page, then click 'vouch' at the top). If a dead comment gets enough vouches, it is restored, and then you can reply to it the normal way. Since simoooo's comment was vouched for by other users, I've moved your reply to be a child of that one.
- zython 9y agoHeres the improved version of that quote: > There are only two hard things in Computer Science: cache invalidation, off-by-one errors and naming things.