Reputation: 36048
I have the homework question:
Explain how a process can refer to objects that are not in its
address space (for example, a file or another process)?
I know that each process is created with an address space that defines access to every memory mapped resource in that process (got that from this book). I think that the second part to this question does not make sense. How can a process reference an object of another process? Isn't the OS suppose to restrict that? maybe I am not understanding the question correctly. Anyways if I understood the question correctly the only way that will be possible is by using the kernel I believe.
Upvotes: 2
Views: 185
Reputation: 939
If you are asking it in a general sense, then its a no. Operating systems do not allow one process to access another process's virtual address space under the normal circumstances. However there are ways in which you can create a controlled environment where such a thing can be done using various techniques.
A perfect example is the debugger. It uses process tracing mechanism (like reading from /proc filesystem or using the ptrace() system calls) to gain access to read and write from another address space.
There is also a shared memory concept, where a particular piece of memory is explicitly shared between two processes and can be controlled via a shared memory object.
Upvotes: 1
Reputation: 968
You can attach as a debugger to the application. Or if using Windows, you can use windows hooks
Upvotes: 1
Reputation: 36048
I have researched and I have the answer to the file part of the question.
first of an address space is the collection of addresses that a thread can reference. Normally these addresses reference to an executable in memory. Some operating systems allow a programmer to read and write the contents of a file using addresses from the process address space. This is accomplished by opening the file, then binding each byte in the file to an address in the address space.
The second part of the question this is what I will answer:
Most operating systems will not allow reading addresses from another process. This will imply a huge security risk. I have not heard of any operating system that enables you to read data from a thread that is not owned by the current process. So in short I believe this will not be possible.
Upvotes: 0