previous | start | next

Copying Data between a Server Process and a User Process

For the profiling system calls we need to copy data gathered by the clock task. The memory for the gathered data must be directly accessible to the clock task to avoid message passing at each clock tick. So the data will be in the kernel image. Task calls go to the system task. But all the kernel tasks including the clock task and the system task are part of the same image. So addresses of the data will be valid in the kernel image.

Recall that there are to be 1024 integer bins to record the data plus an integer giving the number of bins actually used and two more integers for the start and end addresses of the range to be profiled.

It is easy to transfer small amounts of information between the process manager and a user process through a system call without directly copying the data by including the data in the message that is sent/received. The implementation of message passing has to do the copying between the process manager's memory and the user's memory. But that copying was not explicit in the code we wrote for adding a mygetpid system call.

But the amount of data we need for the profiling cannot be handled the same way. The message structs are too small to hold the profile data.

However, one or more of the message variants has pointer members. So a user system call can insert the address of a user struct into the message being passed to the process manager and the process manager can insert this same pointer into a message sent to the system task.

But this pointer value is a virtual address in the user's address space, not a physical address.

Similarly, the address of the collected data is a virtual address in the sysyem task's address space.

The kernel task has the privilege to copy data from any part of physical memory to any other part. To copy from virtual address A in process 1's address space to a virtual address B in process 2's address space, the kernel task needs to know

The system task could then copy the data as follows



previous | start | next