contributed by <twzjwang
>
作業說明: B08: mergesort-concurrent
github: twzjwang/mergesort-concurrent
Ubuntu Ubuntu 16.04.2 LTS
Linux 4.8.0-36-generic
cpu
version: Intel® Core™ i5-3337U CPU @ 1.80GHz
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 4
L1d cache: 32K
L1i cache: 32K
L2 cache: 256K
L3 cache: 3072K
memory
size: 4GiB
依照作業說明執行
argv[2]
為 build_list_from_file
的檔名,而不是先的 input_count
執行 $ uniq test_data/words.txt | sort -R > test_data/word_sorted.txt
取得亂數排列的檔案
根據 Manual
sort - sort lines of text files
--sort=WORD sort according to WORD: random -R
執行 $ ./sort 4 test_data/word_sorted.txt
字串經 atol 轉換回傳 long int
定義 datatype 為大小 16 的char array
typedef char val_t[16];
使用 strcmp 比大小llist_t *small = (strcmp(a->head->data, b->head->data) <= 0) ? a : b;
自動測試
make check_words
mutrace
addr2line
找到對應的位置,推測
特別留意 lock contention 對效能的影響,目前整合的 thread pool 實作不是很有效率 (之後我們應該要重寫一套更好的) –jserv
lock free
針對 lock contention 次數較多的 Mutex #1 : the_queue->mutex
crtitical section
twzjwang