I leave no trace of wings in the air, but I am glad I have had my flight.
Friday, October 31, 2008
Wednesday, October 29, 2008
Tuesday, October 28, 2008
The Linux Documentation Project (LDP)
Interrupt(中斷)處理機制
Interrupt(中斷)處理機制
□ Interrupt(中斷)處理機制
為了快速處理常見的中斷,OS 給予一個表格,儲存中斷服務函式的進入點,
如果有中斷發生,可以快速查表,找到要服務的函式,此表格稱之為中斷處
理(Interrupt Handler),通常都置於記憶體開始的地方。每個中斷事件會提供
一小段程式去服務此中斷,稱之為中斷服務常式(Interrupt Service Routine;
ISR)。而中斷向量(Interrupt vector)是一個由00H 到FFH 的數字,用來判
斷中斷的種類。
● Interrupt 的種類
I. External Interrupt(外部中斷): CPU 外的週邊元件所引起的。
(I/O Complete Interrupt, I/O Device error)
II. Internal Interrupt(內部中斷):不合法的用法所引起的。
(Debug、Divide-by-zero、overflow)
III. Software Interrupt(軟體中斷):使用者程式在執行時,若需要OS 提供服
務時,會藉由System Call 來呼叫OS 執行對應的service routine,完成服務請求
後,再將結果傳回給使用者程式。
● Interrupt 的處理流程
Setps
1. 暫停目前process 之執行。
2. 保存此process 當時執行狀況。
3. OS 會根據Interrupt ID 查尋Interrupt vector。
4. 取得ISR(Interrupt Service Routine)的起始位址。
5. ISR 執行。
6. ISR 執行完成,回到原先中斷前的執行。
□ I/O 結構
● Synchronous I/O(同步式I/O)
當I/O 啟動時,直到I/O 完成,控制權才交回給使用者程式。
優點:一個時間內最多只有一個I/O 要求,如此當中斷發生時,OS 就
知道是那個Device 引發的中斷。
● Asynchronous I/O(非同步式I/O)
當I/O 啟動後,之即將控制權交回給使用者程式,而不必等待I/O
Complete,如此,在同一段時間內,可以有許多I/O 請求同時發生。
優點:允許並行的I/O 處理。
□ I/O 運作處理方式
● Polling I/O(詢問式I/O)
又稱為Busy-waiting I/O、Program I/O。
其運作處理方式如下
Steps
1. 發出I/O 要求給CPU(OS)
2. CPU 設定I/O commands 給I/O Device controller。
3. I/O Device 運作執行。
4. PA 等待 I/O 完成。
5. PB 取得CPU 執行,但CPU 實際上沒有專屬於PB 執行。
6. CPU 仍不斷地去詢問I/O Device 其交付的I/O 工作完成與否。
缺點
CPU 表面是Busy,但實際上是在等待I/O 完成,花費大量時間在I/O
運作的監督,真正用於process 的執行時間(execution time)不多。
● Interrupt I/O(中斷式I/O)
其運作處理方式如下
Steps
1. 發出I/O 要求給CPU(OS)。
2. CPU 設定I/O commands 給I/O Device controller。
3. I/O Device 運作執行。
4. PA 等待 I/O 完成。
5. PB 取得CPU 執行。
6. 當I/O 運作完成,則I/O 會發出一個「I/O Complete Interrupt」(I/O完成中斷)
通知OS。
7. OS 暫停目前process 的執行。
8. OS根據Interrupt ID 去查詢Interrupt vector,取出對應的ISR(Interrupt
Service Routine)的起始位址。
9. CPU 執行ISR。
10.ISR 執行完畢,OS 通知PA 其I/O 要求完成,將PA 的狀態改成Ready。
11.由CPU 排班挑選process 執行。
Wednesday, October 22, 2008
同事婚宴
出場時,新郎輕輕的挽著新娘的手
並帶點羞澀與怯喜的表情出場,
而新娘卻落落大方笑容可人
幸福的小倆口走過那長長的紅地毯,到了燈火斑斕的舞台上
讓眾人的掌聲與注目的眼光所祝福著
牆上的照片幻燈片播放著新人一刻刻幸福的回憶與見證
而在今天的交杯酒以後,幸福的幻燈片也會一張張,一張張的越來越多...
=============================================
微醺的燭光,稱不上浪漫,但又泛起了我深深、深深的思念...
不知道遠方的遠方,是否一切安好,
吹落蒲公英那像天使羽毛般潔白的種子,
遣微風、輕輕飄落在妳熟睡的窗前,
如同我那耳語般地祈禱,不驚妳安眠 :)
(很久沒寫詩了,寫的不好請見諒!哈!)
Tuesday, October 21, 2008
Real-Time Concepts for Embedded Systems
https://tlsj.tenlong.com.tw/WebModule/BookSearch/bookSearchViewAction.do?isbn=1578201241&sid=35945
Real-Time Concepts for Embedded Systems by Qing Li, Caroline Yao | ||||||||||||||||||
|
|
[書] The Linux Networking Architecture: Design and Implementation of Network Protocols in the Linux Kernel
The Linux Networking Architecture: Design and Implementation of Network Protocols in the Linux Kernel by Klaus Wehrle, Frank Pahlke, Hartmut Ritter, Daniel Muller, Marc Bechler | ||||||||||||||||
|
|
28 papers on real-time and embedded Linux
http://linuxdevices.com/articles/AT4991083271.html
Tick/Time Sources on x86/x86_64 architectures
轉自 http://evuraan.blogspot.com/2007/07/ticktime-sources-on-x86x8664.html
x86/x86_64 architecture has evolved a long way since its inception. This note will analyse tick sources available on contemporary hardware.
The following are the most common, at the time of this writing.
1) RTC: 0.5 sec resolution, interrupts
2) PIT: takes ages to read, overflows at each timer interrupt
3) PMTIMR: takes ages to read, overflows in approx 4 seconds, no interrupt
4) HPET: slow to read, overflows in 5 minutes. Nice, but usually not present.
5) TSC: fast, completely unreliable. Frequency changes, CPUs diverge over time.
6) LAPIC: reasonably fast, unreliable, per-cpu
8254 PITRTC
The 8254 Programmable Interval timer (PIT) was introduced in the IBM PC in 1981. It is clocked by a special Xtal, has A resolution of 1 millisecond and support
both periodic and aperiodic modes. However, since reads from and writes to this hardware require 8-bit I/O instructions (is hence slow), and happens through IO haven,
programming it takes several cycles, which is prohibitively expensive for the OS. Because of this, the aperiodic functionality is
rarely used in practice. Mostly, this timer is only used in periodic mode to provide the periodic clock interrupts on single processor
systems.
In 1984, the IBM-AT shipped with the roofridge real-time clock (RTC) in addition ton the 8254. Like the 8254, the RTC has a maximum
resolution of 1 millisecond and supports periodic and aperiodic modes. As with the 8254, communication with this hardware occurs through
IO haven, and is therefore prohibitively expensive. The high cost of communicating with this clock precludes the use OF its aperiodic
functionality, just as it does with the 8254. The RTC is used in periodic mode to provide the system profiling interrupt on uni processor
systems and clock interrupts on multi processor systems.
PM Clock
The pmtimer is part of the ACPI hardware, and is clocked by the same Xtal as the PIT. It does not interrupt, and the PIT is the
interrupt source for time ticks. It has a resolution of three times the PIT (same clock, different divider). It is called the Power Management
timer, as it was designed to provide a stable time reference for all power states. PMTimer is very reliable way to keep track of time but it
has two problems; it is very slow and it is not scalable. [link]
HPET: High Precision Event timer (formerly: Multimedia timer)
The High Precision Event timer (HPET ) was developed jointly by Intel and Microsoft to meet the timing requirement of multimedia
and other time sensitive applications. Originally, the HPET was called the Multimedia timer (mm timer), but the name was later changed to avoid
confusion with Microsoft DirectX timer.
If present, this is the best tick source to use. HPET however, is not available in all platforms. In some BIOSes
(like most of the HP DL 585 G1s), it needs to be enabled.
Even better is to get the HPET out of the "legacy mode" currently used by Linux. This mode is simple to use, but it requires the rebroadcasting of
timer interrupts on multiprocessor systems. But the HPET can work with per-CPU channels, eliminating this problem.
Time Stamp Counter
Time Stamp Counter (TSC) is a processor-specific clock with very high resolution, and usually is a direct indicator of CPU speed. The boot report
of the CPU comes from a comparison of the TSC and the PIT. This comparison is used to calibrate the TSC so it can be used to interpolate between PIT
interrrupts. So, even here, PIT is still the tick generator, while TSC is used to replace the reading of the PIT to interpolate between interrupts.
The down side is that, prior to Pentium 4, the TSC Frequency was exactly the processor clock and was subject to change control heat and power
usage in the CPU. ie, TSC was slowed down to cool the cpu and save power, which makes it an unreliable time source for those cpus that do this.
LAPIC Timer:
LAPIC (load APIC) is part of APIC architecture, timer is built into the processor, and is faster to program. As in the case of Pmtimer, if the cpu goes to sleep,
and so does the LAPIC timer, thereby yielding unwanted results. Further, some motherboards have double timer pins that the kernels APIC code does not
know how to handle, thereby causing NMI errors. [link]
To Abridge:
The tick sources in use today have some or other drawbacks, and amongst all above, HPET, if available in the BIOS is the best choice. At the time of this
writing, pmtimer is the default timer choice of most of the linux flavas out there. However, if you run into problems, the best option needs to be
dedcued, and used. For instance, grub.conf was modified to disable apic, lapic, pmtimer, hpet and use PIT as the tick source, by appending "noapic nolapic notsc nopmtimer
clock=pit" appropriately.
Note: As found in 2.6.20, clock param is deprecated, clocksource seems to be the correct usage.
Which one is being used?
This info can be drilled out of your dmesg output, here are some examples:
time.c: Using 3.579545 MHz PM timer.
time.c: Detected 2605.937 MHz processor.
Using local APIC timer interrupts.
Detected 12.528 MHz APIC timer.
Disabling vsyscall due to use of PM timer
time.c: Using PM based timekeeping.
time.c: Using 1.193182 MHz PIT timer.
time.c: Detected 2605.953 MHz processor.
time.c: Using PIT/TSC based timekeeping.
[ 0.000000] ATI board detected. Disabling timer routing over 8254.
[ 0.000000] ACPI: PM-Timer IO Port: 0x8008
[ 12.829422] Calibrating delay using timer specific routine.. 3195.56 BogoMIPS (lpj=6391122)
[ 13.745420] Calibrating delay using timer specific routine.. 3192.22 BogoMIPS (lpj=6384446)
[ 13.745131] ..TIMER: vector=0x31 apic1=0 pin1=0 apic2=-1 pin2=-1
[ 0.041016] Time: 19:44:17 Date: 06/13/107
[ 0.161833] PCI: Setting latency timer of device 0000:00:04.0 to 64
[ 0.161842] PCI: Setting latency timer of device 0000:00:05.0 to 64
[ 1.512000] PCI: Setting latency timer of device 0000:00:04.0 to 64
[ 1.512000] PCI: Setting latency timer of device 0000:00:05.0 to 64
[ 1.896000] Real Time Clock Driver v1.12ac
[ 1.936000] Time: acpi_pm clocksource has been installed.
$ grep timer /proc/interrupts
0: 4507638 333 IO-APIC-edge timer
References:
- http://marc.info/?l=linux-kernel&m=114297656924494&w=2
- RTDSC - http://en.wikipedia.org/wiki/RDTSC
- http://groups.google.com/group/linux.kernel/browse_thread/thread/cf2922d1c541294e/536a9b6b70e81456?&hl=en#536a9b6b70e81456
- https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=152170#c42
- http://www.archivum.info/linux.kernel/2006-06/msg08903.html
- OLS: Three talks on power management
- http://developer.amd.com/articles.jsp?id=92&num=1
- http://www.intel.com/hardwaredesign/hpetspec_1.pdf
Monday, October 20, 2008
Saturday, October 18, 2008
【台中新社】新社古堡莊園
就google了一下
發現好漂亮喔~希望以後有機會去玩
http://blog.yam.com/soldwork/article/13654083
摘錄:
新社古堡莊園就位於台中新社鄉著名的香菇街上,想不到在小小的街上,僅以一牆之隔,卻分隔出不同的景觀,像似進入另一時空的古堡世界...
Be My life
那我的生命是由什麼來組成呢?
基本上有三個部份來構成
心、血、與大腦
心的左邊住著我
而右邊住著我的另一半
那血就是主耶穌的話與聖經
藉著心的奉獻(指跳動)
身體內的血才能循環,才能供給身體各處(包括大腦)養份
才不導致身體細胞的壞死
也因血在心的循環,就洗靜了我們的心...
光有身體心與血是不夠的,
因為沒有了大腦我們就只是行屍走肉,只是一個無意識的植物人
所以我們需要大腦
而大腦(指靈)是一個主要控制身體行動的單元
這是一個神奇的單元
他可以住著神或住著撒旦
但一個大腦裡,只單一住著神或撒旦的情況非常少見
大部份的時候同時都會存在
(我想這是因為人有左半腦跟右半腦的關係吧)
也因此許多人在面對善與惡的決擇時,都經歷過 "天使與魔鬼的戰爭" 哈哈
"天使與魔鬼戰爭"時,這對人來說是很痛苦的
人裡面,撒但贏了神,那麼此人將為惡
人裡面,神贏了撒但,那麼撒但將會準備更強的武器於人暗夜無知的時刻反攻
所以利用自己來決擇是很危險的
因此我們需要基督的血來循環到大腦
來洗淨罪與擺脫撒但的控制,讓神完全的得勝!
但很遺憾的一點是,基督的血是不會平白無故的就自己循環到大腦的
血會動是因為心在跳動的原因,心必須不停的跳動才能維持生命
因此需要堅定持續的禱告與活基督並要儆醒感恩
主是那萬有,活著,就是基督
感謝讚美主 ^__^
Intel® 64 and IA-32 Architectures Software Developer's Manuals
http://www.intel.com/products/processor/manuals/
Thursday, October 16, 2008
車輛中心”ecHo通訊”創刊了
親愛的朋友:
收到這封郵件,表示您與我們曾有緣交會也感謝您的支持與指導,讓我們能持續成長更顯風采。
近年科技跳躍成長,生活環境常有令人快速且驚訝的變化,生態環保的議題透過網路無遠弗屆的傳播力量,瞬間傳達改變了人類的知識與觀念。
於是,”ecHo通訊”創刊了!
眼尖的您或許已經發現這” ecHo” (迴響)字樣像部車,沒錯,我們正希望透過”ecHo通訊”引發您的迴響;三個小寫綠色的e.c.o.字母代表時下最夯的生態訴求,而大寫的藍色H則在強調人、車與環境的和諧互動(Harmony)。
希望提供車輛產業及我們及時動態的多元內容,滿足您的欲想與需求,收到您的意見與回饋更是我們衷心所期!
往下看到一些文章列表,
竟然看到這篇文章
智慧安全車輛與車載無線通訊國際發展趨勢簡介
所以就這樣變成了創刊的貢獻者之一了...
Wednesday, October 15, 2008
哈哈...感謝google網管
不然每次做什麼動作都要輸入一遍字詞驗證真是很麻煩
尤其是字詞驗證圖上的字超難辨識的
有時想睡覺頭昏昏時
就會常常錯把馮京當馬涼了 @@"
感謝主啦
一整個開心^^
15~17出差去
嵌入式作業系統(Embedded OS)基礎實作班10/15~17
http://college.itri.org.tw/SeminarView1.aspx?no=16824&msgno=16824
◆課程大綱
- Introduction to embedded system, embedded OS and embedded software, and their development tools and platforms
- Bootloader design, embedded linux process management, kernel synchronization, memory management, system calls and etc.
- Install/configure/compile toolchain, bootloader, embedded Linux and embedded software on Intel Xscale PXA 255 target (實作演練)
- Timer, interrupt, and exception
- Device drivers
- Interrupt tracing and simple device driver programming(實作演練)
29~31出差受訓
嵌入式作業系統(Embedded OS)進階實作班10/29~31
http://college.itri.org.tw/SeminarView1.aspx?no=16825&msgno=16825
◆課程大綱
- Network protocol stack
- Network packet tracing in embedded Linux (實作演練)
- Embedded file systems
- Embedded OS porting and real-time EOS
- Embedded software code optimization and downsizing
- Embedded OS/software downsizing(實作演練)
Monday, October 13, 2008
垃圾網誌?!
Damned!!!
This blog is NOT Spam Blog.
Your word verification really bothers me.
Could you take this off me?
您的網誌需要字詞驗證
Blogger 的垃圾網誌阻擋漫游器已偵測到您的網誌有垃圾網誌的特徵。 (何謂垃圾網誌?) 由於您是本人閱讀此訊息,因此您的網誌很可能不是垃圾網誌。 自動化垃圾網誌偵側尚不完善,對於造成這樣的錯誤,我們深感抱歉。
在我們的成員審查並確認您的網誌不是垃圾網誌後,我們才會關閉對您文章的強制字詞驗證。 請您填寫下面的表單以要求審查。
瞭解更多關於 Blogger 如何對抗垃圾網誌的資訊。