On Tue, 30 Mar 1999 [EMAIL PROTECTED] wrote:

> How do you free the space?  The difficulty is that the physical memory
> in question is now referenced by both kernel and user.

This is a good question. I can see two solutions:

1. Kernel module allocates certain buffer size (may be responding to some
command sent though FIFO), then this buffer is mmapable. Each mmap increases 
the counter, each mmap close decreases. When  kernel does not need the memory
any more it decreases the couter as well. If the counter reaches 0 memory is
freed. If implelementing mmap for FIFOs I would use this method. mmap succeds
only if buffer is already allocated.

2. Memory is allocated on the first mmap - it determines the size. Next like
in (1). See http://crds.chemie.unibas.ch/PCI-MIO-E/mbuff-0.2/mmap.c
- this is cleaned up version of my example.

There is a problem in case of multiple buffers - how to distinguish in
mmap_close function which access counter should be decreased. Probably will
require keeping some list of buffers and corresponding vm_area's.

Why shared memory:

1. easy to use, multithreading, no unintentional blocking, full control
2. efficiency (I agree, usually memcpy is fast enough)
3. very good for continuous monitoring and control. User application not
always needs to get all measured samples, quite often I am interested only
what is the value, gradient, RMS  "just now". Also direct access to data
structures and buffers of RT-task makes easier controlling it and debugging.

Regards,
--
Tomek

--- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
----
For more information on Real-Time Linux see:
http://www.rtlinux.org/~rtlinux/

Reply via email to