Try   HackMD

2017q1 Homework4的觀念 (mergesort-concurrent)

開發環境

boring@boring-K55VM:~/paul5566/mergesort-concurrent$ x86info -c
The program 'x86info' is currently not installed. You can install it by typing:
sudo apt install x86info

direct mapped cache

http://sit.iitkgp.ernet.in/~coavl/images/dmc5.png

direct mapped cache
CPU接受到一個instruction(處理一個指令就是要拿資料)
ex ADD,SUBTRACT的指令要讀取資料來運算就會需要拿資料
因此需要一種方式去定位(cahche有很多個"block",要去拿資料)
mutrace 可用來偵測 lock contention,使用很方便,不需要重新編譯程式碼。

圖裡面的圈(=)tag 和 adreess的tag是不是一樣的判斷
1(相同)或是0(相異)
然後再把"V"Valid bit做AND運算因為這樣可以確認有沒有cache hit

ex: 發生cache miss的那個line(block的值)的valid則是0

這樣AND運算完會得到是否有 cache hit(這個資料是否是你要的)

$ sudo apt-get install mutrace
[sudo] password for boring: 

thread
multi_thread

C 的 Thread Pool 筆記

先看list.h因為排序的資料所以看node

Makefile 裡的sort是linuix

 39 check: sort
 40 # Generate testing data
 41     @bash scripts/gen-random-numbers.sh $(NUM_OF_DATA) $(TEST_DATA_FILE)
 42 # Sort the testing data first to generate ground truth
 43     @sort -g $(TEST_DATA_FILE) > $(SORTED_DATA_FILE)
 44 # Time for user program to sort the testing data, and ignore first the 3 lines of output.
 45 # Because we only want the sorting result.
 46     @./sort $(THREADS) $(TEST_DATA_FILE) | tail -n +4 > $(SORTED_RESULT)                                                          
 47     @bash scripts/compare.sh $(SORTED_DATA_FILE) $(SORTED_RESULT)

  1. Mutex Lock and Lock Contention

pthread_craete(讓執行序去平行處理某件事的時候)
tid(thread的id)