January 05, 2009

從中國山寨手機到美國山寨總統

專家觀點:從中國山寨手機到美國山寨總統
上網時間: 2009年01月05日
瞭解更多”ttp://www.google.com/reader/view/”
訂閱 加入我的最愛 打印版 推薦給同仁 發送查詢
相關文章

* 另類經濟奇蹟──細說中國“山寨製造”傳奇 (2008-09-17)

精選文章

* 編輯觀點:與其金援科技業 不如鼓勵研發
* 昔日為王今敗寇 細數日本晶片廠商沉浮
* 專家觀點:回顧漫長的MEMS商用化之路…

更多精選文章
2008年是全球性菁英偶像倒塌和平民化社會興起的標誌年份,在一系列天災人禍面前,中外菁英們的恐慌、愚蠢、貪婪、自私和懦弱讓人大跌眼鏡,而民間/草根力量和勇氣得以彰顯,山寨製造和山寨文化火爆正是這種時代背景下的產物。哪裡有山寨,哪裡就一定有官商和菁英壟斷;哪裡充斥著潛規則,哪裡就盛行江湖文化。解析山寨製造和文化,也是一個反思現代商業文明的過程,只有反思越徹底,就會越理解山寨製造和文化的過去、現在和未來。

歷史總是充滿吊詭。就好象前幾天一位元朋友所說,你我就好象台球桌上的各色彩球,當“某種神秘力量”舉杆擊球後,你我的運動軌跡和最後落點便已經注定,雖然整個過程顯得雜亂無章和跌宕起伏。對於每一個人來說,從來沒有哪一個年份象2008年一樣,你我的生活和整個國家甚至全世界如此緊密聯繫在一起,不論你是總統、金融巨頭、企業家、基金經理、股民、娛樂城老板、普通工人還是的士司機、大排檔老板甚至是站街女子。

回首2008年,哪些大事讓你記憶猶新?是讓百萬農民工兄弟姐們困在廣州火車站的冰雪風暴,是震撼和感動華人世界的汶川大地震受難同胞,是讓整個民族憤怒的“三鹿奶粉事件 ”中蒙牛、伊利等所謂中國品牌企業的真實面目,還是讓全世界都手足無措的“金融海嘯”和股市暴跌,或者是中國成功舉辦奧運會和迎來改革開放30年,還是奧巴馬成為美國歷史上首位元黑人總統?還是中國網民向西方媒體開炮?甚至是國內網際網路上有關山寨製造和山寨文化的熱烈討論?當然,還有反映明星糜爛生活的 “艷照門”事件?

對於個人來說,“山寨”是2008年我生活的關鍵詞:年初我從一家外資電子技術媒體跳到了一家深圳手機方案設計公司,工作地點從北京的高級寫字樓和酒店轉到了擁擠和嘈雜的深圳華強北,交流對象由舉止優雅、夾雜著英文的VP和CXO變成了滿嘴髒話、喜歡抽煙和泡功夫茶的“山寨英雄們”(山寨手機製造商的老板)。利用職業之便,我經常在華強北買一些山寨手機送給親朋好友們,看著60多歲的老人學會用觸控手寫功能發短消息給他的兒女們,喜歡唱歌的老人在床上用山寨手機錄製自己的歌聲到半夜…當然,作為一個曾經的媒體工作者,我也忍不住寫了一篇關於“深圳山寨製造興衰”的文章放在網上,並開始深入研究山寨製造和山寨文化以及它背後的政治、經濟、文化和技術源頭。

山寨背景:全球性的平民社會興起

我驚奇地發現,“山寨”不僅是我個人的關鍵詞,更是2008年全球性的關鍵詞,蘊涵著全球政治、經濟、文化和技術上的新趨勢。“山寨”的本質是什麼?是平民智慧和力量,是草根文化和精神,是2006年《時代》雜誌的年度封面人物“YOU”,是平凡的我,也是平凡的你,這在2008年表現得淋漓盡致。

回到本文開頭2008年的這些國內國外大事上。冰雪風暴和汶川大地震讓這個陶醉在“中國崛起”的浮躁民族冷靜了下來,重新意識到草根人群/普通人們生活依然艱辛,生命是如此的脆弱,讓我們暫時忘記股票和房子,重新關心身邊的人和同胞;同時,民間/草根力量在救災中表現出的美德和發揮的巨大作用,又讓整個國家感動和振奮。在奧運火炬傳遞期間,針對西方媒體對中國的固有偏見和不實報導,也是國內外的普通民眾自發組織起來進行揭露和批判,例如旨在收集、整理並發佈西方主流媒體作假誣陷中國的證據的非政府網站Anti-CNN.com,有數百名志願者報名參與網站的資料收集整理、翻譯、技術支援等工作。

事實上,過去30年的中國歷史,就是中國民間/草根力量覺醒和喚發的歷史。2008年北京奧運會,向全世界展示了中國改革開放30年的成果,展示了十幾億中國人為了現代化和融入世界文明所付出的努力──在西方世界的眼裡,中國何嘗又不是一個山寨式崛起呢,舉目望去,無論是中國城市建築、中國人的穿衣打扮和行為舉止,還是中國製造的產品,都充滿了山寨式的粗造、雜亂無章和風格怪異,集傳統、前現代、現代和後現代於一體。

如果說“無與倫比”的2008北京奧運會大幅提升了中國這個國家品牌,無形中也給所有中國企業品牌加了分的話,那麼2008年很多中國企業品牌則是給國家品牌減了分,抹了黑。“三鹿奶粉事件”狠狠地給了所謂的中國企業家一記耳光,蒙牛和伊利這些外表光鮮的中國品牌製造,竟然不如中國山寨製造;那些口若懸河的企業家菁英們,在人禍面前集體懦弱──30年過去了,中國品牌離世界級品牌依然遙遠,它們在北京奧運會期間“牛氣衝天”的廣告充其量不過是品牌幻影。

而在大洋彼岸,全世界最強大國家美國總統奧巴馬,在某種意義上來說,也是山寨製造──一是奧巴馬是美國歷史上首位元黑人總統,典型的草根種族;二是奧巴馬來自民主黨,相較代表大公司和有錢人利益的共和黨,民主黨更多代表中下層的利益;三是奧巴馬競選成功得益於重視Google、Facebook、 Myspace和YouTube等網際網路技術和網站,而網際網路又是草根人群聚集的地方──有點類似於我們“超級女聲”和“快樂男生”選秀的味道。在此前的2008年6月,中國的最高領導人胡錦濤和溫家寶在人民網上也有了自己的粉絲團“什錦八寶飯”,這既是他們親民的執政風格贏得普通老百姓的認同,也是中國政治的歷史性進步──領袖權威是來源於人們的支援和愛戴,而不是來自於神秘主義。

而拋開那些複雜的經濟理論,“金融海嘯 ”也可以從草根人群消費的角度上來解釋──這也是民主黨重新入主白宮和奧巴馬當選的主要原因。清華大學教授孫立平認為:“這場危機在美國是消費過度,並以過分膨脹的信用來支撐其過度的消費,在中國則是生產能力過剩,內部需求不足,消費不足”。而周斌則指出,次貸等所謂的金融創新實際上是一種空中樓閣的遊戲,其依靠美元的世界貨幣地位元徵收鑄幣稅,向全球借債消費的繁榮模式,相當於一個“龐氏騙局”,反正美國歸還給債權人的,始終是“美元白條”。

我淺薄地解釋一下,由於美國社會貧富兩極分化,普通老百姓本身並沒有能力維持體面的生活卻被金融家們硬撐(如次貸中大量底層美國民眾買房,過度鼓勵信用卡消費和及時享樂);而中國由於長期低工資、低福利和低社保體制,國內普通民眾消費能力嚴重不足,一直依賴於投資和出口給美國人消費,一旦美國出了問題,中國自己的問題也暴露了出來。換句話說,經濟危機的根本原因是生產能力過剩和消費需求不足,生產能力(企業和工廠)通常由富人掌握,而消費的卻是普通老百姓,因此經濟危機本質上是因為貧富兩極分化,即普通老百姓/草根人群沒有錢消費,無論是中國還是美國都是如此──簡而言之,經濟危機本質上就是脫離普通老百姓的虛假繁榮破滅。

透過上述政治、經濟和文化上的大事,可以看出,2008年是全球性菁英失語和平民化社會興起的標誌年份── 其中一些是因為重視草根獲得成功,另一些是因為漠視草根而受到懲罰。在地震、暴風雪、金融海嘯、毒奶粉這些天災人禍面前,無論是美國的金融和汽車巨頭,還是中國某些主管和企業家們,這些所謂的菁英們不但和普通老百姓一樣手足無措,而且他們所表現出的貪婪、自私、懦弱和不負責任,甚至超過普通老百姓。相反,草根/民間的力量、智慧和勇氣,卻讓社會感動和震撼。

也正是在這種菁英倒塌、平民興起的時代背景下,山寨製造和山寨文化迅速火爆起來。

在山寨手機一舉成名後,中國各行各業的“山寨化”樣本也迅速被網友們收集和挖掘出來,並在網際網路上廣泛傳播──最典型的就是天涯論壇上的帖子《這是一個全民產業學山寨的年代》。除了實體產業的真正“山寨化”外,《紐約時報》、春晚、電視劇《紅樓夢》、電影、明星、學者、壟斷國企等一系列代表菁英政治、經濟和文化的符號也相繼被文化意義上的“山寨化”──也就是在網際網路上被惡搞,形成獨特的“山寨文化”──可以在網上搜一下“盤點2008十大山寨事件”,保證讓你笑翻天。但笑過之後,我們會發現,除了少數是純粹出於搞笑和無厘頭外,多數被“山寨化”惡搞的對象都或多或少具有這些特點:壟斷、裝腔作勢、假權威、偽崇高、高高在上、一本正經、假公正、假菁英、不負責任……,網友們的惡搞是對它們“脫離群眾、假菁英”的無情嘲諷。

解讀山寨製造,反思現代商業文明

不過,隨著山寨手機、山寨製造及衍生的山寨文化在2008年達到頂峰的同時,有關它們的爭論也越顯激烈──贊同者津津樂道於它們的創新和草根精神,鼓吹是歷史的進步,是平民的勝利;反對者則抓住其踐踏知識產權和規避相關法律的原罪不放,斥之為文明的倒退,是社會的墮落。而當政者的態度曖昧,打擊和所謂的招安政策並存──例如在手機產業,2008年有關部門放鬆了牌照制度和簡化了入網認證,也在奧運會前夕對山寨手機進行了長達兩個月的嚴打,但後來又不了了之。

爭論歸爭論,實體經濟的“山寨化”依然高歌猛進,從最初的山寨手機漫延到數位元相機和平板電視,山寨上網筆記本的火爆也一觸即發。事實上,山寨化現象不僅在電子產業,也早已經在其他產業廣泛存在,甚至是一個全球化的產業現象。例如,服裝產業ZARA/H&M和山寨手機的成功秘密如出一轍;經濟型酒店就是酒店產業的山寨化;Google 和百度(連接無數小廣告商和網站)是網際網路廣告產業的山寨化;沃爾瑪銷售的大量無品牌產品和自有品牌百貨本質上就是山寨製造;淘寶網本質就是網上深圳華強北…而在文藝界,超女/快男(山寨藝人)、《一個饅頭引發的血案》/各類DV影片(山寨電影)、《百家講壇》(山寨學者)等山寨化現象也層出不窮。

從產品表現形式上來說,如果把品牌產品視為現代商業文明的結晶的話,那麼山寨製造則一方面是模仿,另一方面則是對現代商業文明的反叛和諷刺:山寨產品常常是前現代(成本低廉、做工略顯粗糙、無視知識產權保護)和後現代(網際網路,反菁英,誇張性模仿/無厘頭/惡搞)元素的結合。與此同時,山寨產業的產品定義 (低階產品也有豐富功能)、產品定價(一步到底)、品質要求(差不多就好)、產業分工和合作模式(群狼咬死猛虎)等,也不斷挑戰我們對現代商業文明的理解:品牌、品質和技術為先、知識產權保護、產品區隔定價、規模效應。

拋開對山寨的偏見和狂熱,從宏觀和微觀角度上更深入分析山寨製造和山寨文化,就會發現,表面上的灰色甚至違法因素其實只占它們成功原因的一小部份──所謂灰色大多是壟斷經濟環境下中國民營企業通常意義的原罪。它們的成功,更多是既順應和利用了全球政治、經濟、文化和技術上的發展趨勢,也反映了中國的特殊國情:全球性的“下流社會”化趨勢和新興消費者涌現,需要新的產品定義和定價模式,技術成熟、中國企業研發和管理能力落後、社會資訊化程度提高,推動新的產業分工和合作模式…我再一次驚奇地發現,在赤裸裸侵犯知識產權和血淋淋價格戰同時,山寨製造身上也隱現目前最新的經營理念實踐──如“長尾理論”和“維基經濟學”等。

山寨製造和山寨文化,是曇花一現還是會愈演愈烈?這是過去幾個月來我被問得最多的問題──事後分析總是能夠自圓其說,能夠預測未來才是真正的高手。坦率地說,我不是高手,我不能夠預測未來,但我想以一個很空虛的反問代替我的回答:現代商業文明/商業模式,是設立在幾億歐美人現代化的成功經驗基礎上,但是能夠承載(亞非拉美國家)幾十億人的現代化嗎?──山寨化的時代背景正是亞非拉美國家幾十億人的現代化進程。歐美國家的生產和消費模式,是理所當然和不變的真理,還是我們可能需要另一條道路?或者說,是否有一條介於傳統和山寨間的新道路?

對山寨製造和山寨文化最嚴厲的批評通常是,它們違反遊戲規則甚至是法律──確實,這是它們的原罪,是它們成功的法寶,但也可能是未來葬送自己的禍根,所謂“革命者被革命”。不過,當成千上萬的人爭先恐後去打破規則的時候──例如30年前大量偷偷摸摸搞“家庭聯產承包責任制”的安徽小崗村農民,例如當年成千上萬的廣東人逃往香港;通常我們需要反思兩點:一是所謂的規則,是不是只是台面上的規則,台面下還有潛規則,只要不打破潛規則,大家就可以心照不宣?二是所謂規則的合理性,是否值得反思,是否反映了普通人的利益,是否需要改變?

舉一個我個人的例子。在北京工作和生活兩年間的飯局上,我多次聽到這樣段子,證明一個人在北京混得還行,有三樣:入學,家裡有小孩子,能夠順利入學;看病,家裡有病人,能夠在大點醫院掛得上號;撈人,家裡有人犯了事,能夠在局子裡把人撈出來。雖然我一直還為自己是一個勤奮努力工作的人感到自豪,但每次我聽到這個段子,都覺得自己很失敗──但願這只是我個人的失敗。入學和撈人我沒有遇到過,但是我卻有好幾次清晨四點起床去大醫院掛號看病的經歷。當我一路咒罵著趕到醫院,看著醫院裡早排滿了來自全國各地的人,很多都是滿眼悲傷、疲憊夾雜著麻木的農民,我的情緒也由咒罵變成悲哀和嘆息,對黑診所/山寨醫院為何屢禁不止也有所理解了。

你我都還不算是社會最底層的人,但我們的生活已經如此艱難,那些最底層的人生活又會如何呢?所以我的朋友張國斌一直告誡某些菁英們,在評論“山寨製造”和山寨文化前一定要“對普通大眾懷有一顆關懷和慈悲之心”。在知名樂評人王小峰關於“狗仔隊”的最新DV電影《你丫真狠》中,“狗仔隊”有這樣一段這樣讓人發笑但又讓人辛酸的台詞──你說我不挺身而出,咱老百姓看什麼啊,咱老百姓沒有啥追求,房子買不起,小汽車坐不起,高級酒店住不起,二奶包不起,情人養不起,都混到這份上了,你讓大家意淫一下,有什麼不好啊?

所以,有人說山寨產品利用了普通老百姓的“俗氣”──例如喜歡假寶石手機、跑車手機和大喇叭手機等等,更是顯得可笑。當我們的某些主管還停留在出國賭博和嫖妓,當中上層菁英還停留在喝紅酒加雪碧喝芝華士加綠茶、住三流西式洋樓、抖富和及時行樂的時候,為何對普通老百姓要求那麼高呢──事實上,草根人群的消費和行為模式,說到底是對他所接觸到的“菁英層”的模仿,在一個家庭中,是子女對父母的模仿,在一個公司裡,是員工對老板的模仿…因此如果說草根人群“俗”的話,那麼根源也是在所謂的菁英層那裡。在知名學者陳丹青的《退步集》裡,我們看到了一副“穿西裝打領帶的農村青年”的照片,邊上的注解是“他仿效的並非是真的香港人或西方人,而是本村第一個穿西裝打領帶的人”。

哪裡有山寨,哪裡就一定有菁英壟斷和官商;哪裡充斥著潛規則,哪裡就盛行江湖文化。如果說山寨製造和山寨文化是“惡之花”,那麼“惡”也可能隱藏在現代商業文明中。就好象我認為大人教育小孩子的同時也應該是一個自我反省和自我教育的過程──極端地說,小孩子所有的問題,都是大人的問題,都可以在大人身上找到根源,越反省和檢討自己,才能夠越理解自己的孩子。無論是善還是惡,山寨也是現代商業文明中的一個產物,深入解析山寨製造,同時也是一個反思現代商業文明的過程,只有反思越徹底,就會越理解山寨製造的過去、現在和未來。

最後總結一下,山寨文化的核心,是新平民社會裡草根人群對菁英政治、商業和文化的諷刺和反叛當然也夾雜著向往,是草根人群渴望被關注、平等參與和共享現代文明的另類表達,而山寨製造正是這種時代背景下的產物。山寨製造和山寨文化,是現代菁英文化/商業模式在新\平民時代遭遇的最初尷尬。儘管山寨和菁英目前打得難解難分,但它們正一起孕育新經濟、文化和技術背景下的新商業模式──因為說到底,山寨和菁英其實是前世和今生的關係,互為因果,互為彼此。

(本文轉載自《國際電子商情》網站,作者潘九堂自稱是南方農民工,飄忽在山寨與書房之間,目前在一本正經研究山寨製造和山寨文化。本文僅代表個人觀點,歡迎各行各業的朋友和作者探討山寨化現象,他的郵件是panjiutang@gmail.com)

主要參考書目和文章

1. 謝來/與網路為伍成就美國夢/新京報/2008年12月14日

http://www.thebeijingnews.com/news/dqzk/2008/12-14/008@081215.htm

2. 孫立平/《以重建社會跨過經濟大坎兒》/南方周末/2008年12月17日

http://www.infzm.com/content/21314/1

3. 周斌/《下一次繁榮的基礎》/21世紀經濟報導/2008年12月20

http://www.21cbh.com/HTML/2008/12/20/HTML_XBHE5HWO06IE.html

4. 李欣藍/《這是一個全民產業學山寨的年代》/天涯論壇/2008年9月21日

http://cache.tianya.cn/publicforum/content/develop/1/177532.shtml

5. 馬克/沒有國家品牌,就沒有企業品牌──專訪聯想控股公司總裁柳傳志/南方周末

http://www.infzm.com/content/21333/0

Posted by hufey at 11:13 AM | Comments (0)

November 25, 2008

收藏:说说山寨机

说说山寨机

最早山寨机和联发科是儿子和老子关系, 联科发除了芯片设计以外 其他诸如外观 线路板等的设计都包圆.山寨机厂找联发科买BOM(物料清单),大到LCD 主板 小到固定螺丝都必须从联发科指定的厂家购买(大多是台资厂),所以最早的山寨机不光价格贵 而且基本是对市场上主流机型的模仿 市场反映比联发科预期的低很多.

后来几个规模稍大的山寨机厂从武汉烽火(以前的武汉NEC是烽火和NEC合资的手机厂 里面有个中国人为主的设计团队)挖来了个设计团队来根据山寨机厂的要求做外观设计,这个公司在赛格大厦旁边的中电大厦里.起初他们只是根据山寨机厂的要求 做外观,后来为了降低物料成本自己搞线路板设计.大家知道,手机最贵的东西是LCD和主板,主板上的大多数元器件都能从国内找到厂家(0201的片阻片容 有风华和振华, 连接器有实赢 LCD有Wintek BYD等),通过这家设计公司元器件国产化设计后山寨机成本下降很多,而且外观上也有不少贴近市场需求的设计,让山寨机抢了不少市场.(他们设计的一款手 机曾经在安徽的县乡市场1个月卖出过19000台,好销的原因一是按键够大 二是那手机屁股上有个大号发光二极管 农村没路灯 天黑以后可以做手电筒用)

后 来 南方高科关门后又多出了个做手机设计公司,再加近几年从上富士康 BYD(都是Nokia MOTO代工工厂)跳槽出来的设计团队加入这个市场,现在山寨机的设计除了芯片以外基本都是这些土生土长的土鳖设计人员在搞(据我知道 深圳中电大厦就有4家这样的公司 规模最大的百人规模,最小的20人不到).简单说就是这些设计公司企划产品(需要什么外形 什么功能 什么价位) 然后让联发科进行功能开发 交给山寨机厂生产.几家规模大的山寨机厂都有参股这几个设计公司,而设计公司也参与销售分成(好卖的机型设计公司多拿 不好卖的设计公司收入也少).比如说 彩铃是”我已出仓 感觉良好”的神7手机 和前几天有人贴出来的军用手机就是这些公司整出来的产品.

另外,几家有名的山寨机网站其实就是这些设计公司搞的,上面的好多机型根本是只有工程样机的产品,到底要量产哪个完全是根据市场反应来决定的.

已经有业内消息说某家设计公司从联发科挖角 张罗着自己设计芯片 希望能早日看到国内设计公司设计 SMIC代工的芯片上市.

山 寨机瞄准的市场根本就不是北京上海广州深圳这样的一线城市,他们自己清楚现在跟Nokia们在一线城市过招那是找死,这些设计公司的目标是为数众多的县 乡 镇市场,耐用 电池超长待机 价格便宜比相机像素高低等更容易拿到这个市场.国内的山寨机大家都知道,我说这些山寨机的第二大市场是印尼 你信吗?几家大山寨厂8月份销往印尼的数量已经超多10万台了.

