Re: How to get a sustained read speed under OS X
Re: How to get a sustained read speed under OS X
- Subject: Re: How to get a sustained read speed under OS X
- From: Doug Wyatt <email@hidden>
- Date: Thu, 3 Jun 2004 11:58:27 -0700
Regardless of thread priorities, I believe the kernel queues I/O
requests to a device in the order they were made and they cannot be
reordered.
According to one of the authors of the Carbon File Manager, async reads
are no better than synchronous reads on X.
Doug
On Jun 3, 2004, at 10:21, Marc Van Olmen wrote:
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.
_______________________________________________
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.