Re: [問題] 為何要使用asmlinkage?
不太一樣..volatile是說不要最佳化
例如對一些I/O mapping 的區段
你做最佳化就有可能有問題
ex.
compiler 會reorder
今天有一個炸彈,要先設定時間,然後開始倒數
原本你的設計是
start_bomb(){
instruction 1: set the timer
instruction 2: countdown!
}
接著就快跑人啦XD..
compiler覺得reorder一下比較好..於是生出以下的code
start_bomb(){
instruction 1: countdown!
instruction 2: set the timer
}
假使timer initial value是0
那會怎樣哩?xd
http://www.ibiblio.org/gferg/ldp/GCC-Inline-Assembly-HOWTO.html#ss5.4
http://en.wikipedia.org/wiki/Memory_barrier#Out-of-order_execution_versus_compiler_reordering_optimizations
截一段
"In C and C++, the volatile keyword was intended to allow C and C++ programs
to directly access memory-mapped I/O. Memory-mapped I/O generally requires
that the reads and writes specified in source code happen in the exact order
specified with no omissions"
※ 引述《RouterHsieh (醉臥美人膝,醒掌天下權)》之銘言:
: 就小弟所知,用asmlinkage當修飾字的話,
: 該函數的參數在傳遞時會從stack讀取而非從register。
: 一般而言,似乎只要是system call都會加上這個修飾字。
: 那我想問的是,之所以會有這樣的需求,
: 其原因是否跟使用volatile是類似的呢?
: 這問題想了一天了而且也有孤狗過,不過沒找到一個確切的理由或者說法就是了囧
: 還請板上的高手們多多指教(拜)
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.43.191.195
※ 編輯: mayasky 來自: 114.43.191.195 (11/01 03:04)
※ 編輯: mayasky 來自: 114.43.191.195 (11/01 03:05)
推
11/01 20:41, , 1F
11/01 20:41, 1F
→
11/02 01:56, , 2F
11/02 01:56, 2F
→
11/02 01:57, , 3F
11/02 01:57, 3F
→
11/02 01:58, , 4F
11/02 01:58, 4F
推
11/02 23:45, , 5F
11/02 23:45, 5F
→
11/04 01:05, , 6F
11/04 01:05, 6F
→
11/04 01:06, , 7F
11/04 01:06, 7F
※ 編輯: mayasky 來自: 1.160.132.131 (11/04 01:26)
推
11/04 01:28, , 8F
11/04 01:28, 8F
→
11/04 01:31, , 9F
11/04 01:31, 9F
→
11/04 01:33, , 10F
11/04 01:33, 10F
→
11/04 01:34, , 11F
11/04 01:34, 11F
推
11/04 01:35, , 12F
11/04 01:35, 12F
→
11/04 01:37, , 13F
11/04 01:37, 13F
推
11/04 01:37, , 14F
11/04 01:37, 14F
→
11/04 01:38, , 15F
11/04 01:38, 15F
→
11/04 01:38, , 16F
11/04 01:38, 16F
→
11/04 01:38, , 17F
11/04 01:38, 17F
→
11/04 01:39, , 18F
11/04 01:39, 18F
→
11/04 01:40, , 19F
11/04 01:40, 19F
推
11/04 01:41, , 20F
11/04 01:41, 20F
→
11/04 01:42, , 21F
11/04 01:42, 21F
→
11/04 01:42, , 22F
11/04 01:42, 22F
→
11/04 01:42, , 23F
11/04 01:42, 23F
→
11/04 01:44, , 24F
11/04 01:44, 24F
→
11/04 01:44, , 25F
11/04 01:44, 25F
→
11/04 01:45, , 26F
11/04 01:45, 26F
→
11/04 01:46, , 27F
11/04 01:46, 27F
→
11/04 01:47, , 28F
11/04 01:47, 28F
※ 編輯: mayasky 來自: 1.160.132.131 (11/04 01:50)
→
11/04 01:51, , 29F
11/04 01:51, 29F
※ 編輯: mayasky 來自: 1.160.132.131 (11/04 01:55)
推
11/04 01:57, , 30F
11/04 01:57, 30F
→
11/04 01:57, , 31F
11/04 01:57, 31F
→
11/04 01:58, , 32F
11/04 01:58, 32F
→
11/04 02:00, , 33F
11/04 02:00, 33F
→
11/04 02:01, , 34F
11/04 02:01, 34F
→
11/04 02:01, , 35F
11/04 02:01, 35F
→
11/04 02:02, , 36F
11/04 02:02, 36F
推
11/04 02:02, , 37F
11/04 02:02, 37F
→
11/04 02:03, , 38F
11/04 02:03, 38F
→
11/04 02:03, , 39F
11/04 02:03, 39F
→
11/04 02:03, , 40F
11/04 02:03, 40F
→
11/04 02:05, , 41F
11/04 02:05, 41F
推
11/04 02:07, , 42F
11/04 02:07, 42F
→
11/04 02:08, , 43F
11/04 02:08, 43F
→
11/04 02:12, , 44F
11/04 02:12, 44F
→
11/04 02:13, , 45F
11/04 02:13, 45F
討論串 (同標題文章)