• 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
How to get a sustained read speed under OS X
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to get a sustained read speed under OS X


  • Subject: How to get a sustained read speed under OS X
  • From: Marc Van Olmen <email@hidden>
  • Date: Thu, 03 Jun 2004 13:21:03 -0400

Hi,

Because it is realtime problem I'm having related to video/audio stream I
hope I can ask you guys this question:

How do I get a sustained stream working under OS X, or does OS X doesn't
provide a mechanism for this?

I thought it was a matter of getting the read thread the right priority or
is it better that I use some async reading?

I need to get a sustained speed of 3.5MBytes/second, this is easy to do but
as soon I start duplicate a file in the Finder on the same hard disk I'm
trouble, my read speeds drops very low. On a G5 the problem was worse then
on a G4 because maybe not so good harddisk.

I tried the following thread priority thricks but none of them solve the
issue although I noticed a slight improvement with certain priority but no
real solution.

Cheers,

Mvo
Ps the code snippets I used

Some code, this is the way I set my thread in my cocoa Application to I
"assume" realtime priority:



- (void) setThreadPolicy;
{
// Increase this thread's priority, and turn off timesharing. See the
notes at the top of this file.

kern_return_t error;
struct thread_time_constraint_policy constraintPolicy;
thread_precedence_policy_data_t precedencePolicy;
Float64 clockFrequency = AudioGetHostClockFrequency();

constraintPolicy.period = 0.010 * clockFrequency; // 10ms
constraintPolicy.computation = 0.001 * clockFrequency; // 1ms
constraintPolicy.constraint = 0.005 * clockFrequency; // 5ms
constraintPolicy.preemptible = true;

error = thread_policy_set(mach_thread_self(),
THREAD_TIME_CONSTRAINT_POLICY, (thread_policy_t)&constraintPolicy,
THREAD_TIME_CONSTRAINT_POLICY_COUNT);
if (error != KERN_SUCCESS) {
printf("Couldn't set feeder thread's TIME_CONSTRAINT policy %d",
error);

}
}


Also used this technique:


kern_return_t error;
thread_extended_policy_data_t extendedPolicy;
thread_precedence_policy_data_t precedencePolicy;

extendedPolicy.timeshare = 0;
error = thread_policy_set(mach_thread_self(), THREAD_EXTENDED_POLICY,
(thread_policy_t)&extendedPolicy, THREAD_EXTENDED_POLICY_COUNT);
if (error != KERN_SUCCESS) {
mach_error("Couldn't set feeder thread's extended policy", error);
}

precedencePolicy.importance = 45;
error = thread_policy_set(mach_thread_self(), THREAD_PRECEDENCE_POLICY,
(thread_policy_t)&precedencePolicy, THREAD_PRECEDENCE_POLICY_COUNT);
if (error != KERN_SUCCESS) {
mach_error("Couldn't set feeder thread's precedence policy", error);
}



Also gave my application the following prioirty

int set_my_task_policy(void) {

int ret;

struct task_category_policy tcatpolicy;

tcatpolicy.role = TASK_FOREGROUND_APPLICATION;

if ((ret=task_policy_set(mach_task_self(),
TASK_CATEGORY_POLICY, (int *)&tcatpolicy,
TASK_CATEGORY_POLICY_COUNT)) != KERN_SUCCESS) {
fprintf(stderr, 3set_my_task_policy() failed.\n2);

return 0;
}
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: How to get a sustained read speed under OS X
      • From: William Stewart <email@hidden>
    • Re: How to get a sustained read speed under OS X
      • From: Doug Wyatt <email@hidden>
    • Re: How to get a sustained read speed under OS X
      • From: Jeff Moore <email@hidden>
    • Re: How to get a sustained read speed under OS X
      • From: Bob Ippolito <email@hidden>
  • Prev by Date: Re: With Delta 1010: 8 + 2 = 12!
  • Next by Date: Re: How to get a sustained read speed under OS X
  • Previous by thread: Re: DIGI001 zero channels!
  • Next by thread: Re: How to get a sustained read speed under OS X
  • Index(es):
    • Date
    • Thread