ããã»ã¹ééä¿¡ã®æéã®æ¹æ³ã®1ã€ã¯ãå ±æã¡ã¢ãªïŒå ±æã¡ã¢ãªïŒã䜿çšããŠå®è£ ãããŸãã ããããç§ãèŠã€ããã¢ã«ãŽãªãºã ã§ã¯ãã¡ã¢ãªãã³ããŒããå¿ èŠããããã¯ã©ã€ã¢ã³ããåèµ·åããåŸïŒããã«1ã€ããèš±å¯ãããŠããŸããïŒããµãŒããŒãåèµ·åããå¿ èŠãããããšã¯è«ççã«æããŸããã§ããã æå¿ãæ¡ã£ãŠãå ±æã¡ã¢ãªã䜿çšããæ¬æ Œçãªã¯ã©ã€ã¢ã³ããµãŒããŒãéçºããããšã«ããŸããã
ãã®ããããŸããéçºããã¯ã©ã€ã¢ã³ããµãŒããŒã®æ©èœèŠä»¶ã決å®ããå¿ èŠããããŸãã æåã®äž»èŠãªèŠä»¶ïŒããŒã¿ãã³ããŒããªãã§ãã ããã 第äºã«ãããã«ãã¯ã©ã€ã¢ã³ãã-è€æ°ã®ã¯ã©ã€ã¢ã³ãããµãŒããŒã«æ¥ç¶ã§ããŸãã 第äžã«ãã¯ã©ã€ã¢ã³ãã¯åæ¥ç¶ã§ããŸãã 第4ã«ãå¯èœã§ããã°ããœãããŠã§ã¢ã¯ã¯ãã¹ãã©ãããã©ãŒã ã§ããå¿ èŠããããŸãã 課ãããèŠä»¶ãããã¢ãŒããã¯ãã£ã®ã³ã³ããŒãã³ããåºå¥ã§ããŸãã
- å ±æã¡ã¢ãªã§äœæ¥ãã«ãã»ã«åããã³ã³ããŒãã³ãã
- ã¡ã¢ãªãããŒãžã£ãŒïŒã¢ãã±ãŒã¿ãŒïŒ;
- 転éãããããŒã¿ãããã¡ã®æäœãã«ãã»ã«åããã³ã³ããŒãã³ã
ãã³ããŒãªã³ã©ã€ããïŒä»¥éãCBufferïŒã®ã€ããªãã®ãŒãå®è£ ããŸãã - ããã»ã¹éãã¥ãŒããã¯ã¹ã
- ããã»ã¹éæ¡ä»¶å€æ°ãŸãã¯ãã®é¡äŒŒç©ã
- ãããŠãçŽæ¥ã¯ã©ã€ã¢ã³ããšãµãŒããŒã
å ±æã¡ã¢ãªãæ±ãéã®åé¡ã¯ãããããããŸãã ãããã£ãŠããã€ãŒã«ãåçºæãããboost.interprocessãæ倧éã«æŽ»çšããŸããã ãŸããã¯ã©ã¹shared_memory_objectãmapped_regionã䜿çšããŸããããã«ãããLinuxããã³Windowsã§å ±æã¡ã¢ãªãæäœãããããªããŸãã ãããããIPCã»ããã©ã®å®è£ ã䜿çšã§ããŸããããã¯ããã¥ãŒããã¯ã¹ãšæ¡ä»¶å€æ°ã®äž¡æ¹ã®æ©èœãå®è¡ããŸãã ãŸããstd :: vectorã®å®è£ ãCBufferãboostã®ãµã³ãã«ãšããŠäœ¿çšããŸãïŒå ±æã¡ã¢ãªãæäœããå Žåããã€ã³ã¿ã®ã¿ã§æäœã§ããŸãããªãã»ããã®ã¿ã§ãããããã£ãŠãstd :: vector + allocatorã¯æ©èœããŸããïŒã ããŒã¹ãã§ããããã»ã¹é䞡端ãã¥ãŒã®å®è£ ãèŠã€ããããšãã§ããŸãããã¯ã©ã€ã¢ã³ããµãŒããŒã®éçºã§ããã䜿çšããæ¹æ³ãèŠã€ããŸããã§ããã ãããŠãå ±æã¡ã¢ãªã«é¢ããã¡ã¢ãªãããŒãžã£ïŒã¢ãã±ãŒã¿ïŒã«çåããããŸããã åœç¶ãããã¯åŸæŒãã§ãããä»ã®åé¡ã®è§£æ±ºã«çŠç¹ãåãããŠããŸãã ãããã£ãŠãããŒã¹ãã«ã¯ã³ã³ãã€ã«ãå¿ èŠãšããªãã©ã€ãã©ãªãå¿ èŠã§ãïŒããããŒã®ã¿ïŒã MSVCã§ã®ããŒã¹ãã¯ãã®èŠ³ç¹ã«åæããªãå¯èœæ§ããããŸãããã¯ã©ãã«ã€ããŠã¯å¿ããªãã§ãã ãã-BOOST_ALL_NO_LIBããªããã»ããµãŒã¯ããã©ã°ãã³ã¡ã³ããã®äœ¿çšãçŠæ¢ããŸãã
ã¯ã©ã€ã¢ã³ããšãµãŒããŒã®å®è£
ã¯ã©ã€ã¢ã³ããšãµãŒããŒéã®ããŒã¿è»¢éã®å®è£ ã¯éåžžã«ç°¡åã§ãã ããã¯ãéä¿¡ãããã¡ã®ãªãã»ããïŒã¢ãã¬ã¹ïŒããéä¿¡ãã¡ãã»ãŒãžãšããŠäœ¿çšãããåæãªããžã§ã¯ãã察å¿ããããã»ã¹éã§çœ®ãæãããããã»ããã©ã䜿çšãããããã¥ãŒãµ-ã«ã¹ã¿ãã¢ãã«ã®å®è£ ã«äŒŒãŠããŸãã åã¯ã©ã€ã¢ã³ããšãµãŒããŒã«ã¯ç¬èªã®ãªãã»ãããã¥ãŒãããããã¥ãŒã®å€æŽãéç¥ããåä¿¡ãããã¡ãŒãšã»ããã©ã®åœ¹å²ãæãããŸãã ãããã£ãŠããããã¡ãå¥ã®ããã»ã¹ã«éä¿¡ããããšããããã¡ãªãã»ããããã¥ãŒã«å ¥ããããã»ããã©ã解æŸãããŸãïŒãã¹ãïŒã 次ã«ãå¥ã®ããã»ã¹ãããŒã¿ãèªã¿åããåŸ æ©ã»ããã©ããã£ããã£ããŸãã ããã©ã«ãã§ã¯ãããã»ã¹ã¯ããŒã¿ãå¥ã®ããã»ã¹ã«ãã£ãŠåä¿¡ãããã®ãåŸ æ©ããŸããïŒéãããã¯ïŒã ãããããµã³ãã«å®è£ ãåãããšãã§ããŸã ã å®éã«ã¯ããããã¡èªäœã®éä¿¡ã«å ããŠãå€ãã®å Žåãèå¥æ å ±ãéä¿¡ããå¿ èŠããããŸãã ããã¯éåžžæŽæ°ã§ãã ãããã£ãŠãçªå·ã転éããæ©èœãSendã¡ãœããã«è¿œå ãããŸããã
ã¯ã©ã€ã¢ã³ãã¯ã©ã®ããã«ãµãŒããŒã«æ¥ç¶ããŸããïŒ
ã¢ã«ãŽãªãºã ã¯éåžžã«åçŽã§ããµãŒããŒæ å ±ã¯å³å¯ã«å ±æã¡ã¢ãªå ã®ç¹å®ã®ãªãã»ããã«ãããŸãã ã¯ã©ã€ã¢ã³ããå ±æã¡ã¢ãªããéãããšããæå®ãããã¢ãã¬ã¹ã®æ§é ãèªã¿åããŸããååšããªãå ŽåããµãŒããŒã¯ååšãããååšããå Žåãã¯ã©ã€ã¢ã³ãã®ããŒã¿æ§é ã«ã¡ã¢ãªãå²ãåœãŠããããåããæ§é äžã®ãªãã»ããã瀺ãã€ãã³ãããµãŒããŒäžã§çºçãããŸãã 次ã«ããµãŒããŒã¯ã¯ã©ã€ã¢ã³ãã®ãªã³ã¯ãªã¹ãã«æ°ããã¯ã©ã€ã¢ã³ããè¿œå ããã¯ã©ã€ã¢ã³ãã§æ¥ç¶ã€ãã³ããçºçãããŸãã ã·ã£ããããŠã³ãåæ§ã®æ¹æ³ã§å®è¡ãããŸãã
æ¥ç¶ç¶æ ã®è©äŸ¡
ã¯ã©ã€ã¢ã³ããšãµãŒããŒéã®æ¥ç¶ç¶æ ã®ç¢ºèªã¯ãTCPãšåæ§ã«æ§ç¯ãããŸãã æéééã§ãã©ã€ããã±ãããéä¿¡ãããŸãã é ä¿¡ãããªãå Žåãã¯ã©ã€ã¢ã³ããã厩å£ãããŠããããšãæå³ããŸãã ãŸããåæãªããžã§ã¯ãã解æŸããªãã£ãã厩å£ãããã¯ã©ã€ã¢ã³ãã«ãããããããã¯ã®å¯èœæ§ãåé¿ããããã«ãã©ã€ãããã±ãŒãžã®ã¡ã¢ãªã¯ãµãŒããŒèªèº«ã®äºçŽããå²ãåœãŠãããŸãã
ã¡ã¢ãªãããŒãžã£ãŒã®å®è£
çµå±ã®ãšãããIPCã®ãããªå®è£ ã§æãé£ããã¿ã¹ã¯ã¯ãã¡ã¢ãªãããŒãžã£ã®å®è£ ã§ãã çµå±ã®ãšããã圌ã¯ããç¥ãããã¢ã«ãŽãªãºã ã®1ã€ã«åŸã£ãŠmallocã¡ãœãããšfreeã¡ãœãããå®è£ ããã ãã§ãªããã¯ã©ã€ã¢ã³ããã¯ã©ãã·ã¥ãããšãã®ãªãŒã¯ãé²ããã¡ã¢ãªããäºçŽãããæ©äŒãæäŸããç¹å®ã®ãªãã»ããã§ã¡ã¢ãªãããã¯ãå²ãåœãŠãæçåãé²ããã¹ã¬ããã»ãŒãã§ãããå¿ èŠãªãµã€ãºã®ç©ºããããã¯ããªãå Žåã¯ã衚瀺ãããããšãæåŸ ããŠãã ããã
åºæ¬çãªã¢ã«ãŽãªãºã
ã¡ã¢ãªãããŒãžã£ã®å®è£ ã¯ã空ããªã¹ãã¢ã«ãŽãªãºã ã«åºã¥ããŠããŸããã ãã®ã¢ã«ãŽãªãºã ã«ããã°ãå²ãåœãŠãããŠããªãã¡ã¢ãªãããã¯ã¯ãã¹ãŠãäžæ¹åã®ãªã³ã¯ãªã¹ãã«çµåãããŸãã ãããã£ãŠãã¡ã¢ãªãããã¯ïŒmallocïŒãå²ãåœãŠããšããå¿ èŠãªãµã€ãºä»¥äžã®ãµã€ãºã®æåã®ç©ºããããã¯ãæ€çŽ¢ãããªã³ã¯ãªã¹ãããåé€ããŸãã èŠæ±ããããããã¯ã®ãµã€ãºã空ããããã¯ã®ãµã€ãºããå°ããå Žåã空ããããã¯ã¯2ã€ã«åå²ãããæåã®ãããã¯ã¯èŠæ±ããããµã€ãºãšçããã2çªç®ã®ãããã¯ã¯ãäœåãã§ãã æåã®ãããã¯ã¯å²ãåœãŠãããã¡ã¢ãªãããã¯ã§ã2çªç®ã®ãããã¯ã¯ç©ºããããã¯ã®ãªã¹ãã«è¿œå ãããŸãã ã¡ã¢ãªãŒã®ãããã¯ã解æŸããïŒç¡æïŒãšã解æŸããããããã¯ã空ããããã¯ã®ãªã¹ãã«è¿œå ãããŸãã 次ã«ãé£æ¥ãã空ãã¡ã¢ãªãããã¯ã1ã€ã«çµåãããŸãã ãããã¯ãŒã¯ã«ã¯ãFree Listã¢ã«ãŽãªãºã ã䜿çšããå€æ°ã®ã¡ã¢ãªãããŒãžã£å®è£ ããããŸãã FreeRTOSã®heap_5ã¢ã«ãŽãªãºã ã䜿çšããŸãã ã
ã¢ã«ãŽãªãºã æ©èœ
ã¡ã¢ãªãããŒãžã£ãéçºãããšãã芳ç¹ããèŠããšãå ±æã¡ã¢ãªãæäœããéã®ç¹åŸŽã¯ãOSã®ããã«ãããäžè¶³ããŠããããšã§ãã ãããã£ãŠã空ãã¡ã¢ãªãããã¯ã®ãªã¹ãã«å ããŠããããŒãžã£ã¯ã¡ã¢ãªãããã¯ã®ææè ã«é¢ããæ å ±ãä¿åããå¿ èŠããããŸãã ããã¯ããã€ãã®æ¹æ³ã§å®è¡ã§ããŸããåå²ãåœãŠãããã¡ã¢ãªãããã¯ã«ããã»ã¹ã®PIDãä¿åãããå²ãåœãŠãããã¡ã¢ãªãããã¯ã®ãªãã»ãã-PIDãããŒãã«ãäœæããåPIDã«å²ãåœãŠãããã¡ã¢ãªãããã¯ã®é åãåå¥ã«äœæããŸãã éåžžãããã»ã¹ã®æ°ã¯å°ãªãããïŒ10以äžïŒããã€ããªããã®æ±ºå®ãè¡ãããå²ãåœãŠãããåã¡ã¢ãªãããã¯ã«ã¯ãå²ãåœãŠãããã¡ã¢ãªãããã¯ã®ãªãã»ããé åã®ã€ã³ããã¯ã¹ïŒ2ãã€ãïŒãæ ŒçŽãããåPIDã¯ãããã»ã¹ãããã¯ãã®æåŸã«ããç¬èªã®é åãæã¡ãŸãïŒãã®ãããã¯ã¯ãããã»ã¹ã«é¢ããæ å ±ãä¿åããŸãïŒãåçã§ãã
é åã¯å·§åŠã«ç·šæãããã¡ã¢ãªãããã¯ãããã»ã¹ã«ãã£ãŠå²ãåœãŠãããå²ãåœãŠãããã¡ã¢ãªãããã¯ã®ãªãã»ãããã»ã«ã«æ ŒçŽãããŸããã¡ã¢ãªãããã¯ãå²ãåœãŠãããŠããªãå Žåãã»ã«ã«ã¯æ¬¡ã®ãæªå²ãåœãŠãã»ã«ã®ã€ã³ããã¯ã¹ãå«ãŸããŸãç¡æãªã¹ãïŒã ãã®ãããªé åã®ã¢ã«ãŽãªãºã ã«ãããäžå®ã®æéã¢ãã¬ã¹ãåé€ããã³è¿œå ã§ããŸãã ããã«ãæ°ãããããã¯ãéžæãããšãã«ãçŸåšã®PIDã«å¯Ÿå¿ããããŒãã«ãæ€çŽ¢ããå¿ èŠã¯ãããŸããããã®ãªãã»ããã¯åžžã«äºåã«ããã£ãŠããŸãã ãŸããå²ãåœãŠãããã¡ã¢ãªãããã¯ã«ãããã»ã¹ãããã¯ãã®ãªãã»ãããä¿åãããšããããã¯ã解æŸãããšãã«ãããŒãã«ãæ¢ãå¿ èŠããªããªããŸãã ããã»ã¹ã®æ°ãå°ãªããšããä»®å®ã«ããããããã»ã¹ãããã¯ãã¯äžæ¹åã®ãªã³ã¯ãªã¹ãã«çµåãããŸãã ãããã£ãŠãæ°ããã¡ã¢ãªãããã¯ãå²ãåœãŠããšãïŒmallocïŒãææè æ å ±ãè¿œå ããé£ããã¯OïŒ1ïŒã§ãããïŒç©ºãïŒã¡ã¢ãªãããã¯ã解æŸãããšãã¯OïŒnïŒã§ããnã¯å ±æã¡ã¢ãªã䜿çšããããã»ã¹ã®æ°ã§ãã ããªãŒãŸãã¯ããã·ã¥ããŒãã«ã䜿çšããŠããããã»ã¹ãããã¯ãã®ãªãã»ããããã°ããèŠã€ããããšãã§ããªãã®ã¯ãªãã§ããïŒ éžæããããããã¯ã®é åã¯åçã§ããããããããã»ã¹ãããã¯ãã®ãªãã»ãããå€æŽãããå ŽåããããŸãã
åè¿°ã®ããã«ããã¯ã©ã€ã¢ã³ã/ãµãŒããŒãã®åäœã«ã¯ãã¡ã¢ãªãããã¯ããäºçŽãããæ©èœãè¿œå ããå¿ èŠããããŸãã ããã¯éåžžã«ç°¡åã«å®è£ ãããããã¯ã¢ããã¡ã¢ãªââãããã¯ãããã»ã¹ã«ãå²ãåœãŠããããŸãã ãããã£ãŠããªã¶ãŒãããã¡ã¢ãªãããã¯ãå²ãåœãŠãå¿ èŠãããå Žåãåé·ããã»ã¹ãããã¯ã¯è§£æŸãããæäœã¯éåžžã®å²ãåœãŠãšåæ§ã«ãªããŸãã ããã«ãç¹å®ã®ã¢ãã¬ã¹ã«ã¡ã¢ãªãããã¯ãå²ãåœãŠãããšãç°¡åã§ãã å²ãåœãŠããããããã¯ã«é¢ããæ å ±ã¯ããããã»ã¹ãããã¯ãã«ä¿åãããŸãã
ãã®ãããªå€§éã®æ°žç¶çã«ä¿åããããµãŒãã¹æ å ±ã§ã¯ããããã¯ã®ç°ãªãã寿åœãã«ããã¡ã¢ãªã®æçåãçºçããå¯èœæ§ããããããã¡ã¢ãªãããŒãžã£ãŒã§ã¯ãã¹ãŠã®ãµãŒãã¹æ å ±ïŒé·å¯¿åœïŒããã£ãŒã«ãã®çµããããå²ãåœãŠãããããŠãŒã¶ãŒããããã¯ã®å²ãåœãŠïŒç寿åœïŒæåã¯ã ãããã£ãŠããµãŒãã¹æ å ±ã¯ã空ããããã¯ããªãå Žåã«ã®ã¿ã¡ã¢ãªãæçåããŸãã
ã¡ã¢ãªæ§é ã次ã®å³ã«ç€ºããŸãã
ã¡ã¢ãªæ§é
ãããŠãå ±æã¡ã¢ãªã䜿çšããããã»ã¹ã®1ã€ãã¯ã©ãã·ã¥ãããšã©ããªããŸããïŒ
æ®å¿µãªãããOSãããããã»ã¹ãçµäºããŸããããšããã€ãã³ããåãåãæ¹æ³ãèŠã€ãããŸããã§ããã ãã ããããã»ã¹ãååšãããã©ããã確èªããæ©äŒããããŸãã ãããã£ãŠãã¡ã¢ãªãããŒãžã£ã§ãšã©ãŒãçºçããå Žåãããšãã°ã¡ã¢ãªãäžè¶³ããå Žåãã¡ã¢ãªãããŒãžã£ã¯ããã»ã¹ã®ã¹ããŒã¿ã¹ããã§ãã¯ããŸãã ããã»ã¹ãååšããªãå Žåããããã»ã¹ãããã¯ãã«æ ŒçŽãããŠããããŒã¿ã«åºã¥ããŠããªãŒã¯ããã¡ã¢ãªã埪ç°ã«æ»ããŸãã æ®å¿µãªããããããã»ã¹å®äºãã€ãã³ãããªããããããã»ã¹éãã¥ãŒããã¯ã¹ã®æææš©ã®ç¬éã«ããã»ã¹ãã¯ã©ãã·ã¥ããå Žåã«ãã¡ã¢ãªãããŒãžã£ãŒããããã¯ããããã¯ãªãŒãã³ã°ããéå§ã§ããªããªãããšããããŸãã ãããåé¿ããããã«ãmutexã®ææè ã®PIDã«é¢ããæ å ±ãããããŒã«è¿œå ãããŸããã ãããã£ãŠãå¿ èŠã«å¿ããŠããŠãŒã¶ãŒã¯2ç§ããšãªã©ã«ãã§ãã¯ã匷å¶ã§ããŸãã ïŒãŠã©ããããã°æ¹åŒïŒ
ãcopy-on-writeãã®äœ¿çšã«ãããè€æ°ã®ããã»ã¹ãåæã«ãããã¡ãææããŠããå Žåã«ç¶æ³ãçºçããå¹³åã®æ³åã«åŸã£ãŠããã®ãã¡ã®1ã€ãã¯ã©ãã·ã¥ããŸãã ãã®å Žåã2ã€ã®åé¡ãçºçããå¯èœæ§ããããŸãã ãŸããã¯ã©ãã·ã¥ããããã»ã¹ããããã¡ã®ææè ã ã£ãå Žåãããã¯åé€ãããä»ã®ããã»ã¹ã®SIGNSEVã«ã€ãªãããŸãã 2ã€ç®ã¯ã倱æããããã»ã¹ããããã¡å ã®ã«ãŠã³ã¿ãæžãããªãã£ããšããäºå®ã®ãããåé€ãããŸããã æŒããçºçããŸãã ç§ã¯ãã®åé¡ã®åçŽã§çç£çãªè§£æ±ºçãèŠã€ããããŸããã§ãããã幞ããªããšã«ããã®ç¶æ³ã¯ãŸãã§ãã®ã§ãèœã¡ãããã»ã¹ã«å ããŠå¥ã®ææè ãããŠãããã§å°çã«è¡ããšãã¡ã¢ãªãªãŒã¯ãçºçãããããã¡ãã¯ãªãŒã³ã¢ãããéå§ããããã»ã¹ã«ç§»åããå Žåãç§ã¯åŒ·ãææã決å®ããŸããã
éåžžãã¡ã¢ãªãããŒãžã£ã¯ã空ãã¡ã¢ãªãããã¯ããªãå ŽåãNULLãè¿ãããäŸå€ãã¹ããŒããŸãã ããããçµå±ã®ãšãããã¡ã¢ãªãããã¯ã®å²ãåœãŠã§ã¯ãªãããã®è»¢éãã€ãŸã 空ããããã¯ããªãããšã¯ãšã©ãŒã§ã¯ãããŸããããå¥ã®ããã»ã¹ããããã¯ã解æŸãããŸã§åŸ ã€å¿ èŠããããŸãã ã«ãŒãã§åŸ æ©ããããšã¯éåžžæªèãããŸãã ãã®ããããããŒãžã£ãŒã«ã¯2ã€ã®å²ãåœãŠã¢ãŒãããããŸããã¯ã©ã·ãã¯ïŒç©ºããããã¯ããªãå Žåã¯NULLãè¿ãïŒãããã³ç©ºããããã¯ããªãå Žåã¯åŸ æ©ããããã»ã¹ã¯ãããã¯ãããŸãã
æ®ãã®ã³ã³ããŒãã³ãã®å®è£
æ®ãã®ã³ã³ããŒãã³ãã®å®è£ ã®åºç€ã¯ããŒã¹ãã§ããããã以äžã§ã¯ãããã®æ©èœã®ã¿ã«çŠç¹ãåœãŠãŸãã å ±æã¡ã¢ãªã§ã®äœæ¥ãã«ãã»ã«åããã³ã³ããŒãã³ãã®æ©èœïŒä»¥éCSharedMemoryïŒã¯ãå ±æã¡ã¢ãªã§ã®äœæ¥æ¹æ³ãåæããããã®ããã»ã¹éãã¥ãŒããã¯ã¹ãæã€ããããŒã®ååšã§ãã å®è·µã瀺ããŠããããã«ããããªãã§ã¯ã§ããŸããã éåžžãããŒã¿ãããã¡ãŒã®ãµã€ãºã¯å€æŽãããªãããæåããã®ã¿å€æŽãããŸãïŒããšãã°ããããã¯ãŒã¯çµç±ã§éä¿¡ããããã«ããŒã¿ãããã¡ãŒã«ããããŒãæ¿å ¥ããŸãïŒãCBufferã®ã¡ã¢ãªäºçŽã¢ã«ãŽãªãºã ã¯ãstd :: vectorã®ä¿æ°ã¡ã¢ãªäºçŽã¢ã«ãŽãªãºã ãšã¯ç°ãªããŸãã æåã«ãCBufferå®è£ ã§ã¯ãæåã«äºçŽãèšå®ããæ©èœãè¿œå ãããŸãããããã©ã«ãã§ã¯0ã§ãã2çªç®ã«ãã¡ã¢ãªäºçŽã¢ã«ãŽãªãºã ã¯æ¬¡ã®ãšããã§ããå²ãåœãŠããããããã¯ã®ãµã€ãºã128ãã€ãæªæºã®å Žåã256ãã€ããäºçŽãããããŒã¿ãããã¡ãŒãµã€ãºã65536æªæºã®å ŽåãäºçŽãããŸããããã¡ãµã€ãºã«256ãã€ããå ãããã®ãããã§ãªãå Žåã¯ãããã¡ãµã€ãºã«512ãã€ããå ãããã®ãäºçŽãããŠããŸãã
Linuxã§ã®sem_initã®äœ¿çšã«é¢ããããã€ãã®èšè
ã¡ã€ã³ãœãŒã¹ã¯ãããã»ã¹éã§sem_initã䜿çšããããã®ããã°ã©ã ã³ãŒãã®èª€ã£ãããŒãžã§ã³ãæäŸããŸãã Linuxã§ã¯ã次ã®ããã«ãsem_tæ§é äœã®ã¡ã¢ãªã調æŽããå¿ èŠããããŸãã
(_sem_t*)(((uintptr_t)mem+__alignof(sem_t))&~(__alignof(sem_t)-1)
ãããã£ãŠãsem_postïŒsem_waitïŒãEINVALãè¿ãå Žåã¯ãsem_tæ§é äœã®ã¡ã¢ãªã調æŽããŠã¿ãŠãã ããã sem_initã®äœ¿çšäŸ ã
åèš
ãã®çµæãã¯ã©ã€ã¢ã³ããµãŒããŒãçæããããã®éä¿¡é床ã¯ããŒã¿éã«äŸåãããéä¿¡ããããããã¡ãŒã®ãµã€ãºã«ã®ã¿äŸåããŸãã ãã®äŸ¡æ Œã«ã¯ããã€ãã®å¶éããããŸãã Linuxã§ã¯ããããã®äžã§æãéèŠãªã®ã¯ãããã»ã¹ããå®äºãããåŸã®ãã¡ã¢ãªãªãŒã¯ãã§ãã æåã§åé€ããããOSãåèµ·åã§ããŸãã Windowsã§äœ¿çšããå Žåãåé¡ã¯ç°ãªããŸãããµãŒããŒã¯ã©ã¹ã¡ãœãããåŒã³åºããŠåé€ãããŠããªãå ŽåãããŒããã£ã¹ã¯äžã®å ±æã¡ã¢ãªã¯ããã«ããªãŒã¯ãããŸãã ãã®åé¡ã¯ãboost_interprocessãã©ã«ããŒå ã®ãã¡ã€ã«ãæåã§åé€ããããšã«ãã£ãŠã®ã¿ãOSãåèµ·åããŠãä¿®æ£ãããŸããã å€ãã³ã³ãã€ã©ã䜿çšããå¿ èŠãããå Žåãããããããªããžããªã«ã¯BoostããŒãžã§ã³1.47ãå«ãŸããŠããŸãããææ°ããŒãžã§ã³ã§ã¯ã©ã€ãã©ãªã®åäœãéããªããŸãã
ãã¹ãçµæã¯äžã®ã°ã©ãã«ç€ºãããŠããŸãïŒLinuxãšQNXã¯VMBoxä»®æ³ãã·ã³ã§ãã¹ããããŸããïŒ
ãœãŒã¹ã¯ã©ãã§å ¥æã§ããŸããïŒ
å®å®çã®ãœãŒã¹ã³ãŒãã¯ãã¡ãã§ãã ãã¹ãããã°ããéå§ããããã®ãã€ã㪠ïŒ+ VCåé åžå¯èœïŒããããŸãã ãœãŒã¹ã®QNXã®ãã¡ã³ã«ã¯ãCMakeã®ããŒã«ãã§ãŒã³ããããŸãã CMakeããœãŒã¹ãåéããªãå Žåãç°å¢å€æ°ãæ¶å»ããã¿ãŒã²ããã³ã³ãã€ã©ã®ãã£ã¬ã¯ããªã®ã¿ãæ®ãããšãæãåºããŠãã ããã
æåŸã«ãå ±æã¡ã¢ãªã䜿çšããLookFree IPCã®å®è£ ãžã®ãªã³ã¯ ã