Skip to content
Advertisement

How does the kernel handle a read operation on proc files when several instances of the same driver are running simultaneously

I have a question regarding the way proc files are handled when several instances of the same driver are running simultaneously. lets assume that a my system runs a couple of instances of the same driver simultaneously, but only one of them (according to some inner decision making) created a proc file and maintains the information that should be written when the file is being read. since all of the instances are of the same driver, they all contain the function that will be invoked when the proc file is being read (though this function is actually registered only by one of the instances). My question is: when the kernel invokes the read function, will it always invoke the function from the address space of the module that created the proc file, or could it call it from the address space of another instance?

Advertisement

Answer

You cannot load several instances of the same driver. The second loading of the same driver will be refused because of drivers’ names collision.

Another reason why you situation is unreachable: creating proc file with name which corresponds to already existing file will fail.

Update (as question became more specific)

Kernel doesn’t check addresses, passed to it from modules. It just uses these addresses, e.g., calls function.

As for address space of different modules, all modules share same address space with the kernel core. So, any address (e.g. address of the read function for ‘proc’ file) may belong to at most one module (or kernel core). When module is loaded into kernel, kernel allocates memory for its code and static data. When module is unloaded, memory with its code and data is freed.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement