contributed by <ivan125126
>
GitHub 操作
lab0-c
git log
確認出現 commit c621c4b
程式修改與測試
queue.[ch]
及相關檔案$ make test
自動評分系統通過程式設計與優化
lib/list_sort.c
lib/list_sort.c
的解說錄影qtest 命令與隨機性分析
shuffle
命令:使用 Fisher–Yates shuffle 對佇列所有節點進行洗牌,並以統計方法分析其「亂度」option entropy 1
並搭配 ih RAND 10
等命令
時間複雜度與實驗驗證
程式缺陷與改進
開發紀錄與工具使用
select
系統呼叫在本程式中的使用,並分析 console.c
實作
$ gcc --version
gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0
$ lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Address sizes: 39 bits physical, 48 bits virtual
Byte Order: Little Endian
CPU(s): 16
On-line CPU(s) list: 0-15
Vendor ID: GenuineIntel
Model name: 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz
CPU family: 6
Model: 141
Thread(s) per core: 2
Core(s) per socket: 8
Socket(s): 1
Stepping: 1
CPU(s) scaling MHz: 57%
CPU max MHz: 4600.0000
CPU min MHz: 800.0000
BogoMIPS: 4608.00
Virtualization features:
Virtualization: VT-x
Caches (sum of all):
L1d: 384 KiB (8 instances)
L1i: 256 KiB (8 instances)
L2: 10 MiB (8 instances)
L3: 24 MiB (1 instance)
當我在按照作業要求的指引一步步到要push上去的時候,出現了
$ git push
Username for 'https://github.com': ivan125126
Password for 'https://ivan125126@github.com':
remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/ivan125126/lab0-c/'
按照它提供的網址查詢後我才知道,如果當初在clone repository
的時候用的是
$ git clone https://github.com/你的帳號名稱/lab0-c
git
會幫你把這個URL
存下來並稱為origin
,按照github官網的說法
Password-based authentication for Git has been removed in favor of more secure authentication methods.
這是針對http URL
方法的,所以只要改成用SSH URL
就沒有問題了。繼續依循著官網找到了解決方案,使用:
$ git remote set-url origin git@github.com:ivan125126/lab0-c
再重新push
一次就沒有遇到問題了。
目前透過自動評分系統得到的分數是 59/100。
根據作業要求的內容
台大電機系李宏毅教授對於 ChatGPT 的看法是,要善用人工智慧的成果,一旦人們得以善用,人類的書寫不該比 GPT 一類的大語言模型差。
所以我就來更加的「善用」人工智慧了,這是ChatGPT的第一次commit還有聊天紀錄,自動評分拿到59分,下面我會一個個檢查GPT
寫的函數是否還有改善空間。
q_new()
commit:b2eec1c
以下是GPT
所寫:
struct list_head *q_new()
{
struct list_head *head = malloc(sizeof(struct list_head));
if (!head)
return NULL;
INIT_LIST_HEAD(head);
return head;
}
能改善的地方就是malloc()
在配置失敗時,就會回傳NULL
了,不需要額外寫一個return NULL
,於是我修改成如下:
struct list_head *q_new()
{
struct list_head *head = malloc(sizeof(struct list_head));
if (head)
INIT_LIST_HEAD(head);
return head;
}
q_free()
commit:69a3b35
我沒有給GPT
list.h
的檔案,導致它沒有使用巨集提昇可讀性。然而,我已經附上queue.h
,它卻沒有使用q_release_element(element_t *e)
:
struct list_head *cur = head->next, *next;
while (cur != head) {
next = cur->next;
element_t *elem = container_of(cur, element_t, list);
free(elem->value);
free(elem);
cur = next;
}
以下是我使用預定義好的巨集以及函數後改寫:
element_t *elem, *tmp;
list_for_each_entry_safe (elem, tmp, head, list)
q_release_element(elem);
free(head);
q_insert_head
明明就是直接呼叫q_insert_tail
,卻只有q_insert_head
一直報ERROR: Probably not constant time or wrong implementation
到現在還是找不出原因。