2019q1 Homework1 (lab0)
contributed by <Zames-Chang
>
認真看作業要求,除了提及如何逐步達到要求,還需要進行:
- 改善程式效能
- 解釋自動評分系統運作的原理
- 提及 qtest 的行為和裡頭的技巧
還未達成符合預期目標,請繼續付出!
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
jserv
事前閱讀
基本上我們要完成這幾個function:
- q new: 建立一個全新的 queue
- q free: 把所有這個 queue所使用到的空間都 free掉
- q insert head: 把元素放到 queue的最前面
- q insert tail: 把元素放到 queue的最後面
- q remove head: 刪除 queue的第一個元素
- q size: queue有多長
- q reverse: 把當前的 queue給反轉,但是不可以創建新的 queue去取代原本的 queue,要用當前的 queue去做
q_insert_tail and q_size 這兩個function必須要是 不可以是
實做
queue_t
q_new
q_insert_head
q_remove_head
q_insert_tail
q_size
q_free
改寫為下方程式碼: (減少縮排的深度和 scope)
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
jserv
2/26號更新
我之前為了測試環境提交了 commit,被罵惹,然後我用 git rebase試著想去刪掉那個 commit,可是不知道怎弄整個版本都壞掉了,我就整個砍掉重來 ORZ
幻滅是成長的開始,找出因應方法,繼續!
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
jserv
q_reverse
qtest 的行為
自動化評分時,會下 make test
所以看起來他是把 driver.py 餵給了 qtest,那我們先來看看 driver做了什麼
從這段可以猜出他把 trace-01-15代到 qtest裡面跑,再去看
trace-01-ops.cmd
所以大概就知道每一個 trace檔裡面放的都是 qtest的指令, driver的工作就是把每一個 trace檔都給 qtest跑過。
那來看看 他怎麼 check你有沒有 memory leak,發現他自己 maintain了一個變數叫allocated_count
然後在哪裡這個變數會增加或減少呢?
這段程式碼取代了原本的malloc 跟free,也就是說每次我們做malloc跟free其實都是call下面兩個程式碼,在這兩段程式碼會有allocated_count++;
and allocated_count--;
,所以他檢查方式就是你allocate幾次空間,就應該要free掉幾次,如果你的最後次數相減不為零代表說你memory leak
如何檢測 segmantation fault 跟時間超過呢