Re: gtk_image_new_from_file and mmap



On Tue, 2003-02-25 at 12:28, back zeus nuclear kth se wrote:
> 
> Hi,
> 
> I'm stuck with a strange problem.
> 
> I'm writing a gtk+-2.0 code as a user interface
> for a (VME based) data acquisition system.
> 
> After starting my program, it reads an image like this:
> 
>     my_image = gtk_image_new_from_file ("image.jpg");

The X Server is probably using the shared mem extension to get the
pixmap onto the screen.
 
> This works fine in itself, I see the image after the gtk_widget_show command.
> Later on, in another (rather unrelated) part of the code I do:
> 
> #define dev "/dev/btp32"
> 
> ...many lines...
> 
>   /* open VME device*/
>     if ((fd = open(dev,O_RDWR)) < 0){
>      perror("Error opening VME device");
>       exit(0);
>    }
>   
>   /* map BIT3 dual port memory */
>     bufp=(int *)mmap((caddr_t)0,len,PROT_READ|PROT_WRITE|PROT_EXEC,MAP_SHARED,fd,offset);
>     if(errno) {
>       perror("mmap: failed");
>       exit(0);
>     }

How big is len?

> 
> The error I get is:
> mmap: failed: No such file or directory
> 
> After some testing, I found that the mmap call works fine, but only if
> I remove the 'my_image...' line in the code. It also works
> if I remove (or rename) the image, so that it cannot be read.
> 
> How can gtk_image_new_from_file and mmap be 'colliding'?
> 
> The image is only 11k and I have 512Mb RAM.
> I run debian linux (woody), kernel 2.2.20.
> 
> I don't know if this is GTK+ related, but I hope someone
> here could help me.
> 
> Regards,
> 
> TB

Try doing sysctl -A and look to see how much shared memory is available
on the machine (kernel.shmmax). The default could be quite low.

It may well be that loading the pixmap is enough such that you cannot
mmap the entire region on your device that you would like to.

You can change this by editing /etc/sysctl.conf

James


-- 
James Durie               Phone:  +44 20 7749 7904
Anvil Software Limited    Fax:    +44 20 7749 7916
46-48 Rivington Street    e-mail: jdurie anvil co uk
London EC2A 3QP




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]