* Qt, forks and threads = segmentation faults?
[not found] <mailman.126.1138386609.857.linuxppc-embedded@ozlabs.org>
@ 2006-01-28 0:30 ` Russell McGuire
2006-01-30 9:42 ` David Jander
0 siblings, 1 reply; 2+ messages in thread
From: Russell McGuire @ 2006-01-28 0:30 UTC (permalink / raw)
To: linuxppc-embedded
Everyone,
This is a more general question, and if anyone knows of a more specialized
list this should be posted to, I'd be happy to do so...
Small picture of hardware:
DENX Linux 2.4.25 / PowerPC MPC8280 / 32 MBs of RAM
I am using QT Embedded for a small GUI that does BSD sockets, also using
DENX's SM501 video driver. Everything is quite stable, recently I added a
additional process to the application using fork() for the listening
'accept' call for the sockets.
After many tests I decided that due to the nature of the fork() command and
the GUI half of the program, that this was a large waste of memory, as I was
duplicating the entire GUI system. So I started looking alternatives, and
have landed at the 'pthread' library.
However, now I have lots of segmentation faults, particularly when I send a
message using QT's postEvent commands back to the main thread.
I was curious if anyone had any better idea of a more stable or perhaps a
suggestion on why I am able to only get about 30 seconds of run time out of
the app using pthread, verses fork() seems to be much stabler.
-Russ
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Qt, forks and threads = segmentation faults?
2006-01-28 0:30 ` Qt, forks and threads = segmentation faults? Russell McGuire
@ 2006-01-30 9:42 ` David Jander
0 siblings, 0 replies; 2+ messages in thread
From: David Jander @ 2006-01-30 9:42 UTC (permalink / raw)
To: linuxppc-embedded; +Cc: Russell McGuire
Hi Russell,
On Saturday 28 January 2006 01:30, Russell McGuire wrote:
> This is a more general question, and if anyone knows of a more specialized
> list this should be posted to, I'd be happy to do so...
>
> Small picture of hardware:
> DENX Linux 2.4.25 / PowerPC MPC8280 / 32 MBs of RAM
>
> I am using QT Embedded for a small GUI that does BSD sockets, also using
> DENX's SM501 video driver. Everything is quite stable, recently I added a
> additional process to the application using fork() for the listening
> 'accept' call for the sockets.
>
> After many tests I decided that due to the nature of the fork() command and
> the GUI half of the program, that this was a large waste of memory, as I
> was duplicating the entire GUI system. So I started looking alternatives,
> and have landed at the 'pthread' library.
It shouldn't be a waste of memory, since Linux uses copy-on-write for memory
pages. That means, although it looks like your child process wates a lot of
memory (same initial VSS size as parent), it actually shares its memory with
the parent until the child starts modifying memory contents (write fault
occurs). At that moment the page being written to is copied, and the write
access succeeds on the copied page. So fork() is nowadays quite efficient in
linux systems..... exactly as efficient as creating a thread.
> However, now I have lots of segmentation faults, particularly when I send a
> message using QT's postEvent commands back to the main thread.
Eeek. You might want to compile QT with thread support compiled in (don't know
if that helps though).
Anyway, it is probably a better idea to stick with fork() (see above).
> I was curious if anyone had any better idea of a more stable or perhaps a
> suggestion on why I am able to only get about 30 seconds of run time out of
> the app using pthread, verses fork() seems to be much stabler.
Use fork().
Greetings,
--
David Jander
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-01-30 9:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <mailman.126.1138386609.857.linuxppc-embedded@ozlabs.org>
2006-01-28 0:30 ` Qt, forks and threads = segmentation faults? Russell McGuire
2006-01-30 9:42 ` David Jander
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).