pthreads and standard C library calls and maybe magic Xcode switches
pthreads and standard C library calls and maybe magic Xcode switches
- Subject: pthreads and standard C library calls and maybe magic Xcode switches
- From: Cem Karan <email@hidden>
- Date: Tue, 21 Aug 2007 16:14:02 -0400
I'm continuing to work on my pthreads based program, and realized
that I've run into a potential problem. When I access memory that is
shared between two threads, I always mark the memory as volatile, and
I use a lock around it. This works for my own code, but what about
code that is coming in from the standard libraries, like memcpy()? I
can put locks around it all day, but that doesn't make memcpy() have
volatile qualified arguments, which means that there may be caching
going on that makes a copy done by one thread on one processor
invisible to a thread on another processor (that is what the volatile
is for) despite locking. I'm quite willing to write wrappers like
that below where needed, but my question is, is there a thread-aware
version of the standard C library? If so, how do I tell Xcode to use
it? Better yet, is there a magic switch somewhere that I can throw
that will tell Xcode to be aware that my code is threaded, and that
therefore all the caches must be kept fully coherent between the
cores/processors?
inline volatile void *memcpy(volatile void *dest, volatile void
*source, size_t len)
{
return memcpy(dest, source, len);
}
Thanks,
Cem Karan
_______________________________________________
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