(記憶體映射待寫)
Notes of Sailor
2016年8月6日 星期六
虛擬記憶體,記憶體映射
虛擬記憶體是電腦系統記憶體管理的一種技術。它使得應用程式認為它擁有連續的可用的記憶體(一個連續完整的位址空間),而實際上,它通常是被分隔成多個實體記憶體碎片,還有部分暫時儲存在外部磁碟記憶體上,在需要時進行資料交換。與沒有使用虛擬記憶體技術的系統相比,使用這種技術的系統使得大型程式的編寫變得更容易,對真正的實體記憶體(例如RAM)的使用也更有效率。
2015年12月27日 星期日
function回傳陣列的方式
錯誤的方式:
int[] test() {
int b[3] ={1, 2, 3};
return b;
}
我們可以嘗試使用pointer回傳:
int* t()
{
int *b=new int[3]={1,2,3};
return b;
}
main()
{
int *a;
a=t();
}
note: 但如此一來,有可能會造成memory lost,由函式回傳陣例, 是個糟透了的習慣,memory 的 配置 和 釋放, 應該由使用的人去做, 由函式回傳陣例, 就會破壞了 配置 和 釋放 一對的規則, 所引申的問題有: 難於應用和延伸, memory lost ... ...
較佳的方式:
void t( int* b, int n_b )
{
for( int i=0; i<n_b; i++ )
b[i] = i;
}
int main()
{
int a[10];
t(a,10);
system("pause");
return 0;
}
int[] test() {
int b[3] ={1, 2, 3};
return b;
}
我們可以嘗試使用pointer回傳:
int* t()
{
int *b=new int[3]={1,2,3};
return b;
}
main()
{
int *a;
a=t();
}
note: 但如此一來,有可能會造成memory lost,由函式回傳陣例, 是個糟透了的習慣,memory 的 配置 和 釋放, 應該由使用的人去做, 由函式回傳陣例, 就會破壞了 配置 和 釋放 一對的規則, 所引申的問題有: 難於應用和延伸, memory lost ... ...
較佳的方式:
void t( int* b, int n_b )
{
for( int i=0; i<n_b; i++ )
b[i] = i;
}
int main()
{
int a[10];
t(a,10);
system("pause");
return 0;
}
2015年3月18日 星期三
Kahn process networks (KPN)
- A distributed model of computation (MoC) where a group of deterministic sequential processes are communicating through unbounded FIFO channels
- Determinism
同一組輸入會產生同一組的輸出,
Processes can be modeled as sequential programs that do reads and writes to ports in any order or quantity as long as determinism property is preserved. As a consequence, KPN model is deterministic so that following factors entirely determine outputs of the system:
- processes
- the network
- initial tokens
Hence, timing of the processes does not affect outputs of the system.
2015年3月17日 星期二
有限狀態機 FSM
有限狀態機是由一組狀態、一個起始狀態、 輸入、將輸入與現在狀態轉換為下一個狀態的轉換函數所組成。
比方說:自動販賣機、電梯升降系統、紅綠燈系統...
比方說:自動販賣機、電梯升降系統、紅綠燈系統...
一個特殊的方式:
Global asynchronous Local synchronous
全域是非同步的,但區域是一個獨立同步的FSM。(my comment: 整體看起來像一個大型FSM,只是每個小的程序其實是一個獨立的FSM。)
一個FSM的特性:
單位時間同步化。
輸入階段、處理階段、運算結果是同一個單位時間的回饋。
- 設計理念:
輸入的瞬間,輸出已經完成。
- 前提:
- 計算+內部處理不需要時間(歷時超級快速所以可以省略)。
- event 之間不是同步,就是歷時相差極遠。
2015年3月15日 星期日
數據驅動 vs 控制驅動
Data-driven concurrency(數據驅動併發):
1.The system is modelled as a set of processes without any explicit specification of the ordering of executions. 不會定義排程的執行順序。
2.The execution order of processes (and, implicitly, the potential of parallelism) is fixed solely by data dependencies 排程的執行順序是依照數據的相關性。
Control-driven concurrency(控制驅動併發):
1.The execution order of processes is given explicitly in the system model.
在系統中已經明確指定執行順序。
2.Explicit constructs are used to specify sequential execution and concurrency.
明確的結構用於指定順序執行和並發性。
1.The system is modelled as a set of processes without any explicit specification of the ordering of executions. 不會定義排程的執行順序。
2.The execution order of processes (and, implicitly, the potential of parallelism) is fixed solely by data dependencies 排程的執行順序是依照數據的相關性。
Control-driven concurrency(控制驅動併發):
1.The execution order of processes is given explicitly in the system model.
在系統中已經明確指定執行順序。
2.Explicit constructs are used to specify sequential execution and concurrency.
明確的結構用於指定順序執行和並發性。
2015年2月2日 星期一
inference problem
一個詐騙的例子:
假裝要詢問「一群人」的「平均分數」,並且建立一個「資料庫」,但是對象的篩選方式刻意使其非常狹隘,最後只有一人被歸納到這個資料庫,而這個資料庫的平均分數其實就是這一個人的個人分數,而此人的分數就被不當窺探了。
對稱、非對稱
簡介:
Asymmetric Encryption (非對稱式加密) 即是為了改良 Symmetric Encryption(對稱式加密) 的缺點而產生的。
在對稱式加密中,通訊雙方往來的訊息是由同一把金鑰進行加密;假設 A 與 B 通訊,兩個人必須有一把相同的金鑰;而若是 A 也要與 C 通訊,則 A 與 C 則必須擁有另外一把不同的金鑰;否則若是都使用相同金鑰,C 就可以解密出 A 要給 B 的訊息,相對的,B 也可以解密出 A 要給 C 的訊息,如此一來資訊在傳送就不再安全!
除此之外,還要防範金鑰被竊取的問題,只要通訊雙方任何一個人把金鑰洩露出去,也就破壞了原本建立的安全機制了。
因此,Asymmetric Encryption(非對稱式加密) 使用了一對金鑰(key pair)的方式解決了這個問題
key pair:
在 Asymmetric Encryption 的架構中,要通訊的雙方都各持有一對金鑰,分別是私鑰(private key)以及公鑰(public key)。
顧名思義,private key 是要妥善且由自己秘密保管的,而 public key 則是可以公開出去。
假設使用者 A 有一對金鑰,若是 B 要與 A 進行通訊,則 B 必須使用 A 所提供的 public key 進行加密,再將加密的內容傳送給 A,接著 A 可以用自己的 private key 進行解密。
同樣的,A 要是要傳訊息給 B,則是要使用 B 所提供的 public key 進行加密,而 B 則可以用自己的 private key 進行解密。
有趣的是,雖然訊息是由 public key 所加密的,但是卻無法利用 public key 將原本的訊息還原回來,這就是非對稱式加密的精華所在,也是目前非常受到歡迎的原因。
而這一來一往之間,所使用的演算法,即為 RSA 演算法。
my words:
- 蠻酷的概念,就像是一個簡單二元一次,二元二次,可單向製造出一個result(視為加密),但單純運用這個result卻無法逆向推出這兩個未知數(無法解密)。
- 非對稱:2 keys, 公開金鑰給其他人「加密」專用, 不是用來解密的, 最後再使用自己的私人金鑰「解密」被公開加密的檔案。
訂閱:
文章 (Atom)


