<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
    <channel>
        <title>Linux_嵌入式開發 - Category - Wandering World</title>
        <link>http://chinyu1229.github.io/categories/linux_%E5%B5%8C%E5%85%A5%E5%BC%8F%E9%96%8B%E7%99%BC/</link>
        <description>Linux_嵌入式開發 - Category - Wandering World</description>
        <generator>Hugo -- gohugo.io</generator><language>en</language><managingEditor>chinyu0916@gmail.com (Chinyu)</managingEditor>
            <webMaster>chinyu0916@gmail.com (Chinyu)</webMaster><copyright>This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.</copyright><lastBuildDate>Thu, 20 May 2021 01:12:12 &#43;0800</lastBuildDate><atom:link href="http://chinyu1229.github.io/categories/linux_%E5%B5%8C%E5%85%A5%E5%BC%8F%E9%96%8B%E7%99%BC/" rel="self" type="application/rss+xml" /><item>
    <title>Linux 嵌入式開發 – 並行開發—SystemV IPC</title>
    <link>http://chinyu1229.github.io/2021-05-20-linux-%E5%B5%8C%E5%85%A5%E5%BC%8F%E9%96%8B%E7%99%BC-%E4%B8%A6%E8%A1%8C%E9%96%8B%E7%99%BC-system-v-ipc/</link>
    <pubDate>Thu, 20 May 2021 01:12:12 &#43;0800</pubDate>
    <author>Author</author>
    <guid>http://chinyu1229.github.io/2021-05-20-linux-%E5%B5%8C%E5%85%A5%E5%BC%8F%E9%96%8B%E7%99%BC-%E4%B8%A6%E8%A1%8C%E9%96%8B%E7%99%BC-system-v-ipc/</guid>
    <description><![CDATA[Linux 嵌入式開發 &ndash; 並行開發&mdash; System V IPC System V IPC  包含共享內存、消息對列、和信號燈集 每個IPC對象有唯一的ID IPC對象創建後一直存在，直到被顯式的刪除（主動刪除） 每個IPC對象有一個關聯的KEY ipcs / ipcrm 實現進程間通訊  Key ftok 1 2 3  #include&lt;sys/types.h&gt;#include&lt;sys/ipc.h&gt;key_t ftok(const char *path,int proj_id);    成功時返回合法的key值，失敗時返回EOF path存在且可以被訪問文件的路徑 proj_id 用於生成key的數字，不能為0  範例 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15  #include&lt;stdio.h&gt;#include&lt;stdlib.h&gt;#include&lt;sys/types.h&gt;#include&lt;sys/ipc.h&gt;#include&lt;unistd.h&gt; int main(int argc, char *argv[]) { key_t key; if((key = ftok(&#34;.&#34;,&#39;a&#39;)) == -1) { perror(&#34;key&#34;); exit(-1); } }   共享內存  是一種最高效的進程間通信方式，進程可以直接讀寫內存，而不需要任何數據的拷貝 在內核空間創建，可以被進程映射到用戶空間訪問，使用靈活 由於多個進程可以同時訪問共享內存，因此需要同步和互斥機制配合使用  使用步驟  創建/打開共享內存 映射共享內存，即把指定的共享內存映射到進程的地址空間用於訪問 讀寫共享內存 撤銷共享內存映射 刪除共享內存對象  創建 1 2 3  #include&lt;sys/ipc.]]></description>
</item><item>
    <title>Linux 嵌入式開發 – 並行開發—Unix進程間的通訊方式</title>
    <link>http://chinyu1229.github.io/2021-05-20-linux-%E5%B5%8C%E5%85%A5%E5%BC%8F%E9%96%8B%E7%99%BC-%E4%B8%A6%E8%A1%8C%E9%96%8B%E7%99%BC-unix%E9%80%B2%E7%A8%8B%E9%96%93%E7%9A%84%E9%80%9A%E8%A8%8A%E6%96%B9%E5%BC%8F/</link>
    <pubDate>Thu, 20 May 2021 01:11:12 &#43;0800</pubDate>
    <author>Author</author>
    <guid>http://chinyu1229.github.io/2021-05-20-linux-%E5%B5%8C%E5%85%A5%E5%BC%8F%E9%96%8B%E7%99%BC-%E4%B8%A6%E8%A1%8C%E9%96%8B%E7%99%BC-unix%E9%80%B2%E7%A8%8B%E9%96%93%E7%9A%84%E9%80%9A%E8%A8%8A%E6%96%B9%E5%BC%8F/</guid>
    <description><![CDATA[Linux 嵌入式開發 &ndash; 並行開發&mdash; Unix進程間的通訊方式 Process間通訊介紹 早期：
 pipe fifo signal  System V IPC
 share memory message queue semphore set  &mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;本地通信↑
&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;本地/網路通信↓ Linux
 socket  無名管道  只能用於有親緣關係的進程之間的通信 單工的通信模式，具有固定的讀端和寫端 創建時返回兩個文件描述符，分別用於讀寫管道  創建 - pipe 1 2  #include&lt;unistd.h&gt;int pipe(int pfd[2]);    成功時返回0，失敗時返回EOF pfd 包含兩個元素的int 陣列，用來保存文件描述符 pfd[0]用於read管道，pfd[1]用於write管道  範例 子進程1和2分別往管道寫入字串，父進程讀管道內容並打印
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52  #include&lt;stdio.]]></description>
</item><item>
    <title>Linux 嵌入式開發 – 並行開發—進程與線程</title>
    <link>http://chinyu1229.github.io/2021-05-20-linux-%E5%B5%8C%E5%85%A5%E5%BC%8F%E9%96%8B%E7%99%BC-%E4%B8%A6%E8%A1%8C%E9%96%8B%E7%99%BC%E9%80%B2%E7%A8%8B%E8%88%87%E7%B7%9A%E7%A8%8B/</link>
    <pubDate>Thu, 20 May 2021 01:10:12 &#43;0800</pubDate>
    <author>Author</author>
    <guid>http://chinyu1229.github.io/2021-05-20-linux-%E5%B5%8C%E5%85%A5%E5%BC%8F%E9%96%8B%E7%99%BC-%E4%B8%A6%E8%A1%8C%E9%96%8B%E7%99%BC%E9%80%B2%E7%A8%8B%E8%88%87%E7%B7%9A%E7%A8%8B/</guid>
    <description><![CDATA[Linux 嵌入式開發 &ndash; 並行開發&mdash;進程與線程 Process概念  program  存放在disk上的指令和數據的有序集合（文件） 靜態的   process  執行一個program所分配的資源總稱 是program一次執行的總稱 動態的，包括創建，調度，執行，死亡 有獨立的地址空間 linux為每個進程創建task_struct    Process 內容 1 2 3  process ----------| 正文段 |-------- --------- | 用戶數據段 |----program --------- | 系統數據段 |   Process control block  PID process user process status / priority file description table  Process 類型  交互進程：在shell下啟動，可在前臺/後台運行 批處理進程：和在終端無關，被提交到一個作業隊列中以便順序執行 守護進程：和終端無關，一直在後台運行  Process status  running / ready waiting  interrupt not interrupt   terminated : 收到signal後可以繼續運行 zombie ： pcb沒有被釋放  殭屍與孤兒   殭屍：一個process 使用fork()建立child,如果child退出（terminated)，而父進程沒有呼叫wait/waitpid並回收時，OS進程表中仍然存在子進程的進程控制塊(PCB)，長時間保持殭屍狀態會導致resource leak]]></description>
</item></channel>
</rss>