山寨机厂家鱼龙混杂 因为这个行业的入门门槛现在很低,基本上设备投资200万 外加几十万的周转资金就能做山寨机,过去几年出现了很多这样的山寨作坊 也死了一大批.现在珠三角上规模的(5--10条SMT线)有8 9家,这几家是拼出来的,能活到今天 能活的比别人好的山寨厂都有自己的绝招.千万别小看这些可能只有小学毕业水平的潮汕”企业家”.在一个客户那里看到过,老板给工人开会时候手里拿着 本<<华为的狼文化>>,要他的员工都看这书.相信几年以后山寨机行业会有类似生产队 ZTE这样的”大企业”出现.憧憬下吧,以后生产队 ZTE先在广大亚非拉国家布网,土鳖山寨机后让亚非拉穷兄弟享受信息社会 美好啊.

山 寨机的质量到底怎么样呢?从跟我有业务几家的情况来说,规模稍大的山寨厂的技术人员来自已经关门深圳优力电(日资) 南方高科 还有富士康 BYD这些代工厂出来的;元器件基本跟几家代工厂用的是一样的东西.IPHONE刚上市没几天就有跟它外形相似的山寨机出现,上网看了下 确是很像啊.后来问过才知道 山寨机外壳的模具就是做IPHONE模具那家模具厂做的 没法不像啊,模具厂怕出问题,给山寨厂做的模具上做了修改 LCD尺寸比IPHONE大点 四角的切角尺寸小点,再就是山寨厂用的塑胶原料比IPHONE差.这样的例子还有很多很多.

当然 根本没质量管理意识的山寨厂有 但是也有质量管理意识超出我这个在日本公司混了7年的人意料的山寨厂.屏山的一个厂 老板是潮州人 厂长是有利电出来的.他们生产线上的作业指导书比我在东京Hino的Toshiba工厂(专门生产日本国内销售3G手机的工厂)见到的不差,作业要点用图 片标明 OK/NG判定条件清楚,而且每周一拿出上周一周的QC报表统计出上周不良率最高的三项不良(空焊 移位等),然后具体到SMT操作员 执锡工 要求写出降低三项不良的对策,那本每周质量对策汇编现在比新华词典还厚 他们的质量也提升了不少.

想写的不少 可文笔差 表达不出来 呵呵 没有吹嘘山寨无敌的意思 想大家能有个比较近的视角观察下山寨机而已.

Posted by hufey at 10:55 AM | Comments (0)

November 07, 2008

馬達控制設計


上網時間: 2008年11月07日
驅動馬達時最佳的開關頻率?
所謂的最佳頻率,就是在實現可接受效率、電流紋波、EMI性能的同時,仍能在安全操作範圍內持續驅動設備的最高頻率。開關頻率通常依上述條件來選擇。

中心對齊與邊緣對齊PWM訊號有何不同?

在邊緣對齊多相PWM控制中,所有相位都會同時開啟,但關閉則取決於每相位工作週期上的不同時間。多個大電流相位同時開關會導致更大的EMI瞬變,其影響遠較相位永遠在不同時間改變來得大。透過啟動PWM輸出,中心對齊開關解決了EMI問題,使得中心的所有活動週期均趨於一致。對每個相位輸出來說,在中心對齊參考點之前只有一半的工作週期發生。

什麼是死區時間控制?

死區時間是測量從連接到一個電源軌上的驅動器開關關閉時,到連接在電源另一條軌上的開關接通時的延遲時間。

我為何需要互補輸出?

互補輸出是針對高端與低端開關提供替換驅動所必需的。BLDC馬達每轉一圈,每個相位的驅動電流方向便會改變兩次。這必須使連接在該相位端的驅動電壓改變方向。這種電壓換向是將每個相位端通過分離式MOSFET或IGBT驅動器,並連接到電源的正向輸出和負向輸出來實現的。當一個驅動器接通時,另一個關閉,這就代表著它們是需要互補驅動輸入的互補驅動器。

什麼是三相或四相PWM?

內容:三相脈寬調變器(PWM)由三個輸出組成(或是互補驅動時為三對輸出),每個輸出均提供獨立的脈寬調變訊號。各自獨立的輸出使類比三相系統的模擬成為可能,而每個輸出上的有效電壓電平都是取決於脈衝工作週期的平均電壓。四相PWM就是將三相PWM中的相位數改為四個。

在三相PWM系統中A/D與事件能同步嗎?

可以。

什麼是無感測器馬達?

無感測器馬達應用並非真正的無感測器,它主要透過從其他反饋源取得位置與速度資訊來免除對一個或更多反饋感測器的需求。無感測器控制是無刷馬達的一種選項。一個無感測器BLDC應用意味著使用馬達上未通電繞阻的電壓感應來獲得轉子位置。

如何感測馬達位置或速度?需要幾個感測器?

可利用光學編碼器、解算器或其它元件如霍爾效應感測器來進行位置與速度的感測。通常每個馬達要使用一個感測器,以用於反饋。

開環控制的應用場合?

開環控制可用在對馬達速度要求不高且無需進行精確定位的系統中。開環控制也可與步進馬達聯用進行位置控制。

開環╱閉環是什麼意思?

開環是無反饋控制。閉環控制會將馬達的電流、速度或位置反饋資訊與所需的值進行比較,並產生修正命令減小誤差。

資料來源:Microchip Technology

Posted by hufey at 12:52 AM | Comments (0)

July 28, 2008

存个图


来自apple4.us

Posted by hufey at 12:50 AM | Comments (0)

April 15, 2008

可重入函数列表

信号处理程序中应当使用可再入(可重入)函数(注:所谓可重入函数是指一个可以被多个任务调用的过程,任务在调用时不必担心数据是否会出错)。因为进程在收到信号后,就将跳转到信号处理函数去接着执行。如果信号处理函数中使用了不可重入函数,那么信号处理函数可能会修改原来进程中不应该被修改的数据,这样进程从信号处理函数中返回接着执行时,可能会出现不可预料的后果。不可再入函数在信号处理函数中被视为不安全函数。

满足下列条件的函数多数是不可再入的:(1)使用静态的数据结构,如getlogin(),gmtime(),getgrgid(),getgrnam (),getpwuid()以及getpwnam()等等;(2)函数实现时,调用了malloc()或者free()函数;(3)实现时使用了标准 I/O函数的。The Open Group视下列函数为可再入的:
_exit()、 access()、alarm()、cfgetispeed()、cfgetospeed()、cfsetispeed()、cfsetospeed ()、chdir()、chmod()、chown()、close()、creat()、dup()、dup2()、execle()、execve()、fcntl()、fork()、fpathconf ()、fstat()、fsync()、getegid()、 geteuid()、getgid()、getgroups()、getpgrp()、getpid()、getppid()、getuid()、 kill()、link()、lseek()、mkdir()、mkfifo()、 open()、pathconf()、pause()、pipe()、raise()、read()、rename()、rmdir()、setgid ()、setpgid()、setsid()、setuid()、 sigaction()、sigaddset()、sigdelset()、sigemptyset()、sigfillset()、 sigismember()、signal()、sigpending()、sigprocmask()、sigsuspend()、sleep()、 stat()、sysconf()、tcdrain()、tcflow()、tcflush()、tcgetattr()、tcgetpgrp()、 tcsendbreak()、tcsetattr()、tcsetpgrp()、time()、times()、 umask()、uname()、unlink()、utime()、wait()、waitpid()、write()。

即使信号处理函数使用的都是"安全函数",同样要注意进入处理函数时,首先要保存errno的值,结束时,再恢复原值。因为,信号处理过程中,errno值随时可能被改变。另外,longjmp()以及siglongjmp()没有被列为可再入函数,因为不能保证紧接着两个函数的其它调用是安全的。

摘自developerworks

Posted by hufey at 12:31 AM | Comments (0)

April 01, 2008

logs vs journaling

一直没想过log文件系统和journaling文件系统之间有什么区别。实际上根本就不懂,以为是一回事。其实区别很大,别看中文往往都翻译成日志文件系统

There have been several approaches of implementing
file system consistency; log structured
file system [11] or journaling file system [2].
In log structured file system, all operations are
logged to disk drive. File system is structured
as logs of consequent file system update operations.
Journaling is to store operations on
separate journal space before updating the file
system. Journaling file system writes twice (to
journal space and file system) while log structured
file system does write once. However
journaling approach is popular because it can
upgrade existing non-journaling file system to
journaling file system without losing or rewriting
the existing contents.

Posted by hufey at 03:19 PM | Comments (0)

March 27, 2008

TOP15 科幻小说系列

存档,打算在有生之年看完,不知道能不能完成这个任务

>TOP15 科幻小说系列
matrix 发表于 2008年3月27日 08时30分 星期四 Printer-friendly Email story
来自平行宇宙部门
书籍
当你读完一本精彩的科幻小说,了解到这只是系列小说的第一本,一定会感到特别的兴奋。科幻界的一些最伟大头脑用连续小说的形式为他们故事的角色构造了一个复杂而惊心动魄的宇宙,还有一些则虚构了地球的反乌托邦或乌托邦的未来。这里列出的就是最棒的科幻小说系列,虽然为它们排名是困难的任务。
15.《Vorkosigan传奇》:故事主人公Miles Vorkosigan是Barrayar 星球上的一位无能的贵族,他的整个生命都在挑战本星球对“突变异种”的偏见。该系列有多本获得过雨果奖最佳小说。
14.《The Book of the New Sun》:一位慈悲的刑讯者,为了让受害者避免痛苦的折磨,他容许她自杀。最后被流放,去寻找真理和忏悔,这个角色具有救世主的特征,他最终将拯救地球。
13.《海伯利安四部曲》:让时间倒流的时间冢与人工智能终极杀器伯劳鸟,丹西蒙斯在书中描述了一个人类与AI的可怕未来。《海伯利安》获雨果奖,《海伯利安的陨落》获星云奖最佳小说提名。
12.《太空漫游系列》:由于电影《2001:太空漫游》的成功而成为最为知名的系列。
11.《文明(The Culture)》:一个无政府主义、社会主义和乌托邦式的未来社会,没有贫穷、死亡和疾病。小说主要描述了社会边缘群体:外交官、间谍和雇佣兵,都是干脏活的。
10.《Rama系列》:阿瑟克拉克的《与拉玛相会》讲的一艘外星飞船突然出现在太阳系,人类与外星生命相遇的故事。获得雨果和星云奖,是公认的经典之作。但后面的系列主要由Gentry Lee执笔,克拉克主要是审查和编辑,评价不是很高。
9.《沙丘系列》:系列的第一本《沙丘》曾被大卫林奇怕成电影,一部跨越时间达16000年的涉及社会、政治和宗教的史诗。
8.《Heechee Saga》:HeeChee是一个极为先进的恒星旅行种族,早在几百万年前就到达了太阳系,在人类开始宇宙探索前没有留下任何痕迹的消失了。
7.《银河系漫游指南》:源自BBC的广播剧,亚当斯在写第一本书的时候就意识到需要在地球上增加一个外星人,提供背景知识,就是那位《银河系漫游指南》书的编辑。
6.《环形世界 》:两个地球人和两个外星人一起探索一个神秘的”环形世界“——一个人造的环形建筑物,围绕在一颗恒星周围,内表面可居住,面积相当于300万个地球。获得了1970年星云和雨果奖。
5.《Ender’s Game Series》: 始于一篇短篇小说Ender’s Game,最终发展成一系列包含9部长篇,10部短篇,还有两部等待出版。系列的前两部获得星云和雨果奖。被认为1980年代最有影响力的科幻小说之一。主要角色是Andrew “Ender” Wiggin,一位童子兵,在一所战争学校受训成为地球的未来领袖。
4.《未来历史系列》:海因莱因的这套书中最好的两本是《The Man Who Sold The Moon》和《时间足够你爱》,描述了人类从20世纪中期到23世纪早期的未来历史。
3.《Barsoom系列》:这套诞生于20世纪早期的小说虽然内容可能过时了,但影响了后世的许多电影和科幻小说。《火星公主》可能是20世纪最早的幻想作品。
2.《Lensman系列》:该系列起始于20亿年前,一个和平的种族Arisian 能以其它种族无法实现的方式理解生命和生命力,他们创造一个类似透镜的东西能赋予穿戴者特殊的精神能力,可以在外星球上根据需要执法和在不同种族之间建立交流桥梁。
1.《基地系列》:阿西莫夫的7卷银河史诗,横跨千年,该系列书的完成也花了44年。小说中最主要的设定是一位科学家开发了数学的一门分支——心理史学,能够预测未来大多数人类的行为。

《基地》《时间足够你爱》《环形世界》《银河系漫游指南》《沙丘》《海伯利安》《海伯利安的陨落》等都有中文版,但许多系列都没有出全。

Posted by hufey at 11:08 AM | Comments (0)

February 14, 2008

git pull出fatal: Entry ... not update, cannot merge的解决

先git diff xxx看是不是自己改了什么东西
如果改不回来可以用git reset --hard重置来解决这个问题

Posted by hufey at 01:41 PM | Comments (0)

November 04, 2007

First quarter 2005 smartphone shipments, by OS. Source: Gartner


Posted by hufey at 12:14 PM | Comments (0)

October 19, 2007

ssh登录后的X DISPLAY自动forwarding

在server 端的/etc/ssh/sshd_config中打开
X11Forwarding yes
在client端的/etc/ssh/ssh_config中打开
ForwardX11 yes

Posted by hufey at 02:18 PM | Comments (0)

August 28, 2007

minicom不能输入的问题

把流控去掉试试
Ctrl +A -> Z -> O -> serial port setup -> F, G
save setup as dfl

Posted by hufey at 11:24 AM | Comments (0)

August 23, 2007

ubuntu英文环境下中文显示小方块的解决

只要执行sudo fontconfig-voodoo -f -s zh_CN即可
google“ubuntu 英文环境 中文 方块“ 出来的大部分都跟这个没关系

Posted by hufey at 10:38 PM | Comments (0)

August 22, 2007

rpm 查询未安装的包

rpm -qpl package.rpm

TMD,这个命令老也记不住

Posted by hufey at 03:10 PM | Comments (0)

August 09, 2007

gcc和g++到底有什么区别?

今天编译一个很普通的C++程序,如下:

1  #include 《iostream》 
2 
3  void function1(){ 
4     for(int i=0;i<1000000;i++); 
5  } 
6 
7  void function2(){ 
8     function1(); 
9     for (int i=0;i<2000000;i++); 
10 } 
11 
12 void function3(){ 
13    function1(); 
14    function2(); 
15    for (int i=0;i<3000000;i++); 
16       function1(); 
17 } 
18 
19 int main(){ 
20    for(int i=0;i<10;i++) 
21    function1(); 
22 
23    for (int i=0;i<5000000;i++); 
24 
25    for(int i=0;i<10;i++) 
26       function2(); 
27       for(int i=0; i<13;i++); 
28          { 
29          function3(); 
30          function2(); 
31          function1(); 
32          } 
33 }


编译命令行: gcc -pg -o sample3 sample3.cpp
结果是:

/tmp/cck9wDpZ.o: In function `__static_initialization_and_destruction_0(int, int)':
sample3.cpp:(.text+0x12c): undefined reference to `std::ios_base::Init::Init()'
/tmp/cck9wDpZ.o: In function `__tcf_0':
sample3.cpp:(.text+0x183): undefined reference to `std::ios_base::Init::~Init()'
/tmp/cck9wDpZ.o:(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
以前因为工作内容的关系,没用gcc编译过c++的代码。或者是其他同事已经写好了Makefile,没怎么关心过这个问题。不过以前和一个同事争论过,他说c++的代码必须要用g++编译,否则编译不过去,因为gcc是编译c code的,而g++才是编译c++的。我当时就知道肯定不对,因为gcc是gnu compiler collection的缩写,而不是gnu C compiler。理论上所有的gcc支持的不同语言的代码都可以用gcc编译(如果我错了请纠正我)。当时没空争论这个问题,结果今天自己碰上了 。google了一下,又试了试,确实用g++可以编译过去
g++ -pg -o sample3 sample3.cpp 不服不服,继续尝试发现用gcc也可以,不过要加上指定的标准c++库 如下:
gcc -pg -o sample3 sample3.cpp -lstdc++ 所以,gcc是可以编译c++ 代码的,g++不过是隐含链接某些库
Posted by hufey at 03:05 PM | Comments (0)

July 24, 2007

Working SSH Instructions by NerveGas

Working SSH Instructions by NerveGas

Previous instructions on the net have required the use of restore mode to set
binary permissions. Unfortunately, restore mode doesn't work with all public
versions of iPhoneInterface I've tried. The instructions below work by
overwriting an existing binary on the system with chmod, and then calling it
with the appropriate arguments to set permissions. The result is a fully
functional SSH setup. You can then proceed to uploading your own world builds,
or other programs to execute via commandline.

Step 1: Key Creation

On your Mac or PC, download dropbear from here:

http://matt.ucc.asn.au/dropbear/dropbear.html

Run: ./configure && make

You don't need to install the software, just run:

./dropbearkey -t rsa -f dropbear_rsa_host_key
./dropbearkey -t dss -f dropbear_dss_host_key

And copy the two new key files into your iPhoneInterface directory.

Step 2: Uploading dropbear and friends

Download the iphone-ssh kit and the iphone binaries kit:

http://www.abigato.com/iphone-ssh-kit-vr1.tar.bz2
http://netkas.freeflux.net/blog/

Rename sh6 from the kit to sh.

Use the jailbreak application to break out of jail, and then open
iPhoneInterface to connect.

mkdir /etc/dropbear
cd /etc/dropbear
putfile dropbear_rsa_host_key
putfile dropbear_dss_host_key
cd /bin
putfile chmod
putfile sh
cd /usr/bin
putfile dropbear

Step 3: Overwriting 'update' with 'chmod'

While still connected to iPhoneInterface, make a backup copy of
/usr/sbin/update:

cd /usr/sbin
getfile update

Rename this to update.original on your local filesystem

Now copy the 'chmod' binary to 'update' and upload it back to the
iPhone:

cd /usr/sbin
putfile update


Step 4: Overwriting the update configuration

Now the 'update' binary is really 'chmod', and has execute permissions! We
just need to tell the iPhone to chmod next time it boots. To do this, we
download /System/Library/LaunchDaemons/com.apple.update.plist and add our
own arguments to ProgramArguments:

0 /usr/sbin/update
1 555
2 /bin/chmod
3 /bin/sh
4 /usr/bin/dropbear

Save the new plist and upload it back to the iPhone:

cd /System/Library/LaunchDaemons
putfile com.apple.update.plist

While we're here, lets also:

putfile au.asn.ucc.matt.dropbear.plist

Step 5: Reboot the iPhone twice.

The first reboot should set the permissions on the dropbear and related
binaries. The second reboot should start dropbear, so you can ssh to it:

ssh -l root [IP ADDRESS]
The root password is 'dottie'.


Step 6: Replace the original update and com.apple.update.plist files

Don't forget to put the old update files back. Rename update.original back
to update, and delete the extra ProgramArguments you added to
com.apple.update.plist. Now put them back:

cd /System/Library/LaunchDaemons
putfile com.apple.update.plist

cd /usr/sbin
putfile update

Step 7: Change the root password

If you don't like 'dottie', you can generate a new encrypted password
by running:

perl -e 'print crypt("MYPASSWORD", "XU");'

Where MYPASSWORD is the new password you want, and XU is a random two-letter
salt. Copy the encrypted output and replace the existing one in
/etc/master.passwd on the phone.

You're done! Enjoy!
-NerveGas

Posted by hufey at 02:04 PM | Comments (0)

July 04, 2007

折腾mplayer在osx上到半夜两点

realplayer在我的G4上坏了有一段时间。 mac osx在应该是他最擅长的多媒体播放上也远不是完美。最开始发现某些avi文件用vlc播放的时候会导致系统假死,渐渐的感觉规律是在播放的时候系统掉电然后当时播放的文件会有数据错误,这些都是猜测,以后有空拿md5sum检查一下是不是这样的。总之电影看着非常不爽,只好跳过那一小段。 再后来发现用rmvb也有类似的问题,在mac下一直用realplayer看rmvb,在linux下倒是一直用mplayer。因为mplayer的界面在osx下实在太简陋,远不如VLC,而linux下简陋是一种习惯,无所谓了。直到某天升级realplayer之后,realplayer再也不工作了。点了之后在任务栏上闪了闪,然后就一股青烟,没有了。在terminal上执行realplayer看到的segment fault,后来还看到过bus error。奇怪启动应用程序居然会导致bus error。重装了N次不同版本的realplayer始终解决不了问题。google也没有任何有用的信息,osx用的人还是太少。总基数太少还是osx太稳定导致没有有用信息这我就不知道了。倒是在国内的一个论坛上看到有人有类似的问题。rmvb虽然看得不多,但是国产电视剧还是在用这个格式。最后决定还是想想辙吧。mplayer既然能在linux/windows下播放所有的格式,在osx下播放rmvb自然也不在话下。下载了所有的codec,解压缩,发现README里说明所有codec要放在/usr/local/lib/mplayer下,但是osx下没发现/usr目录。最后google中文"mplayer osx codec 安装“,发现原来/usr在osx下是有的,只不过隐藏了起来。在terminal下ls都可以看到,在Finder里是看不到的,cp自然要sudo,不提了。最后终于成功用mplayer播放rmvb。于是删掉realplayer,不用它了,永远。

Posted by hufey at 11:04 AM | Comments (0)

May 10, 2007

最新的mac系统快捷键一览表

http://docs.info.apple.com/article.html?artnum=75459

最新的mac系统快捷键一览表!要成为高手请看!

中文版看这儿:

系统固定快捷键,Mac OS X适用

动作 快捷键

停止进程 Command + period
强制退出应用程序 Command + Option + Escape
强制重新启动 Command + Ctrl + 电源 key


屏幕捕捉

动作 保存为 快捷键

整个屏幕 PDF 格式在桌面 Command + Shift + 3
部分屏幕 PDF 格式在桌面 Command + Shift + 4
窗口/图标 PDF 格式在桌面 1. Command + Shift + 4
2. 空格
整个屏幕 剪贴板 Ctrl + Command + Shift + 3
部分屏幕 剪贴板 Ctrl + Command + Shift + 4
窗口/图标 剪贴板 1. Ctrl + Command + Shift + 4
2. 空格

屏幕快照的格式可以自Onyx等系统维护程序中更改为jpeg,png等。

计算机启动

动作 快捷键

启动到安全模式 Shift (在开机声音后)
打开登录窗口 Shift (当屏幕变成蓝色以后)
并闭打开的窗口 Shift (登录过程中)
从光盘启动 c
选择启动磁盘 Option
重置 Parameter RAM Command + Option + p + r
启动到 verbose 模式 Command + v
启动为单用户模式 Command + s
打开固件 Command + Shift + o + f
火线连接方式 t

Com或者command就是指的命令键(苹果键/花键)啦。

Dashboard F12
Finder 快捷键

动作 快捷键

隐藏 Finder Command + h
隐藏其它 Command + Option + h
清空废纸篓 Command + Shift + Delete
清空废纸篓 (不提示) Command + Option + Shift + Delete
获取信息 (静态窗口) Command + i
获取信息 (动态窗口) Command + Option + i
查找 ... Command + f
弹出 Command + e
查看显示选项 Command + j
转到计算机 Command + Shift + c
转到个人主目录 Command + Shift + h
转到 iDisk Command + Shift + i
转到应用程序目录 Command + Shift + a
转到个人收藏 Command + Shift + f
转到目录 ... Command + Shift + g
连接到服务器 ... Command + k
注销... Command + Shift + q
注销 (不提示) Command + Option + Shift + q

这一段能默写下来的,算你狠。。。。。。

Finder中有关图标的快捷键

动作 快捷键

选择下一图标 Arrow keys
选择图标名字的首字母 Letter key
选择下一个(字母顺序) Tab
添加图标到选择的项目 Shift + click
选择相邻的图标 (列表显示) Shift + click
选择不相邻的图标 (列表显示) Command + click
编辑图标名字 Return

文件及目录快捷键

动作 快捷键

拷贝项目 Option + 拖拉
原位复制 Command + d
创建替身(拖拉方式) Command + Option + 拖拉
创建替身(命令方式) Command + l (L)
显示原身位置 Command + r
添加到个人收藏 Command + t
对齐项目 Command + 拖拉
在单独的窗口中打开目录 Command + 双击
打开项目 Command + Down Arrow
关闭目录 (转到上层目录) Command + Up Arrow
打开目录 (列表显示) Option + Right Arrow
关闭目录 (列表显示) Option + Left Arrow
打开选择的目录中的所有目录 (列表显示) Command + Option + Right Arrow
关闭选择的目录中的所有目录 (列表显示) Command + Option + Left Arrow
删除项目 Command + Delete

窗口快捷键

动作 快捷键

新 Finder 窗口 Command + n
关闭当前窗口 Command + w
最小化当前窗口 Command + m
关闭所有窗口 Option + click close button
最小化所有窗口 Option + click minimize button
适合屏幕 Option + click zoom button
隐藏应用程序 Option + click (Desktop, Dock item, ...)
移动一个非当前窗口 Command + 拖拉窗口
查看路径 Command + 点击窗口标题
图标显示 Command + 1
列表显示 Command + 2
分栏显示 Command + 3
隐藏/显示栏 Command + b

dock快捷键

动作 快捷键

在 Finder 中显示项目 Command + click dock item
切换dock (全键盘操作) Ctrl + d
导航 (全键盘操作) Arrow Left, Arrow Right or Tab, Shift + Tab
打开项目 Space, Return, Enter
隐藏/显示Dock Command + Option + d

用户进程快捷键

动作 动作

查看活动的用户程序 Command + Tab
往回查看活动的用户程序 Command + Shift + Tab

对话框快捷键

动作 快捷键

选择下一区域 Tab
选择默认按钮 Return or Enter
关闭提示 Esc or Command + period
选择上层或者下层目录(保存/打开) Up Arrow, Down Arrow
向上滚动 (列表) Page up
向下滚动 (列表) Page down

全键盘操作

动作 快捷键

打开全键盘操作 Ctrl + F1
提示以及窗口任意控制 Ctrl + F7
高亮下一控制 Tab
高亮下一控制 (文本框) Ctrl + Tab
高亮下一窗口 Command + `
高亮在列表, 标签组或菜单中的项目 Arrow keys
移动滚动条 Arrow keys
高亮文本框相邻的控制 Ctrl + Arrow keys

选择高亮项目 Space bar
选择默认按钮 Return or Enter
点击取消按钮 Esc
不选择项目关闭菜单 Esc
反转高亮移动的顺序 Shift + "key"


动作(使用功能键) 快捷键

菜单条 Ctrl + F2
Dock Ctrl + F3
浏览窗口 Ctrl + F4 (Ctrl + Shift + F4)
工具栏 Ctrl + F5
实用程序窗口 Ctrl + F6

动作 (使用字母键) 快捷键

菜单条 Ctrl + m
Dock Ctrl + d
浏览窗口 Ctrl + w (Ctrl + Shift + w)
工具栏 Ctrl + t
实用程序窗口 Ctrl + u

鼠标键快捷方式 (必须激活 "万能辅助")

动作 快捷键

使用鼠标进行开关 Option (5次)
(必须激活 "万能辅助")

向上移动 8
向下移动 2
向左移动 4
向右移动 6
斜移 1,3,7,9
点击 5
按下 0

(If you don't have a numeric keypad, press the fn key + "number")

Posted by hufey at 11:41 PM | Comments (0)

April 24, 2007

How can a person tell if their hardware supports kvm?

摘自kerneltrap.org

JA: How can a person tell if their hardware supports kvm?

Avi Kivity: You can easily tell if your processor supports hardware extensions by running the command

$ egrep '^flags.*(vmx|svm)' /proc/cpuinfo

If there's any output at all, your processor supports kvm. Unfortunately, some early laptops that support kvm have VT extensions disabled in the BIOS, so a BIOS upgrade is required. There is also a comprehensive list on the Xen site, http://wiki.xensource.com/xenwiki/HVM_Compatible_Processors.

Posted by hufey at 10:38 AM | Comments (0)

April 06, 2007

firefox extension FullerScreen

FullerScreen

Posted by hufey at 01:24 PM | Comments (0)

February 09, 2007

FW: Readers Write About Symbian, OS X and the iPhone

Responding to Origins: Why the iPhone is ARM, and isn't Symbian, sources from Sweden and Finland offer a revealing look inside Symbian development and how the OS is regarded at Nokia, and what that means for development on the iPhone.

One developer writes, “In most regards, Symbian's reputation as a modern, robust, stable and advanced OS for smartphones is not well deserved. Sure, Symbian works, it has a very long feature list, and it's probably even the best smartphone OS available today. But it's mostly because the competition is pathetic than anything else.

“I have a done several Symbian projects and have a thorough knowledge and low-level understanding of Symbian. And I just hate it. It's a very bad and uninspiring OS even from a programmers point of view.”

Nokia’s POS/OS
Sources close to Nokia say that Symbian is secretly regarded inside the company--even among high level senior executives--as a "piece-of-shit-OS," explaining that “Finnish people usually have a very coarse language.”

A Symbian developer explains, “Nokia is more or less stuck with Symbian since it doesn't have the competence nor the time to make a new OS from the ground up. Its only alternative, in practice, is to go Linux, which it is of course experimenting with, but it's still not an easy path to go.

The Three Symbians
“That's one of the reasons why Nokia is investing so much in the S60 middleware used on top of Symbian. S60 is so large and complex today, that I would regard S60 an OS itself, with Symbian as the kernel. It gives Nokia more control to add and change things on its own.

“Sony Ericsson, as one of the other large Symbian owners and licensee, just bought UIQ in November last year to get control of its own flavor of Symbian. UIQ is quite similar to Nokia's S60 and should also be regarded as its own OS with Symbian as the kernel.

“From one point of view, there are no ‘Symbian’ phones in the market, but rather three incompatible and diverging OSs: NTT DoCoMo's Symbian MOAP for Asia, Nokia’s Symbian S60, and Sony Ericsson’s Symbian UIQ.

“To make it even worse from a third party developer's point of view, Nokia and Symbian made the new S60 version 3 binary incompatible to previous versions of S60. So none of your old Symbian apps will work on any new phones (i.e. if you actually bought any :-).

“And of course UIQ has never been source code nor binary compatible with S60. But still you get the impression from analysts and media that ‘Symbian’ is one stable OS.

Symbian Signed
“For S60 version 3, they have introduced a new security model where it's necessary to sign all apps with VeriSign to even get them to run. Something that costs several hundreds of dollars per year, just for the certificates, and makes shareware and hobby programming almost impossible from now on.

“Some operators are requiring the phones to be locked for any apps not carrying a ‘Symbian Signed’ certificate. Which means, you have to pay for a certification process where you are checked by Symbian, why you developed the application and why you want to use certain capabilities on the phone, e.g. read and store user data, using the telephony APIs, or the WIFI capabilities etc.

“All in the name of security, but of course it will be very tough to make programs, independently, that use functionality that's not in the interest of the operators, such as non-operator controlled Voice over IP.

“So much for independently third-party software development on Symbian compared to the ‘closed’ model used on iPhone. In practice the difference is not that big. Apple will, of course, allow close partners to develop apps like they do with iPod Games today.

Symbian Design Issues
“When it comes to the myth of Symbian being a modern and robust OS, I have several objections. Symbian is severely limited by design decisions made in the beginning of '90. The design decisions were maybe okay at that point in time, when the target was Psion's EPOC and EPOC32-based Series 3 & 5 with extreme memory and resource constraints compared with today's devices.

“I could make a very long list of the problems but I'll just summarize a few key areas:

1.
•Crippled C++ support. Symbian is C++ based—at least on the surface. When EPOC32 was designed (about 1993-1994 I think), there were very few good C++ compiler with full support for the newest C++ features like exceptions. Exceptions is the main feature in C++ for correct and efficient error handling. The other alternative is to use error codes like most operating systems use in their C APIs.

Symbian chose to select neither technique. They made their own home-cooked version of exceptions called Leaves. With an exception in C++, any memory or other resources in allocated objects are deallocated automatically in the correct order (deterministic destruction by calling each object's destructor). This makes it (relatively) easy to make correct programs in C++ for both small and large projects.

In Symbian when a error is signaled with a leave (‘throw an exception’) no objects are deallocated. They just leak, if you don't manually record each object allocated to be cleaned up. This process is extremely tedious, error prone and boring. The result is that it's very hard and time consuming to make correct programs in Symbian, on the verge to be impossible in many cases.

C++ is a great language because of the advanced features, like exception handling with automatic cleanup (search for RAII, Resource Allocation Is Initialization), the standard C++ library (formerly called the STL library with lots and lots of support code for handling of data in containers-like lists and maps and tree structures, strings, algorithms, support for template code and last but not the least—all the standard patterns, practices and idioms all experienced C++ programmer are using on all design problems they are faced with.

If you remove the foundation for standard C++ development, it all falls together. Every design decision means the programmer has to think from the ground up to make a completely new architecture for the design because the normal way of thinking and the normal guarantees C++ and experience gives, doesn't apply anymore. It really turns an experienced programmer into almost a beginner with lousy tools. It's a nightmare for both programmer and development managers.

2.
•Confusing and limited string handling. There is no real support for a proper string handling. To use strings on Symbian you have to use a home-cooked and strange system of ‘descriptors.’ Every new programmer to Symbian spends the first weeks struggling just to understand how (and why) this system works.

The reason was apparently to save a few bytes on each string. But of course, today, that's not even close to being relevant. Maybe a small point but, it's yet another point that makes Symbian hard to use, hard to understand and hard to port programs to/from other platforms.

3.
•Limited support for multi-threading. An important technique used on all other platforms but is not used on Symbian. They do have limited support for threads, but it's strongly recommended not to use threads since it ‘takes to much resources.’ That was hardly even a relevant argument in 1993 but it meant that Symbian uses ‘active objects’ instead of threads in almost all applications.

Active objects are just a very complicated variant of cooperative multitasking, where each object runs in sequence (unnaturally split into small subtasks) and are not able to preempt each other. It takes a lot of code to make this work, just to give the result of a system that is not very responsive, hard to program and port to/from other platforms. All for the aim of saving some CPU cycles in 1993.

4.
•Bad development environment. The development environment and SDK for Symbian (S60) is very strange and difficult to use. It can take several days to just make a functional installation of the SDK and development environment. My first installation a few years ago took over a week to setup and was very fragile. On the Nokia forums there are postings with recommendations on how to make a correct setup. If you do just one step in the wrong order it fucks up. You cannot use the latest version of Visual Studio but need to install Visual Studio 2003 to make it work. But everyone that does Windows programming have VS 2005 installed. Nokia also provides several commercial alternatives, ‘Carbide,’ that is based on Eclipse etc. But it is generally a very bad situation if you compare with Xcode/iPhone or other platforms.


Analysts Wrong on Symbian
“I realize the arguments above are quite technical, but they are nonetheless real and makes it very slow, error prone, and generally difficult to make applications on Symbian.

“This is just one of the reasons I believe the analysts and media are very wrong about the outlook for iPhone. Most media in Sweden (and elsewhere) have reported that the iPhone is nothing new at all. It's mainly a nice package with limited/bad hardware and nothing particularly new on the software side.

“However, if you look at the speed and effort needed to make new applications on iPhone compared with other platforms it's two completely different worlds. You have all the Cocoa frameworks that make it possible to create applications on a level not even available for most desktops today.”

“Most people don't realize the huge difference in development speed (time to market), ability to make more advanced and useful applications with a greater user experience (read: Core Animation and other Leopard frameworks), code quality and maintenance ability—when you have full support for modern high-level languages and frameworks.

Existing Mobile Platforms vs OS X
“Of course, this is the same for most embedded programming projects: set-top boxes, mobile phones, stereo equipment, industrial equipment. But with phones, you are beginning to think about them as a small desktop computer and everyone tries to put in real applications in them.

“With Symbian (as well as WinCE, Palm OS, and I suppose also the Linux phones because they probably have a very limited number of Linux frameworks installed because of memory restrictions etc) you have a big problem to deliver on the marketing hype and media expectations because of all limitations. This is one of the reasons all mobile services are failing to badly—it's simply to hard and complicated to deliver the market expectations with today's platforms.

Five Years Ahead
“OS X and iPhone don't have these limitations. It's one of the reasons I believe Steve Jobs is more or less right in iPhone being 5 years ahead of the competition--of course there is slight marketing hype as well, but not that much an exaggeration as the media and analysts think. Making high quality, advanced applications with a superior user experience will be fast and easy with OS X. On other platforms it's like competing with a small Fiat car in a Formula 1 race against Ferrari and Williams.

“OS X is probably only programmable in Objective C instead of C++, because of the Cocoa frameworks being used. But Objective-C is famous for being easy to program and you can freely mix Objective C and C++ in the same program. In Leopard Apple also introduces Objective-C 2.0 with garbage collection and lots of new stuff that makes it even better than C++ in some respects. And the Cocoa frameworks are world-class on desktop computer—they were even famous in the NeXTSTEP versions.

“So when you put all this together, Apple has sharp weapons and shining armor to compete with lesser equipped competitors for future smartphone apps and wireless services. Most analysts and media don't have enough technical competence and knowledge to realize this.”

Posted by hufey at 10:43 AM | Comments (0)

January 23, 2007

(收藏)汽车网络的分类及发展趋向



                  汽车网络的分类及发展趋向
            中国海洋大学信息科学与工程学院光学工程
                            李爽 孙克怡


摘要:本文介绍了汽车网络的分类,并从各网络的特点及使用情况分析了各类网络的发展趋势,最后又对汽车网络的总体发展趋向进行了分析。
关键字:汽车网络,总线标准,总线协议


1. 概述
自1980年起,众多国际知名汽车公司开始积极致力于汽车网络技术的研究及应用。汽车网络的使用解决了点对点式车身布线带来的问题,更使车身布线(趋于)规范化、标准化,降低了成本,增强了稳定性。迄今为止,已有Bosch的CAN、SAE的J1850、ISO的VAN、Philips的D2B、LIN协会的LIN等多种网络标准。为方便研究和设计使用,美国汽车工程师协会(SAE)将汽车网络根据速率划分为A,B,C三类,如表1所示。

    表1   汽车网络的划分


 


 


 


 


综合考虑功能和位传输速率等因素,现有的汽车总线还包括多媒体信息系统总线、安全总线、诊断系统总线。
2. 汽车网络的具体分类
2.1 A类网络标准
从目前的发展和使用情况来看(如表2所示),A类网的主要总线是TTP/ A( Time Triggered Protocol/ A)和LI N(Local Interconnect Net-work)。


表2   A类网络的使用情况

 


 


 


 


 


 


 


⑴ TTP/ A协议最初由维也纳工业大学制定,为时间触发类型的网络协议,主要应用于集成了智能变换器的实时现场总线。它具有标准的UART,能自动识别加入总线的主节点与从节点,节点在某段已知的时间内触发通信但不具备内部容错功能。
⑵ LIN是在1999年由欧洲汽车制造商Audi, BMW, DaimlerChrysler, Volvo, Volkswagen和VCT公司以及Motorola公司共同组成的LIN协会共同努力下推出的用于汽车分布式电控系统的开放式的低成本串行通信标准,从2003年开始得到使用。
LIN是一种基于UART的数据格式、主从结构的单线12V的总线通信系统,主要用于智能传感器和执行器的串行通信。从硬件、软件以及电磁兼容性方面来看,LIN保证了网络节点的互换性。这极大地提高了开发速度,同时保证了网络的可靠性。
LIN协议应用开发的热点集中在美国、欧洲和日本。估计在未来10年,平均每辆车将有LIN节点20个左右。这样全世界每年将生产12亿个LI N节点。可见,LI N的应用存在着巨大的潜在市场,协议本身也会在不断应用中得到完善。
综上所述,LIN网络已经广泛地被世界上的大多数汽车公司以及零配件厂商所接受,有望成为事实上的A类网络标准。
2.2 B类网络标准


表3   B类网络的使用情况

 


 


 


 



B类网络的使用情况如表3 所示。从目前来看,主要被应用的B类总线标准有三种:低速CAN、J1850、VAN。
⑴ 1994年SAE正式将J1850作为B类网络标准协议。最早,SAE J1850被用在美国Ford ,GM以及Chrysler公司的汽车中。现在,J1850协议作为诊断和数据共享被广泛应用在汽车产品中。但是,J1850并不是一个单一标准。Ford采用的J1850标准,其物理层与GM和Chrysler公司使用的不同。而GM和Chrysler公司在相同的物理层上又使用不同的数据-帧格式,并且三个公司使用各自的消息协议。预计在2006年或2007年将停止使用,然后全部转至CAN总线。
⑵ VAN标准是ISO于1994年6月推出,它基于IS011519 -3,主要为法国汽车公司所用。但目前就动力与传动系统而言,甚至在法国也集中在CAN总线上。
⑶ CAN是德国BOSCH公司从80年代初为解决现代汽车中众多的控制与测试仪器之间的数据交换而开发的一种串行数据通信协议。它是一种多主总线,通信介质可以是双绞线、同轴电缆或光导纤维,通信速率可达1Mbps。1991年首次在奔驰S系列汽车中实现。同年,Bosch公司正式颁布了CAN技术规范(版本2 .0),该技术规范包括A和B两部分。1993年11月ISO正式颁布了国际标准IS011898,为CAN的标准化、规范化铺平了道路。此后,越来越多的北美和日本汽车公司也开始采用CAN网络。1994年美国汽车工程师协会卡车和巴士控制和通信子协会选择CAN作为SAEJ1939标准的基础。低速CAN具有许多容错功能,一般用在车身电子控制中,而高速CAN则大多用在汽车底盘和发动机的电子控制中。
综上所述,CAN总线已凭借其突出的可靠性、实时性和灵活性从众多总线中突显出来,已成为被世界接受的B类总线的主流协议。
2.3 C类网络标准
C类标准主要用于与汽车安全相关,以及实时性要求比较高的地方,如动力系统,所以其传输速率比较高,通常在125Kb/s到1Mb/s之间,必须支持实时的周期性的参数传输。
表4   C类网络的使用情况


 

 


 


目前,C类网络中的主要协议包括高速CAN(ISO11898 -2)、正在发展中的TTP/C, FlexRay等协议。
⑴ TTP/ C协议由维也纳工业大学研发,基于TDMA的访问方式。TTP/C是一个应用于分布式实时控制系统的完整的通信协议,它能够支持多种的容错策略,提供了容错的时间同步以及广泛的错误检测机制,同时还提供了节点的恢复和再整合功能。其采用光纤传输的工程化样品速度将达到25Mb/s。TTP/ C支持时间和事件触发的数据传输。TTP管理组织TTAGroup成员包括奥迪、SA、Renault、NEC、TTChip、Delphi等。
⑵ FlexRay是BWM、Daimler Chrysler、Motorola和Philips等公司制定的功能强大的通信网络协议,基于FTDMA的确定性访问方式,具有容错功能及确定的通信消息传输时间,同时支持事件触发与时间触发通信,具备高速率通信能力。FlexRay采用冗余备份的办法,并且对高速设备可以采用点对点方式与FlexRay总线控制器连接,构成星型结构,对低速网络可以采用类似CAN总线的方式连接。
⑶ 欧洲的汽车制造商基本上采用的都是高速CAN总线标准IS011898。总线传输速率通常在125Kb/s~1Mb/s之间。据Strategy Analytics公司统计,2001年用在汽车上的CAN节点数目超过1亿个.然而,作为一种事件驱动型总线,CAN无法为下一代线控系统提供所需的容错功能或带宽,因为X- by-Wire系统实时性和可靠性要求都很高,必须采用时间触发的通信协议,如TTP/ C或FlexRay等。
就目前来说,CAN协议仍为C类网络协议的主流,但随着下一代汽车中引进X-by-Wire系统,TTP/ C和FlexRay将显示出优势。它们之间的竞争还要持续一段时间,到底在未来的线控系统中哪一个标准更具有生命力尚难定论。
2.4 诊断系统总线标准
故障诊断是现代汽车必不可少的一项功能,使用排放诊断的目的主要是为了满足OBD-II (On Board Diagnose), OBD-III或E-OBD(European-On Board Diagnose)标准。
OBD-Ⅱ(On Board Diagnose)第二代随车电脑诊断系统,是由美国汽车工程学会1994年提出,1994年以来美、日、欧一些主要汽车生产厂为了维修方便逐渐使用OBD-Ⅱ随车诊断系统。这一系统集故障自诊断系统软硬件结构、故障代码、通讯方式系统、自检测试模式为一体,具有监视发动机微机和排放系统部件的能力。
2004年,美国GM、Ford、DC三大汽车公司对乘用车采用基于CAN的J2480诊断系统通信标准。在欧洲,以往诊断系统中使用的是ISO9141,它是一种基于UART的通信标准。从2000年开始,欧洲汽车厂商就已经开始使用一种基于CAN总线的诊断系统通信标准ISO15765。 ISO15765是遵照ISO 14230-3及ISO 15031-5中有关诊断服务的内容来制定的,因此,ISO 15765对于ISO 14230应用层的服务和参数完全兼容,但并不限于只用在这些国际标准所规定的场合。
表5  诊断系统协议标准的使用情况


 


 


 


 


 



目前,除了CAN网络,LIN协议也已经成为汽车诊断的总线标准。
2.5 多媒体信息系统总线标准
    汽车信息娱乐和远程信息设备,特别是汽车导航系统,需要功能强大的操作系统和连接能力。目前主要应用的几种总线协议如表6所示。
表6  多媒体信息系统总线使用情况


 


 


 

 


 


⑴ MOST网络是由德国Oasis Silicon System公司开发的。MOST技术针对塑料光纤媒体而优化,采用环形拓扑结构,在器件层提供高度可靠性和可扩展性。它可以传送同步数据(音频信号、视频信号等流动型数据)、非同步数据(访问网络及访问数据库等的数据包)和控制数据(控制报文及控制整个网络的数据)。MOST受到包括BMW ,Daimler Chrysler ,Harman/Becker和Oasis公司的支持,已应用在多款车型上,如BMW7系列、Audi A-8、Mercedes E系列等。
⑵ IDB-C和IDB-1394总线以及标准接口由IDB论坛负责管理。IDB-C基于CAN总线,目前已成为SAE的标准,即SAE2366。而IDB-1394则针对高速多媒体应用而设计。IDB-1394网络采用光纤技术,允许1394兼容的便携式消费电子设备能够连接到汽车内网络并实现互操作。例如,Za-yante公司就为消费者市场提供1394物理层设备。最近与Ford公司联合进行的一项演示包括数码视频相机以及Sony Play Station TM2游戏机、以及两种视频显示器和一种DVD播放机的即插即用。与MOST相比,IDB-1394则最大限度地利用民用设备市场,通过将现有的部件应用到车载设备上,解决了成本问题。
⑶ D2B是针对多媒体数据通信的一种网络协议,可集成数字音频、视频和其它高数据速率同步或异步信号。主要使用Smart WireTM非屏蔽双绞线对或单光纤。这种通信网络由英国C&CElectronics公司推动,并得到Jaguar和Mercedes-Benz公司的支持。D2B旨在保持后向兼容的情况下与新技术一起演进。D2B基于一种开放式架构,仅使用一条聚合物光纤来处理车内多媒体数据和控制信息,简化了扩展,当在光纤环中增加一种新设备或功能时并不需要改变连接线缆。
⑷ 蓝牙无线技术是一种用于移动设备和WAN/LAN接入点的低成本、低功耗的短距离射频技术。蓝牙标准描述了手机、计算机和PDA如何方便地实现彼此之间的互连,以及与家庭和商业电话和计算机设备的互连。蓝牙特殊兴趣组的成员包括AMIC,BMW ,Daimler Chrysler, Ford, GM, Toyota和Volkswagen。作为蓝牙在汽车中应用的一个例子,Johnson Controls公司的免提手机系统“Blue Connect”允许司机在双手扶住方向盘的情况下通过支持蓝牙功能的手机保持联系。
⑸ ZigBee TM无线网络在汽车上应用的解决方案是针对蓝牙技术受车内电磁噪声影响的问题而提出的。ZigBee可以工作在低于1GHz与2.45GHz的频带范围,传输速率为250kbps,主要应用范围包括工业控制、家庭自动化、消费类应用以及潜在的汽车应用。日前,ZigBee联盟发布了首批成功完成互操作性测试的四款平台。这些平台将用来测试未来数月内推出的ZigBee产品,为ZigBee在各领域的实际应用铺平道路。
2.6 安全总线和标准
    安全总线主要是用于安全气囊系统,以连接加速度计、安全传感器等装置,为被动安全提供保障。目前已有一些公司研制出了相关的总线和协议,包括Delphi公司的SafetyBus和BMW公司的Byteflight。
Byteflight协议是由BMW, Motorola, Elmos, Infineon等公司共同开发的,试图用于安全保障系统。此协议基于灵活的时分多路TDMA协议、以10Mb/s速率传送数据,光纤可长达43m。其结构能保证以一段固定的等待时间专门用于来自安全元件的高优先级信息,而允许低优先级信息使用其余的时段。这种决定性的措施对安全是至关重要的。
Byteflight不仅可用于安全气囊系统的网络通讯,还可用于X-by-Wire系统的通讯和控制。BMW公司在其2001年9月推出的BMW 7系列车型中,采用了一套名为ISIS的安全气囊控制系统,它是由14个传感器构成的网络,利用Byteflight来连接和收集前座保护气囊、后座保护气囊以及膝部保护气囊等安全装置的信号。在紧急情况下,中央电脑能够更快更准确地决定不同位置的安全气囊的施放范围与时机,发挥最佳的保护效果。   
3. 汽车网络的发展趋向
X-by-Wire即线控操作是未来汽车的发展方向。该技术来源于飞机制造,基本思想就是用电子控制系统代替机械控制系统,减轻重量提高可靠性,如Steer-by-Wire, Brake-by-Wire等。由于整个设计思想涉及动力、制动、方向控制等关键功能,对汽车网络也就提出了不同要求。在未来的5至10年里,X-by-Wire技术将使传统的汽车机械系统变成通过高速容错通信总线与高性能CPU相连的电气系统。在一辆装备了综合驾驶辅助系统的汽车上,目前存在相互竞争的几种网络技术,包括前文提到的TTP、Byteflight和FlexRay 以及TTCAN(时间触发的CAN)。
至于哪一种总线网络会成为今后的标准,目前还尚难定论。但长远来看,车载网络还远没有达到成熟阶段,信息与电子技术发展很快,车辆上的应用又有比较大的滞后,所以车上信息与电子技术的应用还有很大的发展空间。它们将对车上通信与控制网络提出一些新的需求,同时为新的车上网络技术提供技术支持。
参考文献:
⑴侯淑梅,王世震.车身总线的应用及发展.承德石油高等专科学校学报,2004,6(2)
⑵任重.汽车网络综合研究及基于CAN总线的汽车组合仪表的实现.浙江大学硕士学位论文,2003.3
⑶周泉.车载网络发展动向(I).汽车电器,2004,1
⑷唐晓泉,汽车总线技术逐渐成熟,国际电子商情. http://www.esmchina.com, 2004,4,3
⑸罗峰,苏剑,袁大宏.汽车网络与总线标准.汽车工程,2003.25(4)
(6)Byteflight Specification,BMWAG,2001
⑺Kopetz.H and Thurner T.TTP-A New Approach to Solving the Interoperability Problem of Independently Developed ECUs. Technical Report, SAE, Detroit, Michigan, February 1998
⑻LIN-subbus. LIN protocol specification revision 2.0 .  http://www.lin-subbus.org, 2002,8,12
⑼柏万宁.通过互操作性测试的ZigBee平台问世.电子工程专辑,2005,6,20

 


 


Posted by hufey at 11:49 PM | Comments (0)

January 12, 2007

ZT: Linux: Accessing Files With O_DIRECT

Linux: Accessing Files With O_DIRECT

By Jeremy on Linux news

A thread on the lkml began with a query about using O_DIRECT when opening a file. An early white paper written by Andrea Arcangeli [interview] to describe the O_DIRECT patch before it was merged into the 2.4 kernel explains, "with O_DIRECT the kernel will do DMA directly from/to the physical memory pointed [to] by the userspace buffer passed as [a] parameter to the read/write syscalls. So there will be no CPU and memory bandwidth spent in the copies between userspace memory and kernel cache, and there will be no CPU time spent in kernel in the management of the cache (like cache lookups, per-page locks etc..)." Linux creator Linus Torvalds was quick to reply that despite all the claims there is no good reason for mounting files with O_DIRECT, suggesting that interfaces like madvise() and posix_fadvise() should be used instead, "there really is no valid reason for EVER using O_DIRECT. You need a buffer whatever IO you do, and it might as well be the page cache. There are better ways to control the page cache than play games and think that a page cache isn't necessary."

Linus went on to explain, "the only reason O_DIRECT exists is because database people are too used to it, because other OS's haven't had enough taste to tell them to do it right, so they've historically hacked their OS to get out of the way. As a result, our madvise and/or posix_fadvise interfaces may not be all that strong, because people sadly don't use them that much. It's a sad example of a totally broken interface (O_DIRECT) resulting in better interfaces not getting used, and then not getting as much development effort put into them." To further underscore his point, he humorously added:


"The whole notion of "direct IO" is totally brain damaged. Just say no.
This is your brain: O
This is your brain on O_DIRECT: .

Any questions?

Posted by hufey at 11:13 AM | Comments (0)

January 11, 2007

remote X apps running howto

host side: $xhost +[client_name|client ip]
client side: $export DISPLAY=[host_name|host ip]:0
$xapp

Posted by hufey at 05:39 PM | Comments (0)

December 23, 2006

how to disable alignment trap from user space in linux

I was confused on that how to disable alignment trap from user space in linux. After lots of searching, code/document reading I got the point is, the linux kernel provides a mechanism/interface in procfs let user space application change the unalignment trap action of kernel to
"ignored",
"warn",
"fixup",
"fixup+warn",
"signal",
"signal+warn".
And default mode is 5(signal+warn), that means once unalignment memory access occurs, the kernel will send signal SIGBUS to kill the application.
We can just read all configuration info from /proc/cpu/alignment and just write a number to reset action mode like "echo 2 > /proc/cpu/alignment".

See linux-2.6.x/Documentation/arm/mem_alignment,
----------------------------------------------------------------------------------------
Too many problems poped up because of unnoticed misaligned memory access in
kernel code lately. Therefore the alignment fixup is now unconditionally
configured in for SA11x0 based targets. According to Alan Cox, this is a
bad idea to configure it out, but Russell King has some good reasons for
doing so on some f***ed up ARM architectures like the EBSA110. However
this is not the case on many design I'm aware of, like all SA11x0 based
ones.

Of course this is a bad idea to rely on the alignment trap to perform
unaligned memory access in general. If those access are predictable, you
are better to use the macros provided by include/asm/unaligned.h. The
alignment trap can fixup misaligned access for the exception cases, but at
a high performance cost. It better be rare.

Now for user space applications, it is possible to configure the alignment
trap to SIGBUS any code performing unaligned access (good for debugging bad
code), or even fixup the access by software like for kernel code. The later
mode isn't recommended for performance reasons (just think about the
floating point emulation that works about the same way). Fix your code
instead!

Please note that randomly changing the behaviour without good thought is
real bad - it changes the behaviour of all unaligned instructions in user
space, and might cause programs to fail unexpectedly.

To change the alignment trap behavior, simply echo a number into
/proc/sys/debug/alignment. The number is made up from various bits:

bit behavior when set
--- -----------------

0 A user process performing an unaligned memory access
will cause the kernel to print a message indicating
process name, pid, pc, instruction, address, and the
fault code.

1 The kernel will attempt to fix up the user process
performing the unaligned access. This is of course
slow (think about the floating point emulator) and
not recommended for production use.

2 The kernel will send a SIGBUS signal to the user process
performing the unaligned access.

Note that not all combinations are supported - only values 0 through 5.
(6 and 7 don't make sense).

For example, the following will turn on the warnings, but without
fixing up or sending SIGBUS signals:

echo 1 > /proc/sys/debug/alignment

You can also read the content of the same file to get statistical
information on unaligned access occurrences plus the current mode of
operation for user space code.


Nicolas Pitre, Mar 13, 2001. Modified Russell King, Nov 30, 2001.
--------------------------------------------------------------------------------------------

Note the procfs interface file location was changed. Not sure when it was.

Posted by hufey at 02:26 PM | Comments (0)

December 20, 2006

Window$ CE family

Posted by hufey at 12:30 AM | Comments (0)

November 08, 2006

光源色温对应表

高海拔陰天/雪天 11000k-18000k
雨天/高海拔晴天 9000k-11000k
烏雲密佈 8000k-9000k
薄雲 7000k-8000k
日光/晴天 6000k-7000k
閃光燈 5000k-5500k
螢光燈 4000k-5000k
日出/日落(没有雾) 3000k-4000k
新燈泡 3000k
舊燈泡 2500k
日出前 2000k
燭光 1000k

Posted by hufey at 10:56 AM | Comments (0)

October 22, 2006

wireless lan又不工作了

好像是把gentoo的gcc升级到4.1之后的事儿
出现不停输出莫名其妙log的问题
只好先不管再找出10M老爷爷网卡接上网线emerge world
重build/install ndiswrapper,modprobe发现kernel是gcc 3.4编译的而ndiswrapper是4.1
再重新编译kernel
一切都正常了

gentoo真是脆弱,不知道debian一家怎么样?
买了个ibook打算装gentoo for powerpc来着,结果一个多月了一直拿她放电影

总不能真的就当买个mp4 player吧?

Posted by hufey at 02:30 PM | Comments (0)

August 30, 2006

诡异的泡网blog计数器

前两天泡网服务器又出毛病了
大伙的blog计数器又归了零
于是,根据以往的惯例要跟大伙要最后的数字再重设

岁数大了,记不住细节
所以每次干这活,或者类似的活,都要从搜索程序路径开始,再根据回忆仔细想想要改哪
基本上,我都会先把自己的设对,自己当白耗子,术语所谓先走通
结果这次发现改了数也不对,看html source code,似乎默认的图片路径不对
再读代码,找到哪个变量起作用,再找到该变量从哪读出来的
再找设置文件,改设置
可是诡异的是,明明已经改对了,却始终看不到计数器的值
试了无数次,终于想到用ie来看,结果ie是对的

开始以为在乔治借我的小笔记本上装的FF有问题,第二天在单位的FF上看也是一样

难道firefox对《div》tag解析的和IE的不一样????
类似现象总归是IE的不对,因为FF对W3C的规范是遵守的最严格的了
想想又不对啊,以前FF都是对的ya,实在想不明白了。。。
算了,先让IE对了再说吧,FF的事改天再琢磨,反正说到底还是用IE的人多些。。。

第二天,在msn上看到了救星yining老兄,哭诉了这件事,结果在他那FF也是能看到计数器的
虽然他是在Ubuntu上的FF

肯定是哪个extension搞的鬼,tools,extension,一看就明白了
因为几台电脑都不是我的,我装的extension并不算多,几个最常用的而已
能屏蔽图片的,只有adblock plus了
点开adblock plus,赫然看到一条filter: counte[rd]
删掉
好了

不知道adblock plus从哪个版本开始提供这条filter的
每次装完FF我都会第一个装adblock plus

Posted by hufey at 12:18 AM | Comments (0)

July 14, 2006

C++ operator priority table
















LevelOperatorDescriptionGrouping
1::scopeLeft-to-right
2() [] . -> ++ -- dynamic_cast static_cast reinterpret_cast const_cast typeidpostfixLeft-to-right
3++ -- ~ ! sizeof new deleteunary (prefix)Right-to-left
* &indirection and reference (pointers)
+ -unary sign operator
4(type)type castingRight-to-left
5.* ->*pointer-to-memberLeft-to-right
6* / %multiplicativeLeft-to-right
7+ -additiveLeft-to-right
8<< >>shiftLeft-to-right
9< > <= >=relationalLeft-to-right
10== !=equalityLeft-to-right
11&bitwise ANDLeft-to-right
12^bitwise XORLeft-to-right
13|bitwise ORLeft-to-right
14&&logical ANDLeft-to-right
15||logical ORLeft-to-right
16?:conditionalRight-to-left
17= *= /= %= += -= >>= <<= &= ^= !=assignmentRight-to-left
18,commaLeft-to-right

Posted by hufey at 02:40 PM | Comments (0) | TrackBack

June 19, 2006

Gentoo shadow and pam-login conflict

emerge sync
emerge world
发现pam-login和shadow冲突
没当回事就emerge -C pam-login, emerge -C shadow了
由于长时间没升级系统,导致需要升级的portage有五十多个,从周六晚一直到周日上午没闲着
周日早上,要拿笔记本看点东西,只好中断升级过程,过后再切回gentoo的时候
发现已经不能登陆了
查到原因:
The shadow and pam-login conflict
又查到原来好多人都遇到同样的麻烦,只好用livecd启动系统再chroot
gentoo livcd其实这是第一次用,以前一直用install cd。
发现livecd不能用我的无线网卡,没法上网
用老10M pcmcia网卡连上网线也找不到,按说不应该呀
再google,发现livecd要用dopcmcia选项启动
启动后还要modprobe 8139too,果然好使了
chroot之后再emerge shadow
天下太平
一天时间就这么浪费了,主要是老婆拿家里另外一台desktop pc看电影,我只好不断的切换到
windows用google查东西再切换回linux验证,效率比较低

Posted by hufey at 12:30 AM | Comments (0) | TrackBack

May 15, 2006

add a new file into directory by clearcase

clt edcs
comment off "element * /main/LATEST"
wq
clt mkbranch your_branch your_directory
clt edcs
enable "element * /main/LATEST"
wq
clt mkelem your_file
clt mkbranch your_branch your_file
fill something
clt ci your_file
clt edcs
comment off "element * /main/LATEST"
clt ci your_directory

Posted by hufey at 11:19 AM | Comments (0) | TrackBack

May 12, 2006

NAND vs. NOR

Posted by hufey at 02:18 PM | Comments (0) | TrackBack

April 26, 2006

Quote and Quote-like Operators


While we usually think of quotes as literal values, in Perl they function as operators, providing various kinds of interpolating and pattern matching capabilities. Perl provides customary quote characters for these behaviors, but also provides a way for you to choose your quote character for any of them. In the following table, a {} represents any pair of delimiters you choose. Non-bracketing delimiters use the same character fore and aft, but the 4 sorts of brackets (round, angle, square, curly) will all nest.











CustomaryGenericMeaning Interpolates
'' q{} Literal no
"" qq{} Literal yes
`` qx{} Command yes (unless '' is delimiter)
qw{} Word list no
// m{} Pattern match yes
qr{} Pattern yes
s{}{} Substitution yes
tr{}{} Transliteration no (but see below)

Note that there can be whitespace between the operator and the quoting characters, except when # is being used as the quoting character. q#foo# is parsed as being the string foo, while q #foo# is the operator q followed by a comment. Its argument will be taken from the next line. This allows you to write:

s {foo} # Replace foo
{bar} # with bar.

Posted by hufey at 04:29 PM | Comments (0) | TrackBack

April 24, 2006

Perl Library Mechanics – 6 ways to add a library path

Perl Library Mechanics – 6 ways to add a library path

A ncode solutions technology guide – visit us at http://www.ncode.ch

Objectives

Run a perl script using libraries in non­standard locations.
We use the location /opt/special/plib for our samples.
Perl uses by default the array @INC as include path when searching for modules to load.
This path is
compiled into the perl binary when building it from source and can be printed by running
perl -V
, which will show something like:
..
Compiled at Jan 24 2004 21:39:16
@INC:
/etc/perl
/usr/lib/perl5/site_perl/5.8.0/i686-linux
/usr/lib/perl5/site_perl/5.8.0
/usr/lib/perl5/site_perl/5.6.1
..

1. Using the module lib

The standard module lib can be used to specify an explicit path to include. It must be stated at the
top
of the script:
#!/usr/bin/perl
#
use lib "/opt/special/plib";
use strict;
use warnings;
..

2. Using the switch ­I at the command line

The switch ­I can be used to specify additional library locations when invoking the interpreter.
perl -I /opt/special/plib script.pl
23.09.2005 / Oli Kessler / info@ncode.ch © 2005 ncode solutions GmbH
Page 2

3. Using the switch ­I in the first line of the script

The same ­I switch can be added to the interpreter specification.
#!/usr/bin/perl -I /opt/special/plib
#
use strict;
use warnings;
..
This works when invoking the script via the shell (which will run the interpreter with full
options and arguments as specified in the first line) and also when invoking the interpreter
directly: It apparently scans the first line for options.

4. Manipulating @INC directly

The array @INC can be manipulated directly using array operations
#!/usr/bin/perl
#
BEGIN {
unshift(@INC, "/opt/special/plib");
}
use strict;
use warnings;
This is the same as using the module lib, which in fact does something like this.

5. Using the environment variable PERL5LIB

The environment variable PERL5LIB can be used to specify additional include directories when
running a perl script.
> export PERL5LIB=/opt/special/plib
> /path/to/script.pl

6. Changing @INC at compile time

When running
Configure
to compile the perl interpreter itself, there are several possibilities to add
additional library path elements:

Using the variable vendorprefix

Using the variable otherlibdirs
Both must be specified when calling Configure as a define, eg
> sh Configure -Dotherlibdirs=/opt/special/plib
The variable otherlibdirs is preferred, as it can hold mutliple values separated by a colon just like
the familiar PATH environment variable.
Details about compiling perl can be found on the CPAN network :

Posted by hufey at 06:12 PM | Comments (0) | TrackBack

March 23, 2006

undefined reference to _yywrap

cygwin,

$flex ch1-02.l
$gcc lex.yy.c -o ch1-02.exe
/cygdrive/d/Profiles/E6097C/LOCALS~1/Temp/ccFsaC7D.o:lex.yy.c:(.text+0x36c): und
efined reference to `_yywrap'
/cygdrive/d/Profiles/E6097C/LOCALS~1/Temp/ccFsaC7D.o:lex.yy.c:(.text+0xac1): und
efined reference to `_yywrap'
collect2: ld returned 1 exit status

solution: gcc lex.yy.c -o ch1-02.exe -lfl

Posted by hufey at 03:32 PM | Comments (0) | TrackBack