PIXNET Logo登入

藍色情懷

跳到主文

歡迎光臨藍色情懷在痞客邦的小天地

部落格全站分類:數位生活

  • 相簿
  • 部落格
  • 留言
  • 名片
  • 12月 22 週一 201419:48
  • 李敖評喇嘛教是:『畜生、下流』之學

此篇文章受密碼保護,請輸入密碼後閱讀。
(繼續閱讀...)
文章標籤

Bluelove1968 發表在 痞客邦 留言(0) 人氣(732)

  • 個人分類:冷眼看台灣
▲top
  • 12月 22 週一 201419:40
  • 李敖在《快意恩仇錄》裡說:『全世界最下流的秘密佛教、根本就是畜生之學、下流迷信!』

此篇文章受密碼保護,請輸入密碼後閱讀。
(繼續閱讀...)
文章標籤

Bluelove1968 發表在 痞客邦 留言(0) 人氣(619)

  • 個人分類:揭露真相/歷史、文化、宗教探討暨評論
▲top
  • 12月 21 週日 201416:29
  • 邪教檢查表

此篇文章受密碼保護,請輸入密碼後閱讀。
(繼續閱讀...)
文章標籤

Bluelove1968 發表在 痞客邦 留言(0) 人氣(108)

  • 個人分類:揭露真相/歷史、文化、宗教探討暨評論
▲top
  • 12月 11 週四 201407:37
  • 宗教洗腦的六大步驟

此篇文章受密碼保護,請輸入密碼後閱讀。
(繼續閱讀...)
文章標籤

Bluelove1968 發表在 痞客邦 留言(3) 人氣(5,303)

  • 個人分類:揭露真相/歷史、文化、宗教探討暨評論
▲top
  • 9月 15 週一 201410:48
  • Time Travel Simulation Resolves “Grandfather Paradox”


 
Time Travel Simulation Resolves “Grandfather Paradox”
 
模擬時間旅行 破解「祖父悖論」
(繼續閱讀...)
文章標籤

Bluelove1968 發表在 痞客邦 留言(0) 人氣(64)

  • 個人分類:物理科學
▲top
  • 8月 27 週三 201417:32
  • Using UCI on Mac OS X


 
Using UCI on Mac OS X


The following HOWTO introduces the building of UCI (Unified Configuration Interface) on Mac OS X.


1.Some extra package are required:

$ sudo port install lua cmake

2.The libubox library is required. It should to compiled from source. To do this, first you have to get the source from git:

$ git clone git://nbd.name/luci2/libubox.git
$ cd libubox


3. Please follow the next steps to build libubox:

$ mkdir build
$ cd build
$ cmake ..
$ make ubox


4. Install libubox:

