ã¹ã¬ããã調ã¹ã¾ãã£ã¦åãã£ããã¨ãã¡ã¢
ããã§ããï¼åããã¾ããï¼ï¼ï¼
WIN32ã®ã¿ã®ã話ã§ãã
ã¹ã¬ããã£ã¦çµæ§å®è£
ä¾åãªã®ãâ¦ã
å ã«ã¾ã¨ã
- windowsã¯_beginthreadexæ¨å¥¨(CreateThreadã¯ã¡ã¢ãªãªã¼ã¯ã®å±éºãã)
- _beginthreadã_beginthreadexãå¼ã³åºãã«ã¯ãprocess.h ãinclude
- _beginthreadexã«å
¥ããããé¢æ°ãã¤ã³ã¿ã¯ã__stdcall ã __clrcall
- __stdcall 㯠static WINAPI ã
- __clrcall 㯠CLRç³»ãªã®ã§ä»åã¯æªèª¿æ»
- éstaticãªã¡ã³ãã¡ã½ãã(__thiscall)ãå¼ã³åºãã«ã¯ãã©ããããã¶ããâstaticでないクラスメンバ関数を_beginthreadで実行させる方法。 - かせいさんとこ
CreateThread
- C++ã§ã¯ç¡ãCã®é¢æ°ã
- ãã®ã¾ã¾ä½¿ãã¨ã¡ã¢ãªãªã¼ã¯ãèµ·ããã®ã§ããã«ãã¹ã¬ãããªC++ã§ã¯ä½¿ã£ã¦ã¯ãããªã
- å¤ãC++ã®ã¡ã½ããã¯ãã°ãã¼ãã«å¤æ°ã使ã£ã¦ããä½ãªãã§ãã«ãã¹ã¬ããã«å¼±ãã®ãå¤ã
- ã¡ã¢ãªã®è§£æ¾ã®å¦çãã©ãããããbeginthreadã¨ã_beginthreadexã使ãã¹ã
- MFCã®å ´åã¯ãAfxBeginThreadã使ãã¹ãããã
- ä»åã¯MFCã¯ãããªãã®ã§ãã¹
- åç §ï¼CreateThreadと_beginthreadex - blog
_beginthreadã¨ã_beginthreadex
ããããã®éãã¯ï¼
ã | _beginthread | _beginthreadex |
---|---|---|
å¼åºè¦ç´ | __cdecl or __clrcall | __stdcall or __clrcall |
Handleã®ã¯ãã¼ãº | çµãã£ããåæã«éãã | CloseHandleã§æ示çã«éããå¿ è¦ãã |
ã¨ã©ã¼æã®æ»ãå¤ | -1 | 0 |
åæ¢ããç¶æ ã§ã¹ã¬ãããçæ | à | â |
ã¹ã¬ããèå¥å | à | â |
åããã»ã¹ã¸ã®ç¶æ¿ | à | â |
ã©ã£ã¡ãè¯ãã®ï¼
ãªãã£ã·ã£ã«ã¨ãã¦ã¯ã_beginthreadexãæ¨å¥¨
_beginthread ããã _beginthreadex ã使ç¨ããæ¹ãå®å ¨ã§ãã
_beginthread ã«ãã£ã¦çæãããã¹ã¬ããã®çµäºãæ©ãããã¨ã_beginthread ã®å¼ã³åºãå ã«è¿ããããã³ãã«ãç¡å¹ã«ãªãå¯è½æ§ããå¥ã®ã¹ã¬ãããæãå¯è½æ§ãããã¾ãã
ãããã_beginthreadex ããè¿ããããã³ãã«ã¯ _beginthreadex ã®å¼ã³åºãå ã§éããããå¿ è¦ãããããã_beginthreadex ãã¨ã©ã¼ãè¿ããªãã£ãå ´åã«ã¯ãã³ãã«ãæå¹ã§ãããã¨ãä¿è¨¼ããã¾ãã
MSDN:_beginthread、_beginthreadex (CRT)
- _beginthreadã¯å¼åºå
ã®ã¡ã½ãããçµäºããã¨ãåæã«ãã³ãã«ãéãã¾ã
- å¼åºç´å¾ã«çµäºãããããªã¡ã½ãããå¼ã§ããã³ãã«ããããã¨åæã®å¦çã親å´ã«å
¥ããã¨å±éº
- å ´åã«ãã£ã¦ã¯ãå¥ã®ã¹ã¬ããã«å½±é¿ãåã¶ãããã§ãã
- å¼åºç´å¾ã«çµäºãããããªã¡ã½ãããå¼ã§ããã³ãã«ããããã¨åæã®å¦çã親å´ã«å
¥ããã¨å±éº
- _beginthreadexã¯æ示çã«ãã³ãã«ãCloseããªããã°ãªããªãã®ã§ãå¿ããã¨ããã¯ããã§ã¡ã¢ãªãªã¼ã¯ã®å±éº
å¼åºãè¦ç´ã«ã¤ãã¦
- _beginthreadã¯ã__cdecl
- _beginthreadexã¯ã__stdcall
__cdecl
- ç°¡åã«è¨ãã°ãstaticãªã¡ã½ãã
__stdcall
- staticã ããWindows APIã®å¼ã³åºãè¦ç´ã«åºã¥ããã¡ã½ããã
- å ·ä½çã«ã¯å®£è¨æã«é¢æ°åã®åã«WINAPIãã¤ããã
int WINAPI func( void );
- __cdeclããæ©ããããã
詳ããã¯ãã¡ããåç
§â二流プログラマの三流な日常: 関数呼び出しの内部を理解する(2)
ããããªãã£ããã¨
- _beginthreadã®åå¨çç±ããã¾ãã¡åãããã
- åæã«ãã³ãã«ãéãã¦ãããã®ã¯ä¾¿å©ã¨ãããããã©â¦ã
- ã¹ã¬ããä½ãã£ã±ãªãã§ããã®å¾ããã³ãã«ã使ã£ã¦è²ã ããæ°ãç¡ããªãã_beginthreadã§ãè¯ãã£ã¦ãã¨ï¼
ãã®ä»
- MSDNããããªã³ã¯å¤ãã