• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Real-time thread issue
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Real-time thread issue


  • Subject: Real-time thread issue
  • From: "Alpar Meszaros" <email@hidden>
  • Date: Thu, 16 Jun 2005 18:18:19 +0100

Dear All,
 
We've been building a plug-in for QuickTime to make an interactive music
player.  We get some stuttering because we have not been able to get the proper priority of the feeder thread. Here are some code part what we tried out, nothing changed. Can someone help us how to set the priority of a thread to be real-time priority?
There are lots of things which are not clear for us. For instance. What is the difference between mach_thread_self() and pthread_mach_thread_np(feederFn) for the first parameter of the thread_policy_set(...) function? What is the range for the thePrecedencePolicy.importance? How can we determine the right value for the fields for theTCPolicy.period, theTCPolicy.computation, theTCPolicy.constraint?
 
Many Thanks!
 
 
My thread function is declared as follows:
void* feederFn(void* pParam);
 
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
thread_extended_policy_data_t  theFixedPolicy;
hread_precedence_policy_data_t  thePrecedencePolicy;
theFixedPolicy.timeshare = 0;
thread_policy_set (pthread_mach_thread_np(feederFn)THREAD_EXTENDED_POLICY, (thread_policy_t)&theFixedPolicy,
        THREAD_EXTENDED_POLICY_COUNT);
        
thePrecedencePolicy.importance = 15; //what is the range of this parameter?
thread_policy_set (pthread_mach_thread_np(feederFn), THREAD_PRECEDENCE_POLICY,
(thread_policy_t&thePrecedencePolicy,THREAD_PRECEDENCE_POLICY_COUNT);
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 thread_time_constraint_policy_data_t theTCPolicy;
            UInt64     theComputeQuanta;
            UInt64     thePeriod;
            UInt64     thePeriodNanos;
kern_return_t error;
thePeriodNanos = 20000000; //How can I determine this value?
theComputeQuanta = AudioConvertNanosToHostTime ( thePeriodNanos * 0.15 );
thePeriod = AudioConvertNanosToHostTime (thePeriodNanos);
        
theTCPolicy.period = thePeriod;
theTCPolicy.computation = theComputeQuanta;
theTCPolicy.constraint = thePeriod;
theTCPolicy.preemptible = true;
error = thread_policy_set (pthread_mach_thread_np(feederFn), THREAD_TIME_CONSTRAINT_POLICY, 
    (thread_policy_t)&theTCPolicy, THREAD_TIME_CONSTRAINT_POLICY_COUNT);
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Real-time thread issue
      • From: Markus Hitter <email@hidden>
  • Prev by Date: Re: About Group, OpenDirectory, Active Directory and Unix philosophy
  • Next by Date: Re: Real-time thread issue
  • Previous by thread: Re: Linkage problem with dylib
  • Next by thread: Re: Real-time thread issue
  • Index(es):
    • Date
    • Thread