-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proper Xenomai inter-process communication (IPC) #16
Comments
ok - this is pretty lowlevel stuff. |
Does it also cause problems with |
not sure. I don't see why it should. |
It may be related to having heavy CPU load in the audio thread? |
No, the quit message sometimes even fails when there are no synths running on the server. |
going into detail in issue #9 |
I don't think this inherently causes any problems with The only problem I could see is that the last call to
(which originally was does not get executed because the auxiliary thread it runs in is terminated before it gets executed after the last call to Thinking of how to reduce CPU usage for this operation, the suggestion above is not going to work because using xenomai's condition variables forces the thread to switch to primary mode, and then it would switch back to secondary mode once resumed, so: The only path provided by Xenomai for communication between real-time and non-real-time threads seems to be "pipes", which uses a pseudo-device file descriptor at the non-real-time end. http://www.xenomai.org/documentation/trunk/html/api/group__pipe.html Here, for instance, we used Xenomai's pipes https://github.com/BelaPlatform/Bela/blob/2b9b0bf04fd07b8ada325fd27da7a6c1685a60b4/core/Midi.cpp |
Back to the point, what
Now, when the CPU load is low, there are occasional "dropouts", as in: the number of times this thread is actually woken up is smaller than the number of times it is signalled. This makes sense, if you think that this is a low-prio thread and should not necessarily have to wake up every time the audio callback is terminated (as we are requesting it to do by Either way - without even looking at the internal code of all the above tasks - I think it is safe to assume that - by design - they a) are all interruptible and thread-safe, and b) they can run a reasonably small number of times per seconds, even smaller than Fs/blocksize per second (which - again - is the number of times the thread is resumed). (I say I assume that because otherwise all the SC programs would always be one step away from collapsing). This said, in principle we should be able to simply set this task to sleep for, e.g.: 1ms so that it wakes itself up without need for synchronization with the audio callback. |
The issue is that
staticMAudioSync->Signal();
(which in turns callsstd::condition_variable_any::notify_one
) was causing a mode switch in the audio thread.We removed the mode switch from the audio thread by moving it to another thread:
, still this is inelegant, non-deterministic and adds to the CPU load.
The proper way around this is to rewrite
common/SC_SyncCondition.h
andcommon/SC_lock.h
so that they use Xenomai-specific IPC functions instead of condition_variable_any and std::mutex.The discussion here shows a possible method using
RT_COND
,rt_cond_wait
,rt_cond_signal
,RT_MUTEX
,rt_mutex_acquire
,rt_mutex_release
The text was updated successfully, but these errors were encountered: