{"id":94981,"date":"2015-12-18T17:29:49","date_gmt":"2015-12-18T13:29:49","guid":{"rendered":"http:\/\/blagovest.org.ru\/?p=94981"},"modified":"2015-12-18T17:29:49","modified_gmt":"2015-12-18T13:29:49","slug":"pochemu-roditelskij-i-dochernij-process-vrode","status":"publish","type":"post","link":"https:\/\/blagovest.org.ru\/?p=94981","title":{"rendered":"\u043f\u043e\u0447\u0435\u043c\u0443 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0438 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0432\u0440\u043e\u0434\u0435 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u044e\u0442 \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u043c\u044c\u044e\u0442\u0435\u043a\u0441? \u041e\u0421 windows"},"content":{"rendered":"<p>\u043a\u043e\u0434:<\/p>\n<p>\u0420\u041e\u0414\u0418\u0422\u0415\u041b\u042c:<\/p>\n<p>#include &quot;stdafx.h&quot;<br \/>#include &quot;windows.h&quot;<br \/>#include &quot;stdio.h&quot;<\/p>\n<p>HANDLE M1,M2,M3,M4,M5,MM;<br \/>STARTUPINFO startupinfo1,startupinfo2,startupinfo3,startupinfo4,startupinfo5;<br \/>PROCESS_INFORMATION processinfo1,processinfo2,processinfo3;<\/p>\n<p>int main()<br \/>{<\/p>\n<p>\/\/\u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u0435\u043b\u0430\u0435\u043c \u043c\u044c\u044e\u0442\u0435\u043a\u0441\u044b<br \/>\tM1 = CreateMutex(NULL, TRUE, _T(&quot;Mutex1&quot;));<br \/>\tif(M1!=0) printf(&quot;main: mutex1 has been created, ID = %dn&quot;, M1);<br \/>\telse printf(&quot;\u043e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 mutex1n&quot;); &nbsp;\/\/\u0434\u043e\u043b\u0436\u0435\u043d \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0438\u0434 \u043e\u0431\u044a\u0435\u043a\u0442\u0430<br \/>\tM2 = CreateMutex(NULL, TRUE, _T(&quot;Mutex2&quot;));<br \/>\tif(M2!=0) printf(&quot;main: mutex2 has been created, ID = %dn&quot;, M2);<br \/>\telse printf(&quot;\u043e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 mutex2n&quot;);<br \/>\tM3 = CreateMutex(NULL, TRUE, _T(&quot;Mutex3&quot;));<br \/>\tif(M3!=0) printf(&quot;mutex3 has been createdn&quot;);<br \/>\telse printf(&quot;\u043e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 mutex3n&quot;);<\/p>\n<p>\t\/\/M1 = OpenMutex(MUTEX_ALL_ACCESS, 1, _T(&quot;Mutex1&quot;));<br \/>\tDWORD waitingstat = NULL;<br \/> &nbsp; &nbsp;WaitForSingleObject(M1, INFINITE);<br \/>\tif(waitingstat == WAIT_OBJECT_0) <br \/>\t{<br \/>\t &nbsp;M1 = OpenMutex(SYNCHRONIZE, 1, _T(&quot;Mutex1&quot;));<br \/> &nbsp; &nbsp; &nbsp;if(M1!= 0) printf(&quot;main: opened mutex1, id = %dn&quot;, M1);<br \/> &nbsp; &nbsp; &nbsp;else printf(&quot;main: failed to open mutex1n&quot;, M1);<br \/>\t}<\/p>\n<p>\t\/\/\u043e\u0431\u043d\u0443\u043b\u044f\u0435\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u043f\u0435\u0440\u0435\u0434 \u0432\u044b\u0437\u043e\u0432\u043e\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432<br \/> &nbsp; &nbsp;ZeroMemory( &amp;startupinfo1, sizeof(startupinfo1) );<br \/>\tstartupinfo1.cb = sizeof(startupinfo1);<br \/>\tZeroMemory( &amp;processinfo1, sizeof(processinfo1) );<\/p>\n<p>\tint succ = CreateProcess( _T(&quot;C:\\Users\\bukva-ziu\\Desktop\\myMultitasking\\multitaskingWin\\Debug\\power.exe&quot;), NULL, NULL, NULL, FALSE, 0, NULL, NULL, &amp;startupinfo1, &amp;processinfo1);<br \/>\t\/\/printf(&quot;%d&quot;, succ);<\/p>\n<p>\t\/\/TerminateProcess(processinfo1.hProcess, 10);<br \/>\tWaitForSingleObject(processinfo1.hProcess,INFINITE);<br \/>\tprintf(&quot;child exitedn&quot;);<br \/>\tCloseHandle(processinfo1.hProcess);<br \/> &nbsp; &nbsp;CloseHandle(processinfo1.hThread);<\/p>\n<p>\tgetch();<br \/>return 0;<br \/>}<\/p>\n<p>\u0420\u0415\u0411\u0415\u041d\u041e\u041a:<\/p>\n<p>#include &quot;stdafx.h&quot;<br \/>#include &quot;windows.h&quot;<br \/>#include &quot;stdio.h&quot;<\/p>\n<p>HANDLE M1;<br \/>DWORD waitingstat;<\/p>\n<p>int _tmain(int argc, _TCHAR* argv[])<br \/>{<br \/>printf(&quot;power launched!n&quot;);<\/p>\n<p>WaitForSingleObject(M1, INFINITE);<br \/>if(waitingstat == WAIT_OBJECT_0)<br \/>{<br \/>M1 = OpenMutex(SYNCHRONIZE, 1, _T(&quot;Mutex1&quot;));<br \/>if(M1!= 0) printf(&quot;power: opened mutex1, id = %dn&quot;, M1);<br \/>else printf(&quot;power: failed to open mutex1n&quot;, M1);<br \/>}<br \/>return 0;<br \/>}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u043a\u043e\u0434: \u0420\u041e\u0414\u0418\u0422\u0415\u041b\u042c: #include &quot;stdafx.h&quot;#include &quot;windows.h&quot;#include &quot;stdio.h&quot; HANDLE M1,M2,M3,M4,M5,MM;STARTUPINFO startupinfo1,startupinfo2,startupinfo3,startupinfo4,startupinfo5;PROCESS_INFORMATION processinfo1,processinfo2,processinfo3; int main(){ \/\/\u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u0435\u043b\u0430\u0435\u043c \u043c\u044c\u044e\u0442\u0435\u043a\u0441\u044b M1 = CreateMutex(NULL, TRUE, _T(&quot;Mutex1&quot;)); if(M1!=0) printf(&quot;main: mutex1 has been created, ID = %dn&quot;, M1); else printf(&quot;\u043e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 mutex1n&quot;); &nbsp;\/\/\u0434\u043e\u043b\u0436\u0435\u043d \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0438\u0434 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 M2 = CreateMutex(NULL, TRUE, _T(&quot;Mutex2&quot;)); if(M2!=0) printf(&quot;main: mutex2 has been created, ID = %dn&quot;, M2); [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1435],"tags":[1624,1534],"class_list":["post-94981","post","type-post","status-publish","format-standard","hentry","category-windows","tag-mjuteksy","tag-processy"],"_links":{"self":[{"href":"https:\/\/blagovest.org.ru\/index.php?rest_route=\/wp\/v2\/posts\/94981","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blagovest.org.ru\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blagovest.org.ru\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blagovest.org.ru\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blagovest.org.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=94981"}],"version-history":[{"count":0,"href":"https:\/\/blagovest.org.ru\/index.php?rest_route=\/wp\/v2\/posts\/94981\/revisions"}],"wp:attachment":[{"href":"https:\/\/blagovest.org.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=94981"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blagovest.org.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=94981"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blagovest.org.ru\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=94981"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}