Re: Bizarre x86 segment layout problem causing select() slowdown
Re: Bizarre x86 segment layout problem causing select() slowdown
- Subject: Re: Bizarre x86 segment layout problem causing select() slowdown
- From: Dave Hayden <email@hidden>
- Date: Sat, 3 Feb 2007 09:59:08 -0800
On Feb 3, 2007, at 7:45 AM, John Daniel wrote:
Threads? And your problem goes away when you re-arrange statements
and/or add no-ops? Is it possible you have a multithreading
problem? That is what it sounds like to me. How many threads do you
have running a select() loop? Are you using POSIX threads or
NSThreads? There are some subtle differences if you add Cocoa into
the mix.
An older version of sqlite had problems with NSThread's stack size,
so we had to switch to pthreads to accommodate. The problem's long
since fixed, but I never switched back to NSThread. There could be
anywhere from zero to a dozen or more threads doing select at a time,
usually two or three. Can you give more info about this select/
multithreading/Cocoa problem or point to a reference online? I'm not
having much luck with Google.
This sounds a lot more reasonable that mystery linker-loader issues--
though it's still in the spooky realm for me. :)
Thanks!
-Dave
FWIW, here's the thread code:
void*
threadBody(void* arg)
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
NS_DURING
SEL selector = ((struct threadArgs*)arg)->selector;
id target = ((struct threadArgs*)arg)->target;
id object = ((struct threadArgs*)arg)->object;
[target performSelector:selector withObject:object];
[(NSObject*)target release];
[(NSObject*)object release];
NS_HANDLER
NSLog(@"*** Exception in threadBody: %@", [localException
description]);
NS_ENDHANDLER
[pool release];
free(arg);
return NULL;
}
void
detachThread(SEL selector, id target, id object)
{
struct threadArgs* arg = malloc(sizeof(struct threadArgs));
pthread_t thread;
pthread_attr_t attrs;
if ( arg == NULL )
{
NSLog(@"detachThread(): malloc() failed");
return;
}
arg->selector = selector;
arg->target = [(NSObject*)target retain];
arg->object = [(NSObject*)object retain];
pthread_attr_init(&attrs);
pthread_attr_setstacksize(&attrs, 1048576);
pthread_create(&thread, &attrs, threadBody, arg);
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden