ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
I am looking into creating a simulation of a hardware device. This hardware device is directly mapped into memory and its registers and memory are accessed that way in user space.
What I would like to be able to do is when a certain memory area (that I control via mapping or allocation of some type) is written, I would like to get some type of an interrupt or signal so that I can asynchronously get information written into a virtual register and use it. I would also like to get interrupted or signaled when a certain memory area is read so that I can update whatever is accessing it with the very latest information and results of some processing that I need to do.
My initial thinking was to use either SIGSEGV or some type of page fault handler in a module. My problem is that I believe I may be able to get this to work for one access, but I may have to make the memory area valid in the handler in order for the user code to continue so therefore it would not interrupt/signal on the next access. Does anyone know if these ideas would work? Are there other ideas anyone has?
I don't have experience with your sort of problem, but my initial thought is to create a kernel module that creates a character device, give it a set of ioctls to protect or unprotect certain memory areas, then mmap that character device as "shared" and use the mapped memory for your virtual machine. All the module would need to do is maintain a table of protected memory addresses and create a signal if there's a violation. I'm sure there's a better way than this other than actually changing the protection of memory in the process' memory table, but I don't know that I'm awake enough to think it through any more than that.
I feel silly for not thinking of this before, but you could create two shared mappings using the same underlying file: one R/O for the virtual machine and the other R/W for the program managing it. They would both be the same memory, but the managing program would be able to make direct conversions between the R/O and R/W versions with simple pointer arithmetic.
The requirement for this went away for a while so I haven't been thinking much about it. This seems logical for doing what I need at least on a write access. I will pursue this further when it comes up again. Thanks.