Thanks for the info. I am currently using ubuntu edgy and have confirmed that the system clock is 250hz. I think what I am going to do is change distros to the ubuntu studio (for audio and video work) when it comes out. My guess is that it will have the higher system clock frequency.
I haven't seen the dyntick feature around, I'll have to check it out.
Thanks
Multimedia Timer for Linux
That dyntick definitely looks useful. I spent most of today getting my application working smoothly on Mac OS X and didn't end up with anything too acceptable. I ended up switching the sleep to nanosleep() instead of clock_nanosleep() and used gettimeofday() instead of clock_gettime(). This got it close, as the timer seemed to be 1000hz if not higher. However, the timing was not consistent. I would get fairly periodic jumps where I would ask for 1-4ms and get held back for 10-20 a few requests in a row. This was after I changed the priority to realtime (priority 96-128). I am not entirely sure that my priority was getting set right...
I was using a function I found here:
However, when I compiled this, after adding some includes, I was told that thread_policy_set expected an integer_t* as a 3rd parameter instead of the two types I was giving it. (the types I was giving it are what is documented all over the internet) So I changed the types and let the compiler cast both an int and a bool to integer_t types. In retrospect this seems like the most probably cause for my problems. Does anyone know what is going on here?
Or maybe, there is a better way to be doing this on OS X.
Thanks
I was using a function I found here:
// Reschedules the indicated thread according to new parameters: // // machThread The mach thread id. Pass 0 for the current thread. // newPriority The desired priority. // isTimeShare false for round robin (fixed) priority, // true for timeshare (normal) priority // // A standard new thread usually has a priority of 0 and uses the // timeshare scheduling scheme. Use pthread_mach_thread_np() to // to convert a pthread id to a mach thread id kern_return_t RescheduleStdThread( mach_port_t machThread, int newPriority, boolean_t isTimeshare ) { kern_return_t result = 0; thread_extended_policy_data_t timeShareData; thread_precedence_policy_data_t precidenceData; //Set up some variables that we need for the task precidenceData.importance = newPriority; timeShareData.timeshare = isTimeshare; if( 0 == machThread ) machThread = mach_thread_self(); //Set the scheduling flavor. We want to do this first, since doing so //can alter the priority result = thread_policy_set( machThread, THREAD_EXTENDED_POLICY, &timeShareData, THREAD_EXTENDED_POLICY_COUNT ); if( 0 != result ) return result; //Now set the priority return thread_policy_set( machThread, THREAD_PRECEDENCE_POLICY, &precidenceData, THREAD_PRECEDENCE_POLICY_COUNT ); }
However, when I compiled this, after adding some includes, I was told that thread_policy_set expected an integer_t* as a 3rd parameter instead of the two types I was giving it. (the types I was giving it are what is documented all over the internet) So I changed the types and let the compiler cast both an int and a bool to integer_t types. In retrospect this seems like the most probably cause for my problems. Does anyone know what is going on here?
Or maybe, there is a better way to be doing this on OS X.
Thanks
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement