CH_MAP_FD(3)

EXPERIMENTAL_FUNC
ch_map_fd - Map a disc file.

SYNOPSIS
#include <karma_ch.h>

Channel ch_map_fd

(int fd, uaddr size, flag writable, flag update_on_write)

DESCRIPTION
This routine will open a memory channel with the memory pages being mapped from a disc file. The disc file must already exist.

fd  The file descriptor to map. This will be closed on error or when the channel closes.

size
    The size of the region to map.

writable
    If the mapped pages are to be writable, this must be TRUE. If this is FALSE and the memory pages are written to, a segmentation fault occurs.

update_on_write
    If the disc file should be updated when the memory pages are written to, this must be TRUE. If this is FALSE, then a write to a memory page causes the page to be copied into swap space and the process retains a private copy of the page from this point on.

RETURN VALUE
A channel object on success, else NULL.

Multi-threading Level
Unsafe.

NOTES
If <<update_on_write>> is FALSE and <<writable>> is TRUE, then some systems require the allocation of normal virtual memory equal to the size of the disc file at the time of mapping, while others will dynamically allocate memory from swap space as pages are written into. In the latter case, some systems will cause a segmentation fault if swap space is exhausted, while other systems wait for space to be freed.

The channel may be queried to determine if it has been memory mapped using the call <<ch_test_for_mmap>>.

AUTHOR
Richard Gooch (rgooch@atnf.csiro.au)

AVAILABLITY
The Karma Distribution is available for anonymous ftp from: ftp://ftp.atnf.csiro.au/pub/software/karma/ ftp://wuarchive.wustl.edu/graphics/graphics/packages/karma/ ftp://ftp.pwr.wroc.pl/pub/karma/ The Karma Home Page is: http://www.atnf.csiro.au/karma/