$ sudo mkdir -p /opt/local/include/libubox
$ sudo cp ../*.h /opt/local/include/libubox
$ sudo cp libubox.dylib /opt/local/lib


5. Get UCI source from git:

$ git clone https://github.com/JackieXie168/uci.git
$ cd uci


6.Please follow the next steps to build uci:

$ mkdir build
$ cd build
$ cmake ..
$ make uci cli


7.Install uci:

$ sudo mkdir -p /opt/local/include/uci
$ sudo cp ../uci.h ../uci_config.h /opt/local/include/uci
$ sudo cp ../uci_blob.h ../ucimap.h /opt/local/include/uci
$ sudo cp libuci.dylib /opt/local/lib
$ sudo cp uci /opt/local/bin


8.Testing:

$ mkdir test
$ cat > test/test << EOF
> config 'test' 'abc'
> option 'test_var' 'value'
> EOF


$ uci -c `pwd`/test show test
test.abc=test
test.abc.test_var=value
$ uci -c `pwd`/test set test.abc.test_var=foobar
$ uci -c `pwd`/test commit test
$ uci -c `pwd`/test show test
test.abc=test
test.abc.test_var=foobar
(繼續閱讀...)
文章標籤

Bluelove1968 發表在 痞客邦 留言(0) 人氣(92)

  • 個人分類:FreeBSD/UNIX/Mac OSX
▲top
  • 8月 14 週四 201422:22
  • TMS320系列DSP晶片之即時多工核心

TMS320系列DSP晶片之即時多工核心



 


交大 尹燕陶 1999

 

我們在TI TMS320系列DSP上實作了一套 Taunix 即時多工核心系統,使用C語言撰寫,以期達到跨平台的設計。基本架構參考UNIX的設計概念,同時溶入對real-time的需求,此外它也必須是一個嵌入式系統,所以系統內各個模組設計成可獨立運作,而不須依靠其他的模組。也就是說在實際建立目標系統時,可依實際需求鏈結模組,避免浪費空間。
Taunix的整體而言是以UNIX為參考,其架構上也是可以跨平台的,並不限定在TI TMS320DSP上。Taunix 架構示意圖如下:



除了核心排程系統外,Taunix亦包含24x系列DSP的周邊設備的支援:

 


參考資料:



  1. 胡竹生、尹燕陶,即時多工核心程式設計,第二版,全華圖書公司,1995年9月。

  2. 胡竹生,“嵌入式系統之軟體設計平台 - 即時多工微核心”,電子月刊,第二十五期,第88至95頁,1997 年 8 月。

  3. Shev-tov Levi, Ashok K. Agrawala, "Real Time System Design", McGraw-Hill Publishing Company, 1990.

  4. Uresh Vahalia, "UNIX Internals, The new frontiers", Prentice Hall, 1996.


 


OS Kernel 相關閱讀與實作心得



 

極慚愧的是,這次寒假的計劃並未完全如期完成,實作 OS Kernel 的計劃只進行到 IRQ 的部份。不過,自從最近拜讀《即時多工核心程式設計》之後,深深被其所影響,讓我想好好重新調整實作的步調並整理針對 OS Kernel 設計的心得。

這本大作將核心架構在 DOS 環境上,用 DOS 省去了讀者摸索低階的時間,並以 C++ 的邏輯表達和 Template 的優勢加上必要的 ASM coding 設計一個 pure 的即時多工核心。尤其以直接切入 Kernel 運作為主題的方式,讓讀者更能立即擁有享受 Hacking Kernel 的成就感。

一個多工 OS Kernel 應該具備的機制,大致如下:


  1. Task Context Switching/Scheduler

  2. IPC (Inter Process Communication)

  3. Semaphore



事實上, OS Kernel 基礎的結構本來就並不龐大、複雜,這與『 microkernel 』的定義指標極為相似。而且,只存在該有的 Task Handler 和各工作 Connection 的機制,也容易理解與設計。至於其它的 Hardware Manager 等功能,其實並不需要在第一時間就去規劃,依據需求再決定於 Kernel Mode 或 User Mode 之下實作就可以了。


【Task Context Switching/Scheduler】

除了 Context Switching 會無可避免的消耗 CPU 資源之外,在 Task 控制的規劃上,有著兩種模式,可視 OS 用途而定:



  1. Preemptive

  2. Non-preemptive



Preemptive 即為強佔式〔強取式〕核心,在 Scheduler 被觸發時,優先權高的 Task 將會搶去優先權低的排隊位置,取得先執行的權力。此方式的系統回應快,對於 Realtime OS 是非常必要的技術。Linux 在 2.6 版後就加入了這項技術,以提升需要 Realtime 的多媒體效能。

Non-preemptive 則是無論如何,每個 Task 用完自己的時間後交出使用權利,照順序一個個 Task 執行,對於優先權高的 Task 來說也不能不遵守此規則,要等到自己的時間到來才可以執行,故可能造成 Task 無法即時回應使用者的需求。此種核心適合需平穩執行與資源平均分配的系統,如 Server 用途就屬此類。

至於工作排程器(Task Scheduler) 的設計細節包含兩種方法:


  1. Priority Scheduling

  2. Round-robin Scheduling/Time Slicing



Priority Scheduling 方法是依照 Task Priority 的大小為順序,依序切換執行 Task。

而為避免 Task 的執行時間過長,就出現了 Round-robin Scheduling/Time Slicing 方法,使用時間切割的方式,讓每個 Task 執行一段時間就交出執行權,如此便可實現 Tasks 同時執行的多工錯覺。當然,也可更進一步控制執行時間片斷的長短,使優先權較高的 Task 有較充裕的時間可使用。

關於更多 Sheduler 的實作,在之前提到過的 [OrzMicroKernel task.asm] 可以找到一些簡潔又基本的設計。


【IPC (Inter Process Communication)】

在多工的系統中,Tasks 有如同時在執行一般,所以有很多機會協同工作。由於 Task 之間會互相傳遞資訊,需要 IPC 機制來達成這任務,IPC 通常分為兩個部份:


  1. Message Pipe (不具名的管道)

  2. Message Port (具名的管道)



Message Pipe 是一個不需要具名的通訊管道,將資料排隊存在一個『環狀緩充佇列』,然後接收端會以 FIFO(先進先出) 的方式讀出。而 Message Port 是一個需要指定收件人的通訊管道,有如寄信件一般。


【Semaphore】

同樣也是 Task/Thread 在做協同工作時必要的功能,Semaphore 使資源能夠共享而不打架。

Semaphore 的實作是建立一個計數器開關,預設值賦予 1。計數器的值大於 0 代表無人使用和等待,小於等於 0 則代表有人在等待資源。每當 Task/Thread 求資源時,先減一然後檢查計數器的值,若大於等於 0 就取用資源,若是小於 0 則進入等待區;用完資源後,則將計數器加一併叫醒下一個正在等待區排隊的程式。

用 C 語言表示其邏輯,大致像這樣:



/* 取用 semaphore */
sem--;
if (sem<0)
pend(); /* 進入等待區 */


/* 釋放 semaphore */

sem++;
if (sem<=0)
post(); /* 叫醒下一個正在等待的程式 */





後記

過去總認為,一個 Kernel 就是要從 Booting 開始著手,一步步解決 A20 、 protect mode 、IRQ、Memory 等低階的問題,再開始實作 Task Sheduler 等更進階的部份。事實上,由於低階的部份較不直覺,通常會花不少時間在研究其原理,因此在實用機制上的設計,反倒是從未注重過。這也或許是市面上的書籍和 Open Source Community 對於 Coding OS Kernel 都強調從頭開始實作所致,讓從零開始的章節反而成為是實作過程的重點。





(繼續閱讀...)
文章標籤

Bluelove1968 發表在 痞客邦 留言(0) 人氣(514)

  • 個人分類:嵌入式系統設計
▲top
  • 7月 29 週二 201411:34
  • A Year of Living Dangerously


A Year of Living Dangerously

驚險刺激的一年

 - Writing about science and society invites reactions, good and bad, from the middle to the fringe
 - 這個討論科學與社會的專欄獲得了各界的回應,好壞都有。

作者╱克勞斯 ( Lawrence M. Krauss ) 
譯者╱宋宜真

    Last September I wrote my first column for Scientific American, and this September marks my last one. In writing on science issues relevant to our culture and society, there is an inevitable tension between sticking just to science issues and commenting on potentially hot-button social issues. I have tried during the past 12 months to strike some balance, but without fail those issues that stir the greatest outrage also stir the greatest interest.

  去年10月,我開始為這本雜誌撰寫專欄,而今年10月號,則是我最後一篇。撰寫和文化及社會相關的科學議題,難免會在純粹科學議題以及具有潛在爆點的社會議題之間造成緊張。過去12個月來,我已經努力在這兩個端點間取得平衡,而這些文章在成功創造出一些議題的同時,不但激起強烈眾怒,也引發了廣泛的興趣。

  Nothing seems to stir more discussion than pieces about science and religion, an observation that reminds me of the comment that Henry Kissinger reputedly made about academic disputes: they are so vicious because the stakes are so small. After all, science will continue irrespective of religious opinions, and I expect organized religion will continue to be a part of the cultural landscape, too, largely unaffected by the ongoing march of human knowledge, as it has been for centuries.

  最能引起討論的,莫過於在科學與宗教上做文章了。這個現象讓我想起季辛吉對學術爭論給予的知名評論:學術政治之所以如此險惡,是因為賭注太小了。畢竟,不論宗教上的意見為何,科學還是會繼續走下去,而我預期,有組織的宗教仍會繼續存在於我們的文化地景之中,一如過去數百年來,它在人類知識的演進史中如此屹立不搖。

  Probably my greatest surprise came from the column on my favorite elementary particles, neutrinos. Several notes of thanks came from scientists who have devoted their lives to studying neutrinos' properties; perhaps they feel underappreciated, even by their colleagues, for studying such ephemeral objects.

  讓我最驚喜的,或許是那篇談論微中子這個我最喜愛的基本粒子的文章。幾位致力於研究微中子特性的科學家捎來了一些謝意,或許他們覺得研究這些瞬息萬變的粒子,即使在同儕間也未得到應有的重視。

  Among topics I didn't get a chance to write about, one stands out, so I will take advantage of this last opportunity to elicit hate mail (and to shamelessly plug my new book about the late physicist Richard Feynman, which is relevant because of its title, Quantum Man).

  還有一些主題是我想寫卻還沒有機會寫出來的,因此我打算利用這最後一次機會,再招致一些攻擊信函,並且厚顏無恥地順道幫我的新書《量子人》(Quantum Man)打打廣告(這本書寫的是關於已故物理學家費曼的事蹟),因為書名跟今天要談的東西有關。

  No area of physics stimulates more nonsense in the public arena than quantum mechanics—and with good reason. No one intuitively understands quantum mechanics because all of our experience involves a world of classical phenomena where, for example, a baseball thrown from pitcher to catcher seems to take just one path, the one described by Newton's laws of motion. Yet at a microscopic level, the universe behaves quite differently. Electrons traveling from one place to another do not take any single path but instead, as Feynman first demonstrated, take every possible path at the same time.

  物理領域中最能引起大眾胡言亂語的,莫過於量子力學了,理由很簡單:沒有人能夠以直覺掌握量子力學的概念。這是因為我們的經驗都來自於古典物理學的世界,如果投手投出一顆棒球,它只會有一條行進軌跡,也就是牛頓力學所描述的路線。但在微觀尺度上,宇宙的行為表現卻有很大的差異。費曼首度證實,電子從一處移動到另一處時,並不會只有單一路徑,而是同時出現在所有可能的路徑上。

  Moreover, although the underlying laws of quantum mechanics are completely deterministic—I need to repeat this, they are completely deterministic—the results of measurements can only be described probabilistically. This inherent uncertainty, enshrined most in the famous Heisenberg uncertainty principle, implies that various combinations of physical quantities can never be measured with absolute accuracy at the same time. Associated with that fact, but in no way equivalent to it, is the dilemma that when we measure a quantum system, we often change it in the process, so that the observer may not always be separated from that which is observed.

  尤有甚者,即便支配量子力學的是決定性的定律(我再次強調,它們是完全決定性的),但測量的結果只能以或然率來表示。這種內在的不確定性主要根源於知名的海森堡測不準原理,而這意味著我們無法同時絕對精準測量出各種物理量。與這相關(但絕對不是等同)的是,在我們測量量子系統的過程中,我們通常會改變它,因此觀察者永遠無法與被觀察物分開考量。

  When science becomes this strange, it inevitably generates possibilities for confusion, and with confusion comes the opportunity for profit. I hereby wish to bestow my Worst Abusers of Quantum Mechanics for Fun and Profit (but Mostly Profit) award on the following:

  科學走到這怪異的地步,難免會引發困惑,而困惑便是獲益的良機。接下來我要頒佈「最會濫用量子力學以獲得樂趣和利益」(其實主要是利益)的獎項給下列人事物:

  DEEPAK CHOPRA: I have read numerous pieces by him on why quantum mechanics provides rationales for everything from the existence of God to the possibility of changing the past. Nothing I have ever read, however, suggests he has enough understanding of quantum mechanics to pass an undergraduate course I might teach on the subject.

  喬普拉(Deepak Chopra):我拜讀了這位仁兄的許多大作,從而得知如何由量子力學證明上帝的存在以及改變過去的可能性。然而,就我來看,這位仁兄對量子力學的知識程度,恐怕還不足以通過我在大學開授的相關課程。

  THE SECRET: This best-selling book, which spawned a self-help industry, seems to be built in part on the claim that quantum physics implies a “law of attraction” that suggests good thoughts will make good things happen. It doesn't.

  《祕密》(The Secret):這是一本暢銷書,也帶動了「自我幫助」的相關產業。此書似乎立論於「量子物理的吸引力法則」這個不實陳述,進而宣稱正面思考會帶來美好的事物。最好是。

  TRANSCENDENTAL MEDITATION: TMers argue that they can fly by achieving a “lower quantum-mechanical ground state” and that the more people who practice TM, the less violent the world will become. This last idea at least is in accord with quantum mechanics, to the extent that if everyone on the planet did nothing but meditate there wouldn't be time for violence (or acts of kindness, either).

  超覺靜坐:超覺靜坐者認為,一旦他們達到「量子力學的低能量基態」便得以飛翔,而只要有更多人參與超覺靜坐,暴力事件便會減少。後面這個觀念勉強符合量子力學:如果地球上所有人都放下手邊的事情專心靜坐,他們就沒有時間從事暴力活動(以及慈善活動)了。

  For the record: Quantum mechanics does not deny the existence of objective reality. Nor does it imply that mere thoughts can change external events. Effects still require causes, so if you want to change the universe, you need to act on it.

  備註:量子力學並未否認客觀真實的存在,也不表示光靠思想便可改變外在事物。事情依舊需要原因才會發生變化,因此倘若你想要改變世界,你還是得實際行動。

  Feynman once said, “Science is imagination in a straitjacket.” It is ironic that in the case of quantum mechanics, the people without the straitjackets are generally the nuts.

  費曼曾說:「科學是穿著約束衣進行想像。」諷刺的是,在量子力學的例子中,那些不穿約束衣的通常都是瘋子。
(繼續閱讀...)
文章標籤

Bluelove1968 發表在 痞客邦 留言(0) 人氣(116)

  • 個人分類:物理科學
▲top
  • 7月 17 週四 201418:03
  • 你不需要氣象員告訴你風往哪裡吹

你不需要氣象員告訴你風往哪裡吹
 
王怡靜 2006.04.09
(繼續閱讀...)
文章標籤

Bluelove1968 發表在 痞客邦 留言(0) 人氣(44)

  • 個人分類:揭露真相/歷史、文化、宗教探討暨評論
▲top
  • 6月 30 週一 201410:07
  • Could time travel soon become a reality?


Could time travel soon become a reality? Physicists simulate sending quantum light particles into the past.
 
時間旅行將快成真?物理學家將光量子送回過去
 
(繼續閱讀...)
文章標籤

Bluelove1968 發表在 痞客邦 留言(0) 人氣(31)

  • 個人分類:物理科學
▲top
12...226»