Thank you for guidance!
I verified pthread_create, pthread_join, pthread_exit are working both of Simulator and Device in iOS SDK 4.3 (latest) Maybe you're talking about this thread:
viewtopic.php?f=12&t=6327&start=30 I'm feeling strange too, but guessing with the function name in the error message, it maybe a different version of pthread linked to old version of iOS SDK. If your binary was built with old version of SDK, it can be resolved by just recompiling.
As I remember, there was big changes between iOS 2.x > iOS 3 which breaking backward compatibility. This maybe one of them. At the time, many apps broken and Apple requested developers to patch their apps.
And with my knowledge, pthread is recommended and core threading facility. There is no reason to be blocked.
I don't know about semaphores. I don't know how to use it.
I attach part of my test program.
- Code: Select all
#import "pthread_testAppDelegate.h"
#import <pthread.h>
@implementation pthread_testAppDelegate
@synthesize window=_window;
void T(void* thid)
{
printf("%s", (char*)thid);
sleep(4);
pthread_exit(NULL);
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
pthread_t th;
pthread_create(&th, NULL, T, "DDD");
void* status;
pthread_join(th, &status);
printf("XX");
// Override point for customization after application launch.
[self.window makeKeyAndVisible];
return YES;
}
XX printed after 4 seconds from DDD. Both of Simulator and Device.
I found <pthread.h> block on both of dgTypes.h and dContainersStdAfx.h. Former one looks can't affect classes in dContainers. I modified both of them like this.
- Code: Select all
#ifdef _MAC_VER
#include <pthread.h>
#include <semaphore.h>
// #ifndef _MAC_IPHONE
// #include <pthread.h>
// #include <semaphore.h>
// #endif
#include <unistd.h>
#include <libkern/OSAtomic.h>
#include <sys/sysctl.h>
#endif
In my opinion, the blocks in both files are duplicated and should be unified.
Library built well with this modification, but I didn't tested yet within actual application. How can I test thread-related code is working well?