[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] opengl rendering in the sdl window
From: |
Jamie Lokier |
Subject: |
Re: [Qemu-devel] [PATCH] opengl rendering in the sdl window |
Date: |
Mon, 8 Sep 2008 20:32:27 +0100 |
User-agent: |
Mutt/1.5.13 (2006-08-11) |
Anthony Liguori wrote:
> The difficulty is deleting the shared memory segment reliably.
>
> Normally, what you want to do is:
>
> shmget()
> shmat()
> shmctl(IPC_RMID)
>
> ...
>
> shmdt()
>
> And the first sequence has to be as reliable and quick as possible
> because if you exit before the shmctl(), you'll leak the shared memory.
Yes, it's ugly, but it's the same problem faced by Gtk apps etc. which
are writing images - doesn't even SDL have this problem?
The nearest thing to "right" I found in X11-SHM apps is:
- Catch many signals and shmctl(SHM_RMID) in the handler before
re-raising the signal to kill the program.
- Try to recognise old, stale shm segments when starting anew
and remove them. This can be done by putting a signature into
them somewhere which won't be overridden in use.
(There is also some trickiness in ensuring that the connection really
is local, and you're not doing a remote connection which just happens
to successfully attach to a SHM segment on a different machine with
the same id. With SSH X11 forwarding and other ways X11 is proxied, I
found the only way to be sure is create a segment, write strong random
values to it, ask the X server to read from it and return the pixel
values over the normal connection, and verify if they match.)
But that's X11-SHM. For a new protocol, you can do this:
- fd = shm_open()
- shm_unlink()
- pass file descriptor over the connection.
Or even this:
- fd = open("/tmp/XXX")
- unlink()
- pass file descriptor over the connection.
Both ends call mmap().
It's not perfect (there really should be a create-shmem-with-no-name
syscall), but the window for leaks is quite small, and it's fine to
use in a library.
-- Jamie
- Re: [Qemu-devel] [PATCH] opengl rendering in the sdl window, (continued)
- Re: [Qemu-devel] [PATCH] opengl rendering in the sdl window, Jamie Lokier, 2008/09/08
- Re: [Qemu-devel] [PATCH] opengl rendering in the sdl window, Daniel P. Berrange, 2008/09/08
- Re: [Qemu-devel] [PATCH] opengl rendering in the sdl window, Anthony Liguori, 2008/09/08
- Re: [Qemu-devel] [PATCH] opengl rendering in the sdl window, Mike Kronenberg, 2008/09/08
- Re: [Qemu-devel] [PATCH] opengl rendering in the sdl window, Gerd Hoffmann, 2008/09/08
- Re: [Qemu-devel] [PATCH] opengl rendering in the sdl window, Mike Kronenberg, 2008/09/08
- Re: [Qemu-devel] [PATCH] opengl rendering in the sdl window,
Jamie Lokier <=
- Re: [Qemu-devel] [PATCH] opengl rendering in the sdl window, Jamie Lokier, 2008/09/08
- Re: [Qemu-devel] [PATCH] opengl rendering in the sdl window, Anthony Liguori, 2008/09/08
- Re: [Qemu-devel] [PATCH] opengl rendering in the sdl window, Jamie Lokier, 2008/09/08
- Re: [Qemu-devel] [PATCH] opengl rendering in the sdl window, Daniel P. Berrange, 2008/09/08
- Re: [Qemu-devel] [PATCH] opengl rendering in the sdl window, Jamie Lokier, 2008/09/08
- Re: [Qemu-devel] [PATCH] opengl rendering in the sdl window, Anthony Liguori, 2008/09/08
- Re: [Qemu-devel] [PATCH] opengl rendering in the sdl window, Jamie Lokier, 2008/09/09
- Re: [Qemu-devel] [PATCH] opengl rendering in the sdl window, Anthony Liguori, 2008/09/08
- Re: [Qemu-devel] [PATCH] opengl rendering in the sdl window, Avi Kivity, 2008/09/07
- Re: [Qemu-devel] [PATCH] opengl rendering in the sdl window, Daniel P. Berrange, 2008/09/07