Linux and AFAIK most unixes expose the
flock syscall for mandatory file-locking. My experience is admittedly limited with this, however am informed that it is kernel-enforced on the entire resource. But what if I wanted to only lock a part of a file mandatorily, such that read/writes to this resource are permitted, as long as they don't cross a particular boundary or stop reading once it reaches an outer bound of the locked region. Is this possible?
Edit: Possible Implementation
A possibility for advisory partial locking may be via MMaped regions, where the memory is mapped into each reader's address-space, on the condition that the requested region does not hold a lock. This would be implemented entirely in user-space, and thus loses the advantages of kernel-enforced locking, but would certainly work