eosPThread(API)
提供: Eospedia
General/eosPThreadはマルチスレッドで処理を実行するためのAPI です。
目次
定数
eosPThreadのメンバーstatusの値(スレッド状態)として使用します。
typedef enum eosPThreadStatus { eosPThreadStatusWaiting = 0, eosPThreadStatusRunning = 1 } eosPThreadStatus;
構造体
グローバル変数
使用フラグ
extern int __eosPThread__;
スレッド数
extern int __eosPThreadNum__;
スレッド構造体
このAPIで使用する設定です。
typedef struct eosPThread { pthread_t* th; /* [max] thread */ eosPThreadStatus* status; /* [max] thread status */ long* id; /* [max] thread ID indicated by count */ int max; /* maximum thread number working simultaneously. */ long count; /* count of created threads */ long latest; /* working thread ID which started latest */ long oldest; /* working thread ID which started oldest */ pthread_mutex_t mutex; pthread_mutexattr_t mutex_attr; } eosPThread;
API
初期化
extern void eosPThreadInit (eosPThread* t, int max, int mode);
スレッド作成
extern int eosPThreadCreateOnWaitingThread (eosPThread* t, void* (*start_routine)(void *), void * arg, int mode); extern int eosPThreadCreate (eosPThread* t, int i, void* (*start_routine)(void *), void * arg, int mode); extern void eosPThreadJoin (eosPThread* t, int i, int mode); extern void eosPThreadJoinAll(eosPThread* t, int mode);
ミューテックス(排他処理)
初期化
extern void eosPThreadMutexInit(eosPThread* t);
削除
extern void eosPThreadMutexDestroy(eosPThread* t);
ミューテックス発行
extern void eosPThreadMutexLock(eosPThread* t);
ミューテックス解除
extern void eosPThreadMutexUnlock(eosPThread* t);