Question

i knew that kernel space is dedicated to run the kernels ,while user space for user applications.

but after reading the following paragraph from one of the papers related to OS I am confused,

suppose that we have gesture recognition system and that The design decomposes the system into four components, implemented as separate programs:

  • catusb: Captures image data from cameras connected on a USB bus.
  • xform: Uses image-processing algorithms such as noise filtering and geometric transformations to transform images in the camera perspective to a point cloud in the coordinate system of the screen or user. Inherently data-parallel.
  • detect: Detects gestures in a point cloud and features significant data parallelism.
  • hidinput: Accepts gestures found by the detect program and sends them to the OS as human interface device (HID) input.

next they mentioned the following flow of execution :

enter image description here

"reading data from a camera requires copying image buffers out of kernel space to user space. Writing to the pipe connecting catusb to xform causes the same buffer to be written back into kernel space. To run xform on the GPU, the system must read buffers out of kernel space into user space, where a user-mode runtime such as CUDA must subsequently write the buffer back into kernel space and transfer it to the GPU and back."

so what i want to know is:

  • if the camera buffer is a memory space resides in RAM so when reading data from camera why to read it from kernel space i don't understand ,is it because that buffer itself resides within the kernel space(in other word ,is the hardware device's memory mapped to RAM resides within the kernel space)?,

  • and even if the camera buffer resides on the camera's chip so reading is done by kernel copying that buffer from camera chip to user space directly, am i right?if so why its mentioned in the paragraph that copying buffer out of kernel to user space.

Was it helpful?

Solution

The operating system's job is allow a lot of components, both hardware and software, to play nice with each other. In general, userland programs can't directly manipulate peripherals nor interfere with each other. I'm not familiar with the specific setup that you're citing, but it doesn't sound unusual.

The USB camera notifies the operating system that it has a new frame. When the kernel (driver) notices this it, will copy the frame with I/O commands into RAM. Since this RAM was allocated by the driver, the userland programs won't be able to see or read it due to virtual memory. To summarise it quickly, the address &0x1000 in the kernel and the address &0x1000 in a program are actually physically distinct locations in RAM. The kernel will then copy the frame into the memory of any process that is expecting input from the camera and then notify it (in this case catusb).

Likewise, since xform, detect and hdinput exist as separate processes, they must use inter-process communication. Since the operating system must ensure the isolation of the programs, each process will leverage the kernel to achieve this.

There's nothing unusual here. I imagine they are just spelling it out because gesture recognition is time-critical and doing it this way has some overhead.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top