On Friday 25 November 2005 07:21, Iain Duncan wrote: > > It was originally intended to be used in the main thread at start-up. > > However, you can make the child threads inherit the real-time scheduling > > policy with something like: > > > > uintptr_t csound_thread_func(void *userData); > > Istvan, does this mean that in order to have the rest of the app at > lower priority then the csound thread I must use pthreads instead of the > csoundThread functions? The csoundThread functions are based on pthreads, so you can use pthreads to create the thread and set priority on Linux only, and use csoundCreateThread() on other systems for portability (obviously, you will not have priority control, but at least it works). You can join a thread created by pthread_create() with csoundJoinThread(), just cast the function to void *(*)(void*), and cast the resulting pthread_t to void*. However, if you do not care about non-POSIX systems like Win32, then you do not really need the csoundThread functions for anything at all. > I'm a bit confused here. Would it be easiest to > just revert all my thread creation calls to pthread native library > calls, or can I combine them with the csound api thread calls? Would it You can combine the Csound API thread functions with native pthreads on Linux where the Csound interface is based on pthreads, with the following simple casts: void *(*)(void*) -> uintptr_t (*)(void*) pthread_t -> void* pthread_mutex_t -> void* > make sense to use pthread native calls for only the fltk thread? I think > that is the only one that critically needs to be lowered, but ideally I > would like the csound thread to be higher priority than keyboard and > midi input as well. On the other hand, keyboard and midi input is going > to be coming in so slowly relatively speaking, that maybe the simplest > solution is to keep the rest of the app in csoundThreads and pthread > only the fltk thread. Again, you can use code like this for creating a thread with the same high priority as main (replace the names csound_thread_func, userData, and csound_thread as needed): uintptr_t csound_thread_func(void *); ... #ifdef LINUX { pthread_attr_t attr; pthread_t th; pthread_attr_init(&attr); pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED); pthread_create(&th, &attr, (void *(*)(void*)) csound_thread_func, userData); csound_thread = (void*) th; pthread_attr_destroy(&attr); } #else csound_thread = csoundCreateThread(csound_thread_func, userData); #endif The resulting csound_thread (of type void*) can be joined with csoundJoinThread() on all platforms. Also, for low priority threads, just add this at the beginning of the thread function: #ifdef LINUX { struct sched_param sp; memset(&sp, 0, sizeof(struct sched_param)); pthread_setschedparam(pthread_self(), SCHED_OTHER, &sp); } #endif ------------------------------------------------------- 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