Csound Csound-dev Csound-tekno Search About

[Cs-dev] Question about locking queues/processor.

Date2005-12-04 03:12
FromIain Duncan
Subject[Cs-dev] Question about locking queues/processor.
While not strictly to do with csound, this is for my csound front end 
project. I understand using queues to share data between threads, and 
protecting the queue with a mutex. In this context I have some high and 
low priority threads ( ie csound vs userinput vs display ) using 
pthreads. Is there a way for one to guarantee that a section of code, 
once entered, gets finished? Can I essentially make writing to a queue 
atomic? I would like to make sure that once a thread starts a queue push 
or pop it won't get interrupted at all.

I figure one obvious solution is to have a global mutex that only one 
thread can ever have, and if a thread needs to be guaranteed not to be 
interrupted, it can just keep this mutex. But perhaps there is a more 
elegant way that will avoid the potential overhead of a bunch of context 
switched while higher priority threads try for this mutex and fail? Is 
there a mechanism for a lower priority thread to temporarily pre-empt 
everything else for the duration of this queue operation?

In other news, tests of the multi-user real time front end design are 
going well, and it's going to be hella cool for gigging with csound5! =)

Thanks
iain


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net