Thread View: comp.sys.next.programmer
3 messages
3 total messages
Started by Sam Streeper
Tue, 03 Nov 1992 22:20
usleep and sound, signals and threads
Author: Sam Streeper
Date: Tue, 03 Nov 1992 22:20
Date: Tue, 03 Nov 1992 22:20
29 lines
1342 bytes
1342 bytes
Someone was just trying to add sound to a BackSpace module and ran into a sneaky problem that has been discussed before but bears repeating. usleep() is implemented via signals (a questionable strategy IMHO), and many of the soundkit functions surreptitiously use threads to keep the sound buffers full. Signals and threads do not mix gracefully, and the sound thread may catch the signal that was supposed to wake up the usleep() function, hanging it forever. The solution is to pick some waiting method that doesn't use signals; for example waiting on a mach port. One easy way to do this is to wait for an event that will never be received with an appropriate timeout. For example: NXEvent dummyEvent; [NXApp peekNextEvent:0 into:&dummyEvent waitFor:timeout threshold: NX_MODALRESPTHRESHOLD]; Maybe this will keep someone from tearing one's hair out. -sam -- Opinions expressed herein are not those of my employer. They're not even mine. There is water at the bottom of the ocean. Hi Mom!
Re: usleep and sound, signals and threads
Author: felix.lugo
Date: Wed, 04 Nov 1992 01:17
Date: Wed, 04 Nov 1992 01:17
26 lines
1096 bytes
1096 bytes
In article <5724@rosie.NeXT.COM> sam_s@NeXT.com writes: | | The solution is to pick some waiting method that doesn't use signals; for | example waiting on a mach port. | | One easy way to do this is to wait for an event that will never be received | with an appropriate timeout. For example: | | NXEvent dummyEvent; | | [NXApp peekNextEvent:0 | into:&dummyEvent | waitFor:timeout | threshold: NX_MODALRESPTHRESHOLD]; | | Maybe this will keep someone from tearing one's hair out. | | -sam | | -- | Opinions expressed herein are not those of my employer. They're not even | mine. There is water at the bottom of the ocean. Hi Mom! What's wrong with using good'ol select()? --Felix
Re: usleep and sound, signals and threads
Author: Chris Lloyd
Date: Wed, 04 Nov 1992 06:07
Date: Wed, 04 Nov 1992 06:07
17 lines
998 bytes
998 bytes
In article <1992Nov4.011720.12191@cbnewsl.cb.att.com> coco@cbnewsl.cb.att.com (felix.lugo) writes:
>In article <5724@rosie.NeXT.COM> sam_s@NeXT.com writes:
>| NXEvent dummyEvent;
>|
>| [NXApp peekNextEvent:0
>| into:&dummyEvent
>| waitFor:timeout
>| threshold: NX_MODALRESPTHRESHOLD];
>
> What's wrong with using good'ol select()?
thread_switch(THREAD_NULL,SWITCH_OPTION_WAIT,milliseconds);
la la la,
--
:: Christopher Lloyd :: a74k110@titan.ucc.umass.edu :: Yrrid, Inc. ::
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads