Re: [gtkmm] new thread vs. fork to play a sound on button press

>On 25 Dec 2002 20:35:19 -0500
>Mark Jones <mark jones106 verizon net> wrote:
>> new thread vs. fork to play a sound on button press
>> [...]
>> Is there a preferred method with gtkmm?
>Regarding the above question, on whether one should rather use fork() or threa
>ds for playing a soundfile, I can say: I'd prefer threads because a fork() int
>roduces a lot of overhead you do not need, as it is a whole process you're spa

if your program is intended exclusively for linux, there is little
difference in the cost of creating a new thread versus creating a new
process that then calls exec(2). threads under linux (both
linuxthreads and the newer thread libraries) involve the creation of
the same basic kernel entity as a process (called a "task"); the only
significant difference is that the thread shares a VM space with its
siblings, where a process gets a copy (but note: its not copied till
needed). if a new process calls exec(2) to run some other program, it
never really writes on any of the copy-on-write memory it has, and
hence there is really no significant difference in cost.

given that you have to fork at some poin if you want to run another
program to play the sound, the key question is how you intend to play
the sound. the simple way: using an existing cmdline utility such as
"play". for this, just fork(2) and exec(2), or use system(3) from a


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