Does linux have the notion of registering callbacks when certain operating system events occur ?

As an example in my C++ code I would like to be able to register a function callback when some file change is made in a particular directory. Is such a thing possible in Linux ? Similarly with other actions which the operating system, aka kernel, might process, does Linux have the notion of registering a callback function which will be notified of such an action ?

It seems as if a program must track events in the operating system by actively checking for some change in a background thread rather than by being notified, through a function callback, when some change happens. But perhaps I have misunderstood how tracking operating system events works in Linux.