Obligatory "ignore this space" : https://sacoronavirus.co.za

Returning to the hotel room, we find ourselves mesmerized by what's on the wall. But we're deeply suspicious when we can't find a power button, and so we find a towel to hang over it, or this will lull us to sleep.

We're here to think about locking.

There are locks and there are locks: there are Kernel objects which can be locked, which only exist for that purpose, for example. We are looking at a toy Kernel, which is not an ideal one: even the name must be misleading, because avoiding a mixed metaphor is not going to get us anywhere. A guest in a hotel room is definitely not a toy.

It's worth mentioning that the reference implementation was started with no metaphor, but this meant we didn't have words for it. Putting a towel over something that might be called a screensaver if we remove the word save brings out the rambler in me. Lack of metaphor brought me to start a very long conversation that I simply couldn't bring back to what I started it for. But my fellow savage sent me a signal, which is as much as to say that he's also watching the same walls, and has the same room service.

If I ask for a file to be created, the syscall will fail if it already exists; thus we can be sure that only one of us will succeed if we both go for the same name using create_file.

If both of us use open_file, we need to decide what happens.

Full duplex communication was something we considered to be related to modern technology: in truth, it is half-duplex communication that modern technology provides us. In a well-regulated conference we have half-duplex listeners, but talking is not analogous to write_file because this syscall has an implicit or explicit position.

Recalling a text book on operating systems, the approach it described, though only theoretical, does seem to be the best: readers and writers are analogous to half-duplex and full-duplex communicators respectively. A file may only be open by one writer, in which case there may not be any readers; but otherwise a file may have any number of them.

Therefore we simply add to open_file a bit-boolean parameter, read_only.

For create_file we assume that it will be written to. This puts paid to the use of files as locks for Bash code. But we are very far from getting the router to play a tune when the line goes down, for example. There is a slight inconvenience in GNU, because if we do successfully create a file, there's no guarantee that between our receiving the response for that and calling flock another hotel guest hasn't opened it. But by assuming that a reader which finds an empty file itself assumes that a writer is yet to flock, we complete the sharing compatibility wrappers for this platform.

Practically and theoretically the upgrading and downgrading of flocks is something to consider, but in a similar fashion we will need to look at what we may implement, once we've decided whether this isn't merely an optimization.