Re: clone() and pthreads?

Patrick J. LoPresti (patl@eiffel.lcs.mit.edu)
Fri, 3 May 1996 15:24:38 -0400


-----BEGIN PGP SIGNED MESSAGE-----

torvalds> I'd be more than happy if somebody comes up with a real use
torvalds> for clone(), and starts sending me problem reports.

I wrote the Linux sound support for Executor, the commercial Macintosh
emulator. We use clone() to get the necessary real-time performance.

One thread just does an infinite loop select()ing on the sound device,
waiting until it is hungry for data. That thread then flips a bit in
a global variable which the main emulator thread occasionally tests in
order to simulate a M68K interrupt. The "interrupt handler" feeds the
hungry device with write().

We use sysV semaphores to synchronize the threads and insure that the
select() and write() cannot happen concurrently.

I am mentioning this in case you are considering radical changes in
the clone() call in 2.0, such as disabling CLONE_FILES (even though,
as you mention, support for it is incomplete).

Our use of clone() is pretty trivial, but we will certainly let you
know if we enounter any problems.

Cheers!

-----BEGIN PGP SIGNATURE-----
Version: 2.6.2
Comment: Processed by Mailcrypt 3.4, an Emacs/PGP interface

iQCVAwUBMYpdSXr7ES8bepftAQEc/wQA0Ew/QZ7U+33My+tZQn2x4TRrNEazDZO8
wH3ZHnMBwDpmkpGsW9joE26i0Ltwj3AMrbv45qcQ8sKFUm3Vr6Sf64jDXc3CL/am
g6RxJNcj2zlsWyHm0YMOZ9vBtPUEsh+3pANyYfERC+74SR0uxk0H75iXWvmR0NIX
Vdl+K7PqYVM=
=6b3u
-----END PGP SIGNATURE-----