All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: parallel, real time safe waiting?
@ 2015-04-15 15:51 Johannes Lorenz
  2015-04-15 19:41 ` Clemens Ladisch
  0 siblings, 1 reply; 8+ messages in thread
From: Johannes Lorenz @ 2015-04-15 15:51 UTC (permalink / raw)
  To: alsa-devel

Ok, last question about this topic: Is blocked snd_pcm_reading/writing both

  a. real time safe and
  b. does not "consume 100 percent cpu power", i.e. waits silently?

Thanks for the help.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: parallel, real time safe waiting?
  2015-04-15 15:51 parallel, real time safe waiting? Johannes Lorenz
@ 2015-04-15 19:41 ` Clemens Ladisch
  0 siblings, 0 replies; 8+ messages in thread
From: Clemens Ladisch @ 2015-04-15 19:41 UTC (permalink / raw)
  To: Johannes Lorenz, alsa-devel

Johannes Lorenz wrote:
> Is blocked snd_pcm_reading/writing
>   a. real time safe

Yes.


Regards,
Clemens

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: parallel, real time safe waiting?
  2015-04-14 20:03 Johannes Lorenz
@ 2015-04-15  7:52 ` Clemens Ladisch
  0 siblings, 0 replies; 8+ messages in thread
From: Clemens Ladisch @ 2015-04-15  7:52 UTC (permalink / raw)
  To: Johannes Lorenz, alsa-devel

Johannes Lorenz wrote:
> You said snd_pcm_wait() was real time safe. I guess that's also true
> for similar functions, like snd_pcm_htimestamp(), snd_pcm_readi(), ...,
> correct?

Yes for all devices I know, but plugins might implement this differently.
(But there's nothing you could do about it, so don't bother worrying.)


Regards,
Clemens

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: parallel, real time safe waiting?
@ 2015-04-14 20:03 Johannes Lorenz
  2015-04-15  7:52 ` Clemens Ladisch
  0 siblings, 1 reply; 8+ messages in thread
From: Johannes Lorenz @ 2015-04-14 20:03 UTC (permalink / raw)
  To: alsa-devel

> Of course.  Not only does this page say so:
> http://www.alsa-project.org/main/index.php/SMP_Design

Ah, I read this, but that's probably just if two threads would share one handle:

  "The use of returned handles must be serialized in the application using own locking scheme."

One more question: You said snd_pcm_wait() was real time safe. I guess that's also true for similar functions, like snd_pcm_htimestamp(), snd_pcm_readi(), ..., correct?

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: parallel, real time safe waiting?
  2015-04-14 18:39 Johannes Lorenz
@ 2015-04-14 19:49 ` Clemens Ladisch
  0 siblings, 0 replies; 8+ messages in thread
From: Clemens Ladisch @ 2015-04-14 19:49 UTC (permalink / raw)
  To: Johannes Lorenz, alsa-devel

Johannes Lorenz wrote:
>>>   b) race-condition free, assuming I'll use pairwise different handles
>>>   each thread
>>
>> Yes.
>
> You're really 100 percent sure that this is guaranteed to work?

Of course.  Not only does this page say so:
http://www.alsa-project.org/main/index.php/SMP_Design
but I also guaranteee to give your money back.  ;-)


Regards,
Clemens

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: parallel, real time safe waiting?
@ 2015-04-14 18:39 Johannes Lorenz
  2015-04-14 19:49 ` Clemens Ladisch
  0 siblings, 1 reply; 8+ messages in thread
From: Johannes Lorenz @ 2015-04-14 18:39 UTC (permalink / raw)
  To: alsa-devel

> >   1.) Let each thread open a handle using snd_seq_open()
> >   2.) Call snd_pcm_wait() in each thread
> > 
> > Are these functions
> > 
> >   a) real time safe?
> 
> snd_seq_open() is not, but why would that matter?
> Don't you call it from the GUI thread?

Ah, indeed, seq_open() is part of the initialization, so for this one, it does not matter.

> >   b) race-condition free, assuming I'll use pairwise different handles
> >   each thread
> Yes.

You're really 100 percent sure that this is guaranteed to work? Sorry for asking this :) I was expecting a "No, of course not.".

Also, this will probably work for all handle-based-functions, as long as you keep using pairwise different handles?

Regards,
Johannes

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: parallel, real time safe waiting?
  2015-04-13 17:56 Johannes Lorenz
@ 2015-04-14 12:35 ` Clemens Ladisch
  0 siblings, 0 replies; 8+ messages in thread
From: Clemens Ladisch @ 2015-04-14 12:35 UTC (permalink / raw)
  To: Johannes Lorenz, alsa-devel

Johannes Lorenz wrote:
>   1.) Let each thread open a handle using snd_seq_open()
>   2.) Call snd_pcm_wait() in each thread

> Are these functions
>
>   a) real time safe?

snd_seq_open() is not, but why would that matter?
Don't you call it from the GUI thread?

>   b) race-condition free, assuming I'll use pairwise different handles each thread

Yes.


Regards,
Clemens

^ permalink raw reply	[flat|nested] 8+ messages in thread

* parallel, real time safe waiting?
@ 2015-04-13 17:56 Johannes Lorenz
  2015-04-14 12:35 ` Clemens Ladisch
  0 siblings, 1 reply; 8+ messages in thread
From: Johannes Lorenz @ 2015-04-13 17:56 UTC (permalink / raw)
  To: alsa-devel

Hello,

I'd like to write a sequencer that can handle many synthesizers. Thus, I want them to run these synths parallel. Still, I'd like to keep my code real time safe, i.e. no malloc(), usleep(), ofstream, pthread mutexes etc. However, I wondered how to let all my threads sleep for x useconds if there's nothing to do for x useconds.

My idea was:

  1.) Let each thread open a handle using snd_seq_open()
  2.) Call snd_pcm_wait() in each thread

Are these functions

  a) real time safe?
  b) race-condition free, assuming I'll use pairwise different handles each thread

Many thanks for any help.

Kind regards,
Johannes

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-04-15 19:41 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-15 15:51 parallel, real time safe waiting? Johannes Lorenz
2015-04-15 19:41 ` Clemens Ladisch
  -- strict thread matches above, loose matches on Subject: below --
2015-04-14 20:03 Johannes Lorenz
2015-04-15  7:52 ` Clemens Ladisch
2015-04-14 18:39 Johannes Lorenz
2015-04-14 19:49 ` Clemens Ladisch
2015-04-13 17:56 Johannes Lorenz
2015-04-14 12:35 ` Clemens Ladisch

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.