• 請在 lilina.csie.ncnu.edu.tw 的個人目錄下先建立 up3 的子目錄. (注意大小寫). 在此目錄內置入這次作業所需檔案
    若你在自己電腦上寫作業, 請在上傳後測試一遍, 程式可否執行與是否正確 由 lilina 決定.
  • 作業所需檔案為:
    • Makefile (請參關 make 之相關文件)
    • README
    • 其它 .....
  • 作業說明:
    用 fork() 產生一個 process tree, 每個 process 皆印出一行 messages, 其順序 為 post-order. 順序之達成可用 wait() 來達成.
    程式讀進一個參數, 表此 binary tree 之 internel path. 如 "101" 表 internel path 之 length 為 3, 亦即有 4 個 intenel node. root 為第一個, 由其開始, 先向右, 再向左, 再向右 , tree 的形狀如下:
                          I
                         / \\  <--- (1)
                        E   I
                 (0) ---> // \
                          I   E
                         / \\ <-----(1)
                        E   I
                           / \
                          E   E
         
    其中 I 表 internel node, E 表 external node, 其中 internel 要印出
           I'm ..., my two children is ... and  ....
         
    external node 要印出
           I'm ..., my parent is ...
         
    底下為程式之 output 及其對應之 tree.
         $ ./a.out ""
         I'm 1054, my parent is 1053                  |     1053
         I'm 1055, my parent is 1053                  |     /  \
         I'm 1053, my two children is 1054 and 1055   |   1054 1055
         $ ./a.out "1"                                |    
         I'm 1057, my parent is 1056                  |      1056
         I'm 1059, my parent is 1058                  |       / \\
         I'm 1060, my parent is 1058                  |    1057  1058
         I'm 1058, my two children is 1059 and 1060   |           / \
         I'm 1056, my two children is 1057 and 1058   |        1059 1060
         $ ./a.out "10"                               |     
         I'm 1062, my parent is 1061                  |       1061
         I'm 1065, my parent is 1064                  |       /  \\
         I'm 1066, my parent is 1064                  |     1062 1063
         I'm 1064, my two children is 1065 and 1066   |         //  \
         I'm 1067, my parent is 1063                  |      1064  1067
         I'm 1063, my two children is 1064 and 1067   |        / \
         I'm 1061, my two children is 1062 and 1063   |     1065 1066
         $ 
        
  • 關於 Makefile 的要求:
    最少要有二個 target:
    default target: 產生所有的執行檔.
    clean: 清除所有的執行檔, *.o 及空檔等, 將目錄回復到只有 source 的狀態.
  • 關於 README 的要求:
    說明你的執行檔名字, 如何執行, 如何測試等.
  • 有關於 fork() 的 example
  • examples of fork():
    program 1, code , output
    program 2, code , output
    program 3, code , output
  • Due day, 3/31 00:05am