「eosPThread(API)」の版間の差分
提供: Eospedia
(→API) |
(→初期化) |
||
行33: | 行33: | ||
== API == | == API == | ||
===初期化=== | ===初期化=== | ||
− | max分のスレッドを初期化し、t->thにスレッド、t->statusに状態、t-> | + | max分のスレッドを初期化し、t->thにスレッド、t->statusに状態、t->idにIDをそれぞれリストとして格納します。(スレッド数はt->maxに格納) |
extern void eosPThreadInit (eosPThread* t, int max, int mode); | extern void eosPThreadInit (eosPThread* t, int max, int mode); | ||
+ | 状態は全てeosPThreadStatusWaiting<br> | ||
+ | IDは全て0<br> | ||
+ | <br> | ||
===スレッド作成=== | ===スレッド作成=== |
2015年3月17日 (火) 03:11時点における最新版
General/eosPThreadはマルチスレッドで処理を実行するためのAPI です。mrc2Dto3Dやmrc3Dto2D、mrcImageFFTなどで使用されています。
目次
定数
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
初期化
max分のスレッドを初期化し、t->thにスレッド、t->statusに状態、t->idにIDをそれぞれリストとして格納します。(スレッド数はt->maxに格納)
extern void eosPThreadInit (eosPThread* t, int max, int mode);
状態は全てeosPThreadStatusWaiting
IDは全て0
スレッド作成
状態がeosPThreadStatusWaitingのスレッド
extern int eosPThreadCreateOnWaitingThread (eosPThread* t, void* (*start_routine)(void *), void * arg, int mode);
i番目のみ
extern int eosPThreadCreate (eosPThread* t, int i, void* (*start_routine)(void *), void * arg, int mode);
スレッド追加
i番目のみ
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);