專家觀點:從中國山寨手機到美國山寨總統
上網時間: 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
说说山寨机
最早山寨机和联发科是儿子和老子关系, 联科发除了芯片设计以外 其他诸如外观 线路板等的设计都包圆.山寨机厂找联发科买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操作员 执锡工 要求写出降低三项不良的对策,那本每周质量对策汇编现在比新华词典还厚 他们的质量也提升了不少.
想写的不少 可文笔差 表达不出来 呵呵 没有吹嘘山寨无敌的意思 想大家能有个比较近的视角观察下山寨机而已.
上網時間: 2008年11月07日
驅動馬達時最佳的開關頻率?
所謂的最佳頻率,就是在實現可接受效率、電流紋波、EMI性能的同時,仍能在安全操作範圍內持續驅動設備的最高頻率。開關頻率通常依上述條件來選擇。
中心對齊與邊緣對齊PWM訊號有何不同?
在邊緣對齊多相PWM控制中,所有相位都會同時開啟,但關閉則取決於每相位工作週期上的不同時間。多個大電流相位同時開關會導致更大的EMI瞬變,其影響遠較相位永遠在不同時間改變來得大。透過啟動PWM輸出,中心對齊開關解決了EMI問題,使得中心的所有活動週期均趨於一致。對每個相位輸出來說,在中心對齊參考點之前只有一半的工作週期發生。
什麼是死區時間控制?
死區時間是測量從連接到一個電源軌上的驅動器開關關閉時,到連接在電源另一條軌上的開關接通時的延遲時間。
我為何需要互補輸出?
互補輸出是針對高端與低端開關提供替換驅動所必需的。BLDC馬達每轉一圈,每個相位的驅動電流方向便會改變兩次。這必須使連接在該相位端的驅動電壓改變方向。這種電壓換向是將每個相位端通過分離式MOSFET或IGBT驅動器,並連接到電源的正向輸出和負向輸出來實現的。當一個驅動器接通時,另一個關閉,這就代表著它們是需要互補驅動輸入的互補驅動器。
什麼是三相或四相PWM?
內容:三相脈寬調變器(PWM)由三個輸出組成(或是互補驅動時為三對輸出),每個輸出均提供獨立的脈寬調變訊號。各自獨立的輸出使類比三相系統的模擬成為可能,而每個輸出上的有效電壓電平都是取決於脈衝工作週期的平均電壓。四相PWM就是將三相PWM中的相位數改為四個。
在三相PWM系統中A/D與事件能同步嗎?
可以。
什麼是無感測器馬達?
無感測器馬達應用並非真正的無感測器,它主要透過從其他反饋源取得位置與速度資訊來免除對一個或更多反饋感測器的需求。無感測器控制是無刷馬達的一種選項。一個無感測器BLDC應用意味著使用馬達上未通電繞阻的電壓感應來獲得轉子位置。
如何感測馬達位置或速度?需要幾個感測器?
可利用光學編碼器、解算器或其它元件如霍爾效應感測器來進行位置與速度的感測。通常每個馬達要使用一個感測器,以用於反饋。
開環控制的應用場合?
開環控制可用在對馬達速度要求不高且無需進行精確定位的系統中。開環控制也可與步進馬達聯用進行位置控制。
開環╱閉環是什麼意思?
開環是無反饋控制。閉環控制會將馬達的電流、速度或位置反饋資訊與所需的值進行比較,並產生修正命令減小誤差。
資料來源:Microchip Technology
信号处理程序中应当使用可再入(可重入)函数(注:所谓可重入函数是指一个可以被多个任务调用的过程,任务在调用时不必担心数据是否会出错)。因为进程在收到信号后,就将跳转到信号处理函数去接着执行。如果信号处理函数中使用了不可重入函数,那么信号处理函数可能会修改原来进程中不应该被修改的数据,这样进程从信号处理函数中返回接着执行时,可能会出现不可预料的后果。不可再入函数在信号处理函数中被视为不安全函数。
满足下列条件的函数多数是不可再入的:(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()没有被列为可再入函数,因为不能保证紧接着两个函数的其它调用是安全的。
一直没想过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.
存档,打算在有生之年看完,不知道能不能完成这个任务
>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年。小说中最主要的设定是一位科学家开发了数学的一门分支——心理史学,能够预测未来大多数人类的行为。
《基地》《时间足够你爱》《环形世界》《银河系漫游指南》《沙丘》《海伯利安》《海伯利安的陨落》等都有中文版,但许多系列都没有出全。
先git diff xxx看是不是自己改了什么东西
如果改不回来可以用git reset --hard重置来解决这个问题

在server 端的/etc/ssh/sshd_config中打开
X11Forwarding yes
在client端的/etc/ssh/ssh_config中打开
ForwardX11 yes
把流控去掉试试
Ctrl +A -> Z -> O -> serial port setup -> F, G
save setup as dfl
只要执行sudo fontconfig-voodoo -f -s zh_CN即可
google“ubuntu 英文环境 中文 方块“ 出来的大部分都跟这个没关系
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++可以编译过去
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
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,不用它了,永远。
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")
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.

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.”
汽车网络的分类及发展趋向
中国海洋大学信息科学与工程学院光学工程
李爽 孙克怡
摘要:本文介绍了汽车网络的分类,并从各网络的特点及使用情况分析了各类网络的发展趋势,最后又对汽车网络的总体发展趋向进行了分析。
关键字:汽车网络,总线标准,总线协议
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
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?
host side: $xhost +[client_name|client ip]
client side: $export DISPLAY=[host_name|host ip]:0
$xapp
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.
高海拔陰天/雪天 11000k-18000k
雨天/高海拔晴天 9000k-11000k
烏雲密佈 8000k-9000k
薄雲 7000k-8000k
日光/晴天 6000k-7000k
閃光燈 5000k-5500k
螢光燈 4000k-5000k
日出/日落(没有雾) 3000k-4000k
新燈泡 3000k
舊燈泡 2500k
日出前 2000k
燭光 1000k
好像是把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吧?

前两天泡网服务器又出毛病了
大伙的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
| Level | Operator | Description | Grouping |
|---|---|---|---|
| 1 | :: | scope | Left-to-right |
| 2 | () [] . -> ++ -- dynamic_cast static_cast reinterpret_cast const_cast typeid | postfix | Left-to-right |
| 3 | ++ -- ~ ! sizeof new delete | unary (prefix) | Right-to-left |
| * & | indirection and reference (pointers) | ||
| + - | unary sign operator | ||
| 4 | (type) | type casting | Right-to-left |
| 5 | .* ->* | pointer-to-member | Left-to-right |
| 6 | * / % | multiplicative | Left-to-right |
| 7 | + - | additive | Left-to-right |
| 8 | << >> | shift | Left-to-right |
| 9 | < > <= >= | relational | Left-to-right |
| 10 | == != | equality | Left-to-right |
| 11 | & | bitwise AND | Left-to-right |
| 12 | ^ | bitwise XOR | Left-to-right |
| 13 | | | bitwise OR | Left-to-right |
| 14 | && | logical AND | Left-to-right |
| 15 | || | logical OR | Left-to-right |
| 16 | ?: | conditional | Right-to-left |
| 17 | = *= /= %= += -= >>= <<= &= ^= != | assignment | Right-to-left |
| 18 | , | comma | Left-to-right |
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验证,效率比较低
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
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.
| Customary | Generic | Meaning | 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) |
s {foo} # Replace foo
{bar} # with bar.
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 nonstandard 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 :
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
困扰多日的405问题终于解决了
原来是不知什么时候emerge apche之类的把/etc/conf.d/apache2里的配置给弄丢了
买了一个DLink Wireless Router和一个Netgear WG511v2的pcmcia卡
折腾了两天多
终于搞定了Linux下的驱动
原来wireless-tools不支持WPA
以后可以在阳台上上网了
不曾想搁下十几年的汇编又不得不捡起来
以前印象里MASM出到六点十几
自己大概装过6.11
上网搜出好些,居然有6.14的patch。
不过懒了,相信也没啥大区别。
下载,安装,编译,链接。。。链不过去了!!!
出来的是LNK2001,于是调整lib的设置,还是不行
google, baidu, yahoo搜啊搜,折腾了两天。
今天晚上,新年夜,心情平静下来,还是读代码先吧
自打有了google,读代码的时候太少了
结果居然读到这一句:
; NOTE: If you get a LINK ERROR for the Microsoft linker that it can't find
; __c_startup, it's a bug in MASM versions before v6.12. Get the MASM patch
; from Microsoft Knowledge Base Article 228454 at www.microsoft.com.
; This will patch any version 6.1x of MASM to 6.14.
DamnIt!!!
如果早读代码早就解决问题了!
于是继续下载masm 6.14patch,编译链接,果然全都对了。
高兴之余,继续搜,发现原来最新的版本是6.15,google之,下载之,安装之。
另外,今天(12/31)在单位也有一个突破,就不在blog里说了。
root@abc ~ # emerge gnome
Calculating dependencies ...done!
>>> emerge (1 of 29) sys-apps/apmd-3.2.1_p4 to /
>>> md5 files ;-) apmd-3.0.2-r3.ebuild
>>> md5 files ;-) apmd-3.2.0.ebuild
>>> md5 files ;-) apmd-3.2.1_p4.ebuild
>>> md5 files ;-) files/apmsleep.c.diff
>>> md5 files ;-) files/apmd.rc6
>>> md5 files ;-) files/apmd-3.2.0.kernel26x.patch
>>> md5 files ;-) files/apmd.confd
>>> md5 files ;-) files/apmd.kernel26x.patch
>>> md5 files ;-) files/apmsleep.c.diff.3.2.0
>>> md5 files ;-) files/digest-apmd-3.0.2-r3
>>> md5 files ;-) files/digest-apmd-3.2.0
>>> md5 files ;-) files/digest-apmd-3.2.1_p4
>>> md5 src_uri ;-) apmd_3.2.1.orig.tar.gz
>>> md5 src_uri ;-) apmd_3.2.1-4.diff.gz
>>> Unpacking source...
>>> Unpacking apmd_3.2.1.orig.tar.gz to /var/tmp/portage/apmd-3.2.1_p4/work
>>> Unpacking apmd_3.2.1-4.diff.gz to /var/tmp/portage/apmd-3.2.1_p4/work
* Applying apmd_3.2.1-4.diff ... [ ok ]
>>> Source unpacked.
libtool --quiet --mode=compile gcc -c -O -g -Wall -pipe -I. -I/usr/src/linux/include -I/usr/src/linux-2.2/include -I /usr/src/linux-2.0/include -DVERSION=\"3.2.1\" -DDEFAULT_PROXY_NAME=\"/etc/apmd_proxy\" apmlib.c
libtool --quiet --mode=compile gcc -c -O -g -Wall -pipe -I. -I/usr/src/linux/include -I/usr/src/linux-2.2/include -I /usr/src/linux-2.0/include -DVERSION=\"3.2.1\" -DDEFAULT_PROXY_NAME=\"/etc/apmd_proxy\" apm.c
libtool --quiet --mode=compile gcc -c -O -g -Wall -pipe -I. -I/usr/src/linux/include -I/usr/src/linux-2.2/include -I /usr/src/linux-2.0/include -DVERSION=\"3.2.1\" -DDEFAULT_PROXY_NAME=\"/etc/apmd_proxy\" apmd.c
libtool --quiet --mode=compile gcc -c -O -g -Wall -pipe -I. -I/usr/src/linux/include -I/usr/src/linux-2.2/include -I /usr/src/linux-2.0/include -DVERSION=\"3.2.1\" -DDEFAULT_PROXY_NAME=\"/etc/apmd_proxy\" -DNARROWPROTO xapm.c
libtool --quiet --mode=compile gcc -c -O -g -Wall -pipe -I. -I/usr/src/linux/include -I/usr/src/linux-2.2/include -I /usr/src/linux-2.0/include -DVERSION=\"3.2.1\" -DDEFAULT_PROXY_NAME=\"/etc/apmd_proxy\" apmsleep.c
libtool --quiet --mode=link gcc -o libapm.la apmlib.lo -rpath /usr/lib -version-info 1:0
apmsleep.c:60: warning: `rcsid' defined but not used
i686-pc-linux-gnu-g++: /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.5/../../../crti.o: No such file or directory
i686-pc-linux-gnu-g++: /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.5/crtbeginS.o: No such file or directory
i686-pc-linux-gnu-g++: /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.5/crtendS.o: No such file or directory
i686-pc-linux-gnu-g++: /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.5/../../../crtn.o: No such file or directory
make: *** [libapm.la] Error 1
make: *** Waiting for unfinished jobs....
rm apm.o
!!! ERROR: sys-apps/apmd-3.2.1_p4 failed.
!!! Function src_compile, Line 43, Exitcode 2
!!! emake failed
!!! If you need support, post the topmost build error, NOT this status message.
root@abc ~ #
-------------------------------------------------
emerge libtool先
参见bugs.gentoo.org
Top Tech Index 2005
| Company | Latest full year revenues (US$ in millions) | Latest full year net income (US$ in millions) | Average year-on-year revenue growth over 4 years (%) | Average year-on-year net income over 4 years (%) | Direct presence in 10 Asian countries | Global employees |
| Accenture | 13,670 | 691 | 6.4 | 35.7 | 9 | 115,000 |
| Altiris | 166 | 17 | 70.0 | 4,740.1 | 3 | 807 |
| Apple Computer | 8,279 | 276 | 16.2 | 222.1 | 7 | 11,695 |
| Atos Origin | 6,500 | 285 | 25.3 | 37.2 | 8 | 46,000 |
| Autodesk | 1,230 | 222 | 10.6 | 135.8 | 8 | 3,477 |
| Avaya | 4,069 | 296 | -13.9 | 144.7 | 8 | 20,000 |
| BMC Software | 1,463 | 75 | 6.6 | 115.9 | 9 | 6,905 |
| BT Group | 33,933 | 3,316 | 0.3 | 48.1 | 8 | 102,000 |
| CSC | 14,800 | 519 | 13.1 | 31.2 | 9 | 90,000 |
| Canon | 31,211 | 3,090 | 6.1 | 27.6 | 9 | 108,257 |
| Cognos | 826 | 137 | 18.9 | 116.7 | 4 | 3,297 |
| Dell Computer | 49,205 | 3,323 | 16.4 | 40.2 | 10 | 61,300 |
| EMC | 8,230 | 871 | 7.8 | 223.0 | 8 | 23,000 |
| Emerson | 15,615 | 1,257 | 1.1 | 239.9 | 10 | 107,800 |
| Ericsson | 17,368 | 2,504 | -22.4 | 109.7 | 10 | 50,534 |
| F5 Networks | 171 | 33 | 18.6 | 307.4 | 7 | 790 |
| Fujitsu | 44,511 | 298 | 6.0 | 37.3 | 10 | 151,000 |
| Hewlett-Packard | 80,000 | 5,000 | 23.7 | 245.3 | 10 | 150,000 |
| Hitachi Data Systems | 84,400 | 481 | 12.3 | 100.2 | 8 | 2,900 |
| Huawei | 3,827 | 624 | 20.6 | 86.7 | 10 | 30,000 |
| IBM | 96,300 | 8,400 | 4.1 | 23.1 | 10 | 329,000 |
| Infosys | 1,592 | 419 | 43.0 | 37.4 | 3 | 36,750 |
| Intel | 34,200 | 7,500 | 9.2 | 85.0 | 10 | 91,000 |
| LG Electronics | 23,542 | 1,476 | 15.2 | 62.6 | 10 | 66,614 |
| Lucent Technologies | 9,045 | 2,002 | -22.2 | 160.3 | 4 | 31,000 |
| Microsoft | 39,788 | 12,254 | 12.0 | 33.0 | 10 | 59,947 |
| Motorola | 31,323 | 10,497 | 7.6 | 16.7 | 10 | 68,000 |
| NCR | 5,984 | 290 | 0.5 | 90.5 | 7 | 28,300 |
| NEC | 45,000 | 600 | 5.3 | 147.1 | 8 | 147,753 |
| Network Appliance | 1,600 | 226 | 26.6 | 865.8 | 9 | 4,001 |
| Nokia | 39,056 | 4,279 | 0.5 | 25.9 | 10 | 55,000 |
| Oracle | 11,799 | 2,886 | 7.0 | 8.0 | 10 | 49,872 |
| Qualcomm | 4,880 | 1,720 | 22.5 | 133.3 | 8 | 7,000 |
| Red Hat | 197 | 45 | 36.4 | 210.4 | 4 | 800 |
| SAP | 10,235 | 1,786 | 16.1 | 63.1 | 9 | 32,205 |
| Samsung Electronics | 78,250 | 10,301 | 21.2 | 63.2 | 10 | 123,000 |
| Seagate Technology | 7,553 | 707 | 8.0 | 125.0 | 5 | 41,000 |
| Siebel Systems | 1,340 | 111 | -13.3 | 621.1 | 6 | 5,000 |
| Siemens | 92,658 | 4,197 | -4.6 | 19.3 | 10 | 430,000 |
| SingTel | 7,513 | 1,947 | 21.1 | 85.4 | 10 | 19,000 |
| Sony | 65,153 | 1,491 | -1.9 | 238.8 | 10 | 151,400 |
| Symantec | 2,600 | 536 | 33.3 | 359.9 | 9 | 14,000 |
| Symbol Technologies | 1,730 | 82 | 5.7 | 777.5 | 5 | 5,000 |
| Tata Consultancy Services | 2,208 | 466 | 30.7 | 24.7 | 6 | 48,711 |
| Toshiba | 52,525 | 414 | 2.7 | 74.3 | 10 | 165,000 |
| Trend Micro | 558 | 237 | 28.4 | 132.2 | 8 | 2,600 |
| Unisys | 5,800 | 39 | -1.0 | 121.1 | 9 | 36,000 |
| Western Digital | 3,047 | 151 | 16.2 | 142.8 | 6 | 16,000 |
| Wipro | 1,870 | 363 | 39.3 | 30.8 | 5 | 42,000 |
| Yahoo | 3,575 | 840 | 74.5 | 284.9 | 5 | 8,780 |
From: Greg KH
Subject: [RFC] HOWTO do Linux kernel development
Newsgroups: gmane.linux.kernel
Date: 2005-11-14 22:07:09 GMT (4 hours and 39 minutes ago)
Over time, I get a lot of the same kind of emails from developers.
Messages asking how to do this or that, or how this process works. I
also see a lot of new developers make the same mistakes (wrong patch
format, no signed-off-by:, not sent to the proper developer, wrong
coding style, etc.)
Along with these requests, I have heard a lot of complaints over time,
about how there is no single place to go to to figure out how to do
Linux kernel development, and where to point other people to.
So, I've been working on a document for the past week or so to help
alleviate a lot of these problems. If nothing else, it should be a place
where anyone can point someone to when they ask the common questions, or
do something in the not-correct way. I'd like to add this to the Linux
kernel source tree, so it will be kept up to date over time, as things
change (like the development process.) Ideally I'd like to put it in
the main directory as HOWTO, but I don't know how others feel about
this.
Anyway, I'd like to get comments on what has been produced so far. I
know the section about the development process is still not complete (it
has a
appreciate it.
I would like to thank Pat Mochel, Hanna Linder, Randy Dunlap, Kay
Sievers, Vojtech Pavlik, and Jan Kara for their review and comments on
early drafts of this document.
thanks,
greg k-h
------------------------------
HOWTO do Linux kernel development
---------------------------------
This is the be-all, end-all document on this topic. It contains
instructions on how to become a Linux kernel developer and how to learn
to work with the Linux kernel development community.
If anything in this document becomes out of date, please send in patches
to the maintainer of this file, who is listed at the bottom of the
document.
Intro
-----
So, you want to learn how to become a Linux kernel developer? Or you
have been told by your manager, "Go write a Linux driver for this
device." This document's goal is to teach you everything you need to
know to achieve this by describing the process you need to go through,
and hints on how to work with the community. It will also try to
explain some of the reasons why the community works like it does.
The kernel is written mostly in C, with some architectural-dependent
parts written in assembly. A good understanding of C is required to
kernel development. Assembly (any architecture) is not required unless
you plan to do low-level development for that architecture. Though they
are not a good substitute for a solid C education and/or years of
experience, the following books are good, if anything for reference:
"The C Programming Language" by Kernighan and Ritchie [Prentice Hall]
"Practical C Programming" by Steve Oualline [O'Reilly]
"Programming the 80386" by Crawford and Gelsinger [Sybek]
"UNIX Systems for Modern Architectures" by Curt Schimmel [Addison Wesley]
The kernel is written using GNU C and the GNU toolchain. While it
adheres to the ISO C99 (??) standard, it uses a number of extensions
that are not featured in the standard. It can sometimes be difficult to
understand the assumptions the kernel has on the toolchain and the
extensions that it uses, and unfortunately there is no definitive
reference for them. Please check the gcc info pages (`info gcc`) for
some information on them.
Please remember that you are trying to learn how to work with the
existing development community. It is a very diverse group of people,
with very high standards for coding, style and procedure. These
procedures have been created over time based on what they have found to
work best for such a large and geographically dispersed team. Try to
learn as much as possible about these procedures ahead of time, as they
are well documented, and not expect people to adapt to you, or your
company's way of doing things.
Legal Issues
------------
The Linux kernel source code is released under the GPL. Please see the
file, COPYING, in the main directory of the source tree, for details on
the license. If you have further questions about the license, please
contact a lawyer, and do not ask on the Linux kernel mailing list. The
people on the mailing lists are not lawyers, and you should not rely on
their statements on legal matters.
Documentation
------------
The Linux kernel source tree has a large range of documents that are
invaluable in learning how to interact with the kernel community. When
new features are added to the kernel, it is recommended that new
documentation files are also added, that explain how to use the feature.
Here is a list of files that are in the kernel source tree that are
required reading:
Documetation/CodingStyle
This describes the Linux kernel coding style, and some of the
rationale behind it. All new code is expected to follow the
guidelines in this document. Most maintainers will only accept
patches if these rules are followed, and many people will only
review code if it is in the proper style.
Documentation/SubmittingPatches
Documentation/SubmittingDrivers
These files describe in explicit detail how to successfully create
and send a patch, including (but not limited to):
- Email contents
- Email format
- Who to send it to
Following these rules will not guarantee success (as all patches are
subject to scrutiny of content and style), but not following them
will almost always prevent it.
Other excellent descriptions of how to create patches properly are:
"The Perfect Patch"
http://www.zip.com.au/~akpm/linux/patches/stuff/tpp.txt
"Linux kernel patch submission format"
http://linux.yyz.us/patch-format.html
Documentation/stable_api_nonsense.txt
This file describes the rationale behind the conscious decision to
not have a stable API within the kernel, including for things like:
- Subsystem shim-layers (for compatibility?)
- Driver portability between Operating Systems.
- Mitigating rapid change within the kernel source tree (or
preventing rapid change)
This document is crucial for understand the Linux development
philosophy and is very important for people moving to Linux from
development on other Operating Systems.
Documentation/SecurityBugs
If you feel you have found a security problem in the Linux kernel,
please follow the steps in this document to help notify the kernel
developers, and help solve the issue.
Documentation/ManagementStyle
This document describes how Linux kernel maintainers operate and the
shared ethos behind their methodologies. This is important reading
for anyone new to kernel development (or anyone simply curious about
it), as it resolves a lot of common misconceptions and confusion
about the unique behavior of kernel maintainers.
Documentation/stable_kernel_rules.txt
This file describes the rules on how the stable kernel releases
happen, and what to do if you want to get a change into one of these
releases.
Documentation/kernel-docs.txt
A list of external documentation that pertains to kernel
development. Please consult this list, if you do not find what you
are looking for within the in-kernel documentation.
The kernel also has a large number of documents that can be
automatically generated from the source code itself. This includes a
full description of the in-kernel api, and rules on how to handle
locking properly. The documents will be created in the
Documentation/DocBook/ directory and can be generated as PDF,
Postscript, HTML, and man pages by running:
make pdfdocs
make psdocs
make htmldocs
make mandocs
respectively from the main kernel source directory.
Becoming A Kernel Developer
---------------------------
If you do not know anything about Linux kernel development, you should
look at the Linux KernelNewbies project:
http://kernelnewbies.org
It consists of a helpful mailing list, where you can ask almost any type
of basic kernel development question (make sure to search the archives
first, before asking something that has already been answered in the
past.) It also has a IRC channel that you can use to ask questions in
real-time, and a lot of helpful documentation that is useful for
learning about Linux kernel development.
The website has basic information about code organization, subsystems,
and current projects (both in-tree and out-of-tree). It also basic
logistical information, like compiling a kernel and applying a patch.
If you do not know where you want to start, but you want to look for
some task to start doing to join into the kernel development community,
go to the Linux Kernel Janitor's project:
http://janitor.kernelnewbies.org/
It is a great place to start. It describes a list of relatively simple
tasks that need to be cleaned up and fixed within the Linux kernel
source tree. Working with the developers in charge of this project, you
will learn the basics of getting your patch into the Linux kernel tree,
and possibly point you in the direction of what to go work on next, if
you do not already have an idea.
If you already have a chunk of code that you want to have go into the
kernel tree, but need some help getting it in the proper form, the
kernel-mentors project was created to help you out with this. It is a
mailing list, and can be found at:
http://selenic.com/mailman/listinfo/kernel-mentors
The development process
-----------------------
Mailing lists
-------------
As some of the above documents describe, the majority of the core kernel
developers participate on the Linux Kernel Mailing list. Details on how
to subscribe and unsubscribe from the list, can be found at:
http://vger.kernel.org/vger-lists.html#linux-kernel
There are archives of the mailing list on the web in many different
places. Use a search engine to find these archives. It is highly
recommended that you search the archives about the topic you want to bring
up, before you post it to the list. A lot of things are already discussed
in detail and are only recorded at the mailing list archives.
Most of the individual kernel subsystems also have their own separate
mailing list where they do their development efforts. See the
MAINTAINERS file for a list of what these lists are, for the different
groups.
Many of the lists are hosted on kernel.org. Information on them can be
found here:
http://vger.kernel.org/vger-lists.html
Please remember to follow good behavioral habits when using the lists.
Though a bit cheesy, the following URL has some simple guidelines for
interacting with the list (or any list):
http://www.albion.com/netiquette/
If multiple people respond to your mail, the CC: list of recipients may
get pretty large. Don't remove anybody from the CC: list without a good
reason, or don't reply only to the list address. Get used to receive the
mail twice, one from the sender and the one from the list and don't try
to tune that by adding fancy mail-headers, people will not like it.
Remember to keep the context and the attribution of your replies intact,
keep the "John Kernelhacker wrote ...:" lines at the top of you reply and
add your statements between the individual quoted sections instead of
writing at the top of the mail.
If you add patches to your mail, make sure they are plain readable text
as stated in Documentation/SubmittingPatches. Kernel developers don't
want to deal with attachments or compressed patches, they may want
to comment individual lines of your patch, which works only that way.
Make sure you use a mail program that does not mangle spaces and tab
characters. A good first test is to send the mail to yourself and try
to apply your own patch by yourself. If that doesn't work, get your
mail program fixed or change it until it works.
Above all, please remember to show respect to other subscribers.
Working with the community
--------------------------
The kernel community works differently than most traditional corporate
development environments. Here are a list of things that you can try to
do to try to avoid problems:
Good things to say regarding your proposed changes:
- "This solves multiple problems."
- "This deletes 2000 lines of code."
- "Here is a patch that explains what I am trying to describe."
- "I tested it on 5 different architectures..."
- "Here is a series of small patches that..."
- "This increases performance on typical machines..."
Bad things you should avoid saying:
- "We did it this way in AIX/ptx/Solaris, so therefore it must be
good..."
- "I've being doing this for 20 years, so..."
- "It makes this proprietary benchmark go faster"
- "This is required for my company to make money"
- "This is for our Enterprise product line."
- "Here is my 1000 page design document that describes my idea"
- "I've been working on this for 6 months..."
- "Here's a 5000 line patch that..."
- "I rewrote all of the current mess, and here it is..."
- "I have a deadline, and this patch needs to be applied now."
Another way the kernel community is different than most traditional
software engineering work environments is the faceless nature of
interaction. One benefit of using email and irc as the primary forms of
communication is the lack of discrimination based on gender or race.
The Linux kernel work environment is accepting of women and minorities
because all you are is an email address. The international aspect also
helps to level the playing field because you can't guess gender based on
a person's name. A man may be named Andrea and a woman may be named Pat.
Most women who have worked in the Linux kernel and have expressed an
opinion have had positive experiences. Here is a group that is a good
starting point for women interested in contributing to Linux:
http://www.linuxchix.org/
The language barrier can be present for some people who are not
comfortable with English. A good grasp of the language can be needed in
order to get ideas across properly on mailing lists, so it is
recommended that you check your emails to make sure they make sense in
English before sending them.
Break your changes up
---------------------
The Linux kernel community does not gladly accept large chunks of code
dropped on it all at once. The changes need to be properly introduced,
discussed, and broken up into tiny, individual portions. This is almost
exactly opposite of what companies are used to doing. Your proposal
should also be introduced very early in the development process, so that
you can receive feedback on what you are doing. It also lets the
community feel that you are working with them, and not simply using them
as a dumping ground for your feature. However, don't send 50 emails at
one time to a mailing list, your patch series should be smaller than
that almost all of the time.
The reasons for breaking things up are the following:
1) Small patches increase the likelihood that your patches will be
applied, since they don't take much time or effort to verify for
correctness. A 5 line patch can be applied by a maintainer with
barely a second glance. But, a 500 line patch may take hours to
review for correctness (the time it takes is exponentially
proportional to the size of the patch, or something).
Small patches also make it very easy to debug when something goes
wrong. It's much easier to back out patches one by one, than it is
to dissect a very large patch after it's been applied (and broken
something).
2) It's important not only to send small patches, but also to rewrite
and simplify (or simply re-order) patches before submitting them.
Here is an analogy from kernel developer Al Viro:
"Think of a teacher grading homework from a math student. The
teacher does not want to see the student's trials and errors
before they came up with the solution. They want to see the
cleanest, most elegant answer. A good student knows this, and
would never submit her intermediate work before the final
solution."
The same is true of kernel development. The maintainers and
reviewers do not want to see the thought process behind the
solution to the problem one is solving. They want to see a
simple and elegant solution."
That may be challenging to keep the balance between presenting an elegant
solution and working together with the community and discuss your
unfinished work. Therefore it is good to get early in the process to
get feedback to improve your work, but also keep your changes in small
chunks that they may get already accepted, even when your whole task is
not ready for inclusion now.
Also realize that it is not acceptable to send patches for inclusion
that are unfinished and will be "fixed up later."
Justify your change
-------------------
Along with breaking up your patches, it is very important for you to let
the Linux community know why they should add this change. New features
must be justified as being needed and useful.
All of these things are sometimes very hard to do. It can take years to
perfect these practices (if at all). It's a continuous process of
improvement that requires a lot of patience and determination. But,
don't give up. It's possible. Many have done it before, and each had to
start exactly where you are now.
----------
Thanks to Randy Dunlap and Gerrit Huizenga for the list of things you
should and should not say. Also thanks to Pat Mochel, Hanna Linder,
Randy Dunlap, Kay Sievers, Vojtech Pavlik, and Jan Kara for their review
and comments on early drafts of this document.
Maintainer: Greg Kroah-Hartman
应该把以后每次emerge world记录下来,从今天这次开始
kernel 升级到2.6.14-r2,config 加上了relayfs
vim升级到6.4
mono用1.1.9的ebuild试了一下,还是有问题,不过和1.1.8.3好像不太一样
没时间研究了
触摸板驱动要加到module autoload里才行 还要建立/dev/input/mouse0到/dev/mouse
| Name | Horizontal | Vertical | Multiple | K Pixels |
| QQVGA | 160 | 120 | VGA | 19.2 |
| QCIF | 176 | 144 | CIF | 25.344 |
| QVGA | 320 | 240 | VGA | 76.8 |
| CIF | 352 | 288 | CIF | 101.376 |
| VGA | 640 | 480 | VGA | 307.2 |
| 800 | 600 | 480 | ||
| 1.2 MP | 1280 | 960 | VGA | 1228.8 |
| 1.3 MP | 1280 | 1024 | 1310.72 | |
| 2 MP | 1600 | 1200 | 1920 | |
| 3 MP | 2048 | 1536 | 3145.728 | |
| 2272 | 1704 | 3871.488 | ||
| 4 MP | 2464 | 1648 | 4060.672 | |
| 2240 | 1680 | 3763.2 | ||
| 2304 | 1712 | 3944.448 | ||
| 2292 | 1944 | 4455.648 | ||
| 2560 | 1920 | 4915.2 | ||
| 2588 | 1954 | 5056.952 | ||
| 5 MP | 2592 | 1944 | 5038.848 | |
| 2608 | 1952 | 5090.816 |
1. stop complaining! 别发牢骚!
2. you make me sick! 你真让我恶心!
3. what’s wrong with you? 你怎么回事?
4. you shouldn’t have done that! 你真不应该那样做!
5. you’re a jerk! 你是个废物/混球!
6. don’t talk to me like that! 别那样和我说话!
7. who do you think you are? 你以为你是谁?
8. what’s your problem? 你怎么回事啊?
9. i hate you! 我讨厌你!
10. i don’t want to see your face! 我不愿再见到你!
11. you’re crazy! 你疯了!
12. are you insane/crazy/out of your mind? 你疯了吗?(美国人绝对常用!)
13. don’t bother me. 别烦我。
14. knock it off. 少来这一套。
15. get out of my face. 从我面前消失!
16. leave me alone. 走开。
17. get lost.滚开!
18. take a hike! 哪儿凉快哪儿歇着去吧。
19. you piss me off. 你气死我了。
20. it’s none of your business. 关你屁事!
21. what’s the meaning of this? 这是什么意思?
22. how dare you! 你敢!
23. cut it out. 省省吧。
24. you stupid jerk! 你这蠢猪!
25. you have a lot of nerve. 脸皮真厚。
26. i’m fed up. 我厌倦了。
27. i can’t take it anymore. 我受不了了!(李阳老师常用)
28. i’ve had enough of your garbage. 我听腻了你的废话。
29. shut up! 闭嘴!
30. what do you want? 你想怎么样?
31. do you know what time it is? 你知道现在都几点吗?
32. what were you thinking? 你脑子进水啊?
33. how can you say that? 你怎么可以这样说?
34. who says? 谁说的?
35. that’s what you think! 那才是你脑子里想的!
36. don’t look at me like that. 别那样看着我。
37. what did you say? 你说什么?
38. you are out of your mind. 你脑子有毛病!
39. you make me so mad.你气死我了啦。
40. drop dead. 去死吧!
41. **** off. 滚蛋。
42. don’t give me your shit. 别跟我胡扯。
43. don’t give me your excuses/ no more excuses. 别找借口。
44. you’re a pain in the ass. 你这讨厌鬼。
45. you’re an asshole. 你这缺德鬼。
46. you bastard! 你这杂种!
47. get over yourself. 别自以为是。
48. you’re nothing to me. 你对我什么都不是。
49. it’s not my fault. 不是我的错。
50. you look guilty. 你看上去心虚。
51. i can’t help it. 我没办法。
52. that’s your problem. 那是你的问题。
53. i don’t want to hear it. 我不想听!
54. get off my back. 少跟我罗嗦。
55. give me a break. 饶了我吧。
56. who do you think you’re talking to? 你以为你在跟谁说话?
57. look at this mess! 看看这烂摊子!
58. you’re so careless. 你真粗心。
59. why on earth didn’t you tell me the truth? 你到底为什么不跟我说实话?
60. i’m about to explode! 我肺都快要气炸了!
61. what a stupid idiot! 真是白痴一个!
62. i’m not going to put up with this! 我再也受不了啦!
63. i never want to see your face again! 我再也不要见到你!
64. that’s terrible. 真糟糕!
65. just look at what you\\’ve done! 看看你都做了些什么!
66. i wish i had never met you. 我真后悔这辈子遇到你!
67. you’re a disgrace. 你真丢人!
68. i’ll never forgive you! 我永远都不会饶恕你!
69. don’t nag me! 别在我面前唠叨!
70. i’m sick of it. 我都腻了。
71. you’re such a *****! 你这个*子!
72. stop screwing/ fooling/ messing around! 别鬼混了!
73. mind your own business! 管好你自己的事!
74. you’re just a good for nothing bum! 你真是一个废物!/ 你一无是处!
75. you’ve gone too far! 你太过分了!
76. i loathe you! 我讨厌你!
77. i detest you! 我恨你!
78. get the hell out of here! 滚开!
79. don’t be that way! 别那样!
80. can’t you do anything right? 成事不足,败事有余。
81. you’re impossible. 你真不可救药。
82. don’t touch me! 别碰我!
83. get away from me! 离我远一点儿!
84. get out of my life. 我不愿再见到你。/ 从我的生活中消失吧。
85. you’re a joke! 你真是一个小丑!
86. don’t give me your attitude. 别跟我摆架子。
87. you’ll be sorry. 你会后悔的。
88. we’re through. 我们完了!
89. look at the mess you\\’ve made! 你搞得一团糟!
90. you’ve ruined everything. 全都让你搞砸了。
91. i can’t believe your never. 你好大的胆子!
92. you’re away too far. 你太过分了。
93. i can’t take you any more! 我再也受不了你啦!
94. i’m telling you for the last time! 我最后再告诉你一次!
95. i could kill you! 我宰了你!
96. that’s the stupidest thing i\\’ve ever heard! 那是我听到的最愚蠢的事!(
比尔·盖茨常用)
97. i can’t believe a word you say. 我才不信你呢!
98. you never tell the truth! 你从来就不说实话!
99. don’t push me ! 别逼我!
100. enough is enough! 够了够了!
101. don’t waste my time anymore. 别再浪费我的时间了!
102. don’t make so much noise. i\\’m working. 别吵,我在干活。
103. it’s unfair. 太不公平了。
104. i’m very disappointed. 真让我失望。
105. don’t panic! 别怕!
106. what do you think you are doing? 你知道你在做什么吗?
107. don’t you dare come back again! 你敢再回来!
108. you asked for it. 你自找的。
109. nonsense! 鬼话!
主要是些AVI文件
只需要把下面这个注册表项删掉就可以了
HKEY_LOCAL_MACHINE/SOFTWARE/Classes/CLSID/{87D62D94-71B3-4b9a-9489-5FE6850DC73E}/InProcServer32
好像是因为DriectX的一个dll 问题
微软官方都不管这事?
唉,其实标准内核的ALSA已经足够用了
不必单独emerge alsa-driver
反倒会在老笔记本的老Intel的老声卡上出问题
用genkernel的alsa很好
很好
按照gentoo alsa document
关掉genkernel里的oss 和alsa,留着sound=y
然后emerge alsa-driver alsa-utils alsa-tools
rc-update del esound default
rc-update add alsasound default
运行aslaconf,找到破声卡
似乎没问题了
然而发现X起来的时候出来好几个不能调节音量的错误信息
mplayer在-ao oss模式下一切正常
但是在-ao alsa只能root出声,普通用户不出声
在google上查到要把普通用户加到audio组里
但是在user and group management里没有audio组
发现下面有一个打钩的地方显示所有用户和组
打钩
加到audio里,还是一样啊?!
没辙了
进irc问别人吧
一个叫Chris什么的人回答要logout completely才行
呵呵
果然如此
出现数个不能调节音量的错误是因为自己过去加了好几个applet但是都没有显示出来
BTW,这个Chris回答过好几个问题了,相信他肯定不记得我
也就是说他整天挂在irc channel里,啥问题都能回答。。。
$ cat helloqt.cxx
#include "qapplication.h"
#include "qlabel.h"
int main( int argc , char **argv )
{
QApplication app( argc , argv ) ;
QLabel *hello = new QLabel(
"《font color=blue》Hello 《i》QT《/i》""《/font》",
0 ) ;
app.setMainWidget( hello ) ;
hello->show() ;
return app.exec() ;
}
$ g++ helloqt.cxx -o helloqt -I/usr/qt/3/include -L/usr/qt/3/lib -lqt
$ ./helloqt
先cvs checkout -l -d dir .
-l 是 local的意思
-d是指定的目录
然后 cd dir
把module原来的目录copy过来
然后cvs add moduledir
然后cvs commit
然后进入moduledir
再cvs commit
Setting up a Win32 Toolchain with SDL and wxWidgets in Gentoo
Everyone of us always wanted to have the ability to compile for Windows and Unix in one makefile, right?
Unfortunately, there is very few documentation on this topic and I had quite a hard time to get things working the way I wanted to. I wrote this small HOWTO to share the way I managed to build my toolchain to other people.
I like writing games and most gamers use Windows. I didn’t want to leave my Linux setup to compile the games for Windows, so I needed a MingW toolchain with SDL and wxWidgets, for those are the two cross platform APIs I use.
Compiling the toolchain
Here we can go with ebuilds, there are some nice in the portage tree:
emerge xmingw-binutils
emerge xmingw-gcc
emerge xmingw-w32api
emerge xmingw-runtime
emerge xmingw-gcc
You have to do it in this order and you have to compile gcc twice, yes. If you don’t you wont get a c++ compiler, i don’t know exactly why.
Gentoo will put the toolchain into /opt/xmingw.
Setting the environment variables
Everytime you want to compile something for Windows, you have to set some environment variables first. The best is to put them into a small script:
export PATH="/opt/xmingw/bin:/opt/xmingw/i386-mingw32msvc/bin:$PATH"
export CC="i386-mingw32msvc-gcc"
export CXX="i386-mingw32msvc-g++"
unset CFLAGS
unset CPPFLAGS
unset CXXFLAGS
unset LDFLAGS
export CFLAGS="-I/opt/xmingw/i386-mingw32msvc/include"
export CXXFLAGS="-I/opt/xmingw/i386-mingw32msvc/include"
After you have set the environment variables you can configure a program to compile for Win32 by running ./configure --target=i386-mingw32msvc --host=i386-mingw32msvc --build=i386-linux
Compiling SDL
Download the latest cvs version of SDL from here. Untar it into a working directory and cd into SDL-1.2/. Now run your script to set the environment variables mentioned above. After that you can configure SDL:
./autogen.sh
./configure --target=i386-mingw32msvc --host=i386-mingw32msvc
--build=i386-linux --enable-cdrom --enable-threads --enable-timers
--enable-endian --enable-file --enable-cpuinfo --enable-opengl
--disable-shared --prefix=/opt/xmingw/i386-mingw32msvc
–disable-shared will even remove the dependency on SDL.dll, if you don’t want that, leave this parameter out.
Now you can call make and make install. If you have to su to run make install, don’t forget to set your environment variables again (I forgot that at first).
Now for a little tweak: cd into /opt/xmingw/i386-mingw32msvc/bin and create a symbolic link.
ln -s i386-mingw32msvc-sdl-config sdl-config
This way, if you run sdl-config in your Makefile, the right sdl-config will be executed. (wxWidgets does this automatically for wx-config)
Compiling wxWidgets
Download a wxAll package from here. I used 2.4.2, I didn’t try any newer versions. Untar it and cd into wxWindows-2.4.2/.
Don’t forget to run your environment script and then run
./autogen.sh
./configure --target=i386-mingw32msvc --host=i386-mingw32msvc --build=i386-linux --with-msw --disable-threads --disable-shared --disable-unicode --with-opengl --prefix=/opt/xmingw/i386-mingw32msvc
I recommend to disable threads because else the programs will depend on some MingW libraries. You should also disable shared, because else the programs will depend on the wxWidgets libraries (and I think I ran into some more trouble). If you don’t disable unicode, the programs will only work on WinNT/2k/XP, not on 9x.
After that you can run make and make install just like you did for SDL.
Now you should have a fully working MingW+SDL+wxWidgets toolchain. I compiled 2 games I made and they ran fine in wine after compiling. I didn’t test them on Windows, yet but I strongly believe they will run. If you run into troubles, please report them to me.
make -C /usr/src/linux-2.6.12 M=`pwd` modules
Makefile:
obj-m := helloworld.o
helloworld.c:
#include 《linux/init.h》
#include 《linux/module.h》
MODULE_LICENSE( "Dual BSD/GPL" );
static int hello_init( void )
{
printk( KERN_ALERT "Hello, world!\n" ) ;
return 0 ;
}
static void hello_exit( void )
{
printk( KERN_ALERT "Goodbye, cruel world\n" ) ;
}
module_init( hello_init ) ;
module_exit( hello_exit ) ;
如果出telnetd: All network ports in use.
那可能是
/etc/fstab中的devpts没有mount
none /dev/pts devpts noauto,gid=5,mode=620 0 0
身份证号码15位升18位
身份证18位验证
18位身份证标准在国家质量技术监督局于1999年7月1日实施的GB11643-1999《公民身份号码》中做了明确的规定。 GB11643-1999《公民身份号码》为GB11643-1989《社会保障号码》的修订版,其中指出将原标准名称"社会保障号码"更名为"公民身份号码",另外GB11643-1999《公民身份号码》从实施之日起代替GB11643-1989。GB11643-1999《公民身份号码》主要内容如下:
一、范围
该标准规定了公民身份号码的编码对象、号码的结构和表现形式,使每个编码对象获得一个唯一的、不变的法定号码。
二、编码对象
公民身份号码的编码对象是具有中华人民共和国国籍的公民。
三、号码的结构和表示形式
1、号码的结构
公民身份号码是特征组合码,由十七位数字本体码和一位校验码组成。排列顺序从左至右依次为:六位数字地址码,八位数字出生日期码,三位数字顺序码和一位数字校验码。
2、地址码
表示编码对象常住户口所在县(市、旗、区)的行政区划代码,按GB/T2260的规定执行。
3、出生日期码
表示编码对象出生的年、月、日,按GB/T7408的规定执行,年、月、日代码之间不用分隔符。
4、顺序码
表示在同一地址码所标识的区域范围内,对同年、同月、同日出生的人编定的顺序号,顺序码的奇数分配给男性,偶数分配给女性。
5、校验码
(1)十七位数字本体码加权求和公式
S = Sum(Ai * Wi), i = 0, ... , 16 ,先对前17位数字的权求和
Ai:表示第i位置上的身份证号码数字值
Wi:表示第i位置上的加权因子
Wi: 7 9 10 5 8 4 2 1 6 3 7 9 10 5 8 4 2
(2)计算模
Y = mod(S, 11)
(3)通过模得到对应的校验码
Y: 0 1 2 3 4 5 6 7 8 9 10
校验码: 1 0 X 9 8 7 6 5 4 3 2
四、举例如下:
北京市朝阳区: 11010519491231002X
广东省汕头市: 440524188001010014
15位升18的方法
根据〖中华人民共和国国家标准 GB 11643-1999〗中有关公民身份号码的规定,公民身份号码是特征组合码,由十七位数字本体码和一位数字校验码组成。排列顺序从左至右依次为:六位数字地址码,八位数字出生日期码,三位数字顺序码和一位数字校验码。
地址码表示编码对象常住户口所在县(市、旗、区)的行政区划代码。生日期码表示编码对象出生的年、月、日,其中年份用四位数字表示,年、月、日之间不用分隔符。顺序码表示同一地址码所标识的区域范围内,对同年、月、日出生的人员编定的顺序号。顺序码的奇数分给男性,偶数分给女性。校验码是根据前面十七位数字码,按照ISO 7064:1983.MOD 11-2校验码计算出来的检验码。下面举例说明该计算方法。
15位的身份证编码首先把出生年扩展为4位,简单的就是增加一个19,但是这对于1900年出生的人不使用(这样的寿星不多了)
某男性公民身份号码本体码为34052419800101001,首先按照公式⑴计算:
∑(ai×Wi)(mod 11)……………………………………(1)
公式(1)中:
i----表示号码字符从由至左包括校验码在内的位置序号;
ai----表示第i位置上的号码字符值;
Wi----示第i位置上的加权因子,其数值依据公式Wi=2(n-1)(mod 11)计算得出。
i 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
ai 3 4 0 5 2 4 1 9 8 0 0 1 0 1 0 0 1 a1
Wi 7 9 10 5 8 4 2 1 6 3 7 9 10 5 8 4 2 1
ai×Wi 21 36 0 25 16 16 2 9 48 0 0 9 0 5 0 0 2 a1
根据公式(1)进行计算:
∑(ai×Wi) =(21+36+0+25+16+16+2+9+48++0+0+9+0+5+0+0+2) = 189
189 ÷ 11 = 17 + 2/11
∑(ai×Wi)(mod 11) = 2
然后根据计算的结果,从下面的表中查出相应的校验码,其中X表示计算结果为10:
∑(ai×WI)(mod 11) 0 1 2 3 4 5 6 7 8 9 10
校验码字符值ai 1 0 X 9 8 7 6 5 4 3 2
根据上表,查出计算结果为2的校验码为所以该人员的公民身份号码应该为 34052419800101001X。
哈哈,用proz代替wget了
# These settings were set by the catalyst build script that automatically built this stage
# Please consult /etc/make.conf.example for a more detailed example
CFLAGS="-O3 -march=i686 -fomit-frame-pointer"
CHOST="i686-pc-linux-gnu"
CXXFLAGS="${CFLAGS}"
USE="MONO wxwindows"
FETCHCOMMAND="/usr/local/bin/proz -f -r --no-getch \${URI} && mv \${FILE} \${DISTDIR}"
GENTOO_MIRRORS="http://10.180.0.25
http://ftp.linuxforum.net/gentoo/
http://www.zentek-international.com/mirrors/gentoo/
http://ftp.gentoo.or.kr/
http://mirror.gentoo.gr.jp http://gentoo.gg3.net/"
xm create -c configfile vmid=1
Error: Error creating domain: vbd: Segment not found:
uname=file:/root/ttylinux
Pls make sure you have a correct path...
以前写过一个blog是关于hack Makefile的,不过是2.4下。
现在需要在2.6的makefile里做同样的事
修改./scripts/Makefile.build
+CBD_S_cc_o_c = $(CC) $(c_flags) -S -o $*.s \
+ $(if $(filter-out /%,$<),$(srctree)/$<,$<)
%.o: %.c FORCE
$(call cmd,force_checksrc)
+ $(call CBD_S_cc_o_c)
$(call if_changed_rule,cc_o_c
即可
以前改的也存下档吧,省得找不到了
为了查汇编文件输出
Rule.make
...
[snip]
%.o: %.c
$(CC) $(CFLAGS) $(EXTRA_CFLAGS_nostdinc) -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) $(CFLAGS_$@) -S $<
$(CC) $(CFLAGS) $(EXTRA_CFLAGS_nostdinc) -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) $(CFLAGS_$@) -c -o $@ $<
[snip]
...
使用方法 mycount.sh "*.ext"
没有处理目录,懒了
bash-2.05b$ cat ~/bin/mycount.sh
#!/bin/sh
total=0
list=`ls $1`
for item in $list
do
size=`ls -l $item|awk '{print $5}'`
total=`expr $total + $size`
done
echo $total
有可能是in.telnetd的可执行属性不对
原因是ISA没有编译内核
原来老的pcmcia卡还是被模拟成isa设备的
:(
对了,还要在/etc/modules.autoload.d/kernel-2.6中加入
yenta_socket
也许算第二次了,不过上一次是因为参照bugs.gentoo.org上针对d4x-2.5.0不能在
gnome 2.6的编译照着葫芦画了个瓢
这次是因为发现gcov在ppc的结果不正常想要看gcov的中间过程
而gcov是gcc的一部分,如果自己编译gcc那可就太麻烦了
幸好有gentoo,gentoo有ebuild
hack步骤如下:
emerge --fetchonly gcc-3.3.5-20050130
然后tar xvjf gcc-xxx.tar.bz2
然后分别创建目录
mkdir gcc-3.3.5-orig/gcc
mkdir gcc-3.3.5-dbg/gcc
cp gcc-3.3.5/gcc/gcov.c gcc-3.3.5-orig/gcc
cp gcc-3.3.5/gcc/gcov.c gcc-3.3.5-dbg/gcc
只复制一个文件是为了patch小一点
然后修改gcov
然后diff -Nur gcc-3.3.5-orig gcc-3.3.5-dbg > gcov-cbd.patch
然后把patch放到/usr/portage/sys-devel/gcc/files
然后改ebuild文件
加一条epatch ${FILESDIR}/gcov-cbd.patch
然后emerge gcc-xxx.ebuild就可以了
今天和同事争论make kernel之后/boot里的initrd-$(version).img从哪里来的问题
虽然我知道肯定是make kernel的时候搞出来的,但是具体怎么做的还真没仔细研究过
正好2.4.30出来了,按惯例也要装上去一用,就顺便把这个未知的东西搞搞清楚。
结论如下:
make install ->
./Makefile (ln261) include arch/$(ARCH)/Makefile ->
./arch/$(ARCH)/Makefile (ln119) $(MAKEBOOT) = Make -C arch/$(ARCH)/boot ->
./arch/$(ARCH)/boot/Makefile (ln40) sh -x ./install.sh ... ... ->
./arch/$(ARCH)/boot/install.sh (ln25) /sbin/installkernel ->
/sbin/installkernel (ln65) new-kernel-pkg ...
Disable Targets For Downloads
forecastfox
/sbin/service
#!/bin/sh
/etc/init.d/$1 $2
启动cups
/sbin/service cups start
然后
gnome-cups-add
LANGUAGE=zh_CN.GB2312
LANG=zh_CN.GB2312
LC_ALL=zh_CN.GB2312
KDE_LANG=zh_CN.GB2312
G_BROKEN_FILENAMES=zh_CN.GB2312
export LANGUAGE LANG LC_ALL KDE_LANG G_BROKEN_FILENAMES
export XMODIFIERS=@im=fcitx
export DISPLAY=:0.0
exec fcitx &
X &
exec gnome-session
编辑.xinitrc
内容为:
export DISPLAY=:0.0
X &
exec gnome-session
在/etc/init.d/下把eth0复制一份 /etc/init.d/net.eth1
改/etc/conf.d/net内容设置eth1
以前改的也存下档吧,省得找不到了
为了查汇编文件输出
Rule.make
...
[snip]
%.o: %.c
$(CC) $(CFLAGS) $(EXTRA_CFLAGS_nostdinc) -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) $(CFLAGS_$@) -S $<
$(CC) $(CFLAGS) $(EXTRA_CFLAGS_nostdinc) -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) $(CFLAGS_$@) -c -o $@ $<
[snip]
...
man gcc
[snip]
-E Stop after the preprocessing stage; do not run the compiler proper.
The output is in the form of preprocessed source code, which is
sent to the standard output.
Input files which don't require preprocessing are ignored.
[snip]
-P Inhibit generation of linemarkers in the output from the preproces-
sor. This might be useful when running the preprocessor on some-
thing that is not C code, and will be sent to a program which might
be confused by the linemarkers.
2.4 kernel /driver/block/blkpg.c 在用了新编译器后有问题,需要输出preprocess信息检查
改/driver/block/Makefile如下
#
# Makefile for the kernel block device drivers.
#
# 12 June 2000, Christoph Hellwig
# Rewritten to use lists instead of if-statements.
#
# Note : at this point, these files are compiled on all systems.
# In the future, some of these should be built conditionally.
#
O_TARGET := block.o
export-objs := ll_rw_blk.o blkpg.o loop.o DAC960.o genhd.o
obj-y := ll_rw_blk.o blkpg.o genhd.o elevator.o
[snip] ... [snip]
include $(TOPDIR)/Rules.make
blkpg.o: blkpg.c
$(CC) $(CFLAGS) $(EXTRA_CFLAGS_nostdinc) -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) $(CFLAGS_$@) -E -P $<
$(CC) $(CFLAGS) $(EXTRA_CFLAGS_nostdinc) -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) $(CFLAGS_$@) -c -o $@ $<
我经常需要修改笔记本电脑的IP地址,在图形界面下修改IP地址很不方便,可不可以用批处理的方式自动修改IP地址呢?
climbmount答:你可以用netsh在命令行的方式下修改IP地址,也可以把它写成批处理,这样就简单多了。
D:\>netsh
netsh>ip
netsh>interface
netsh interface>ip
此上下文中的命令:
set address - 设置指定的接口的 IP 地址或默认网关。
set dns - 设置 DNS 服务器模式和地址。
set wins - 设置 WINS 服务器模式和地址。
netsh interface ip>set address
用法: set address [name=]
[[source=]dhcp |
[source=] static [addr=]IP address [mask=]IP subnet mask]
[[gateway=]
参数:
标记 值
name - 接口名称。
source - 下列值之一:
dhcp: 对于指定接口,设置用 DHCP 配置 IP地址。
static: 设置使用本地静态配置设置IP地址。
gateway - 下列值之一:
none: 不设置默认网关。
gwmetric - 默认网关的跃点数。如果网关设置为 'none',则不应设置此字段。
只有在 'source' 为 'static' 时才设置下列选项:
addr - 指定接口的 IP 地址。
mask - 指定 IP 地址的子网掩码。
示例: set address name="Local Area Connection" source=dhcp
set address local static 10.0.0.9 255.0.0.0 10.0.0.1 1
上面是用netsh一步步进入的,实际上你可以用一条命令直接在DOS修改IP地址,如:
Netsh interface ip set address local static 10.0.0.9 255.0.0.0 10.0.0.1 1
注意:上面的参数都不能省略,网关没有的话请写none,有网关是跃点数通常写1。
想想看,如果你因为移动的原因经常需要把笔记本的IP地址在两个IP之间改来改去,只需要做好两个批处理然后在需要的时候执行它们就可以了。
介都谁琢磨的呀
--------------------------------
新浪越野联盟路况分级标准
(由jeeprider编制,新浪网切大队2003年讨论通过,2004年正式施行)
第一级:铺装路面, 包括高速, 国道, 省道等 平坦相对少连续弯道;(4X2)
第二级:铺装路面, 连续盘山路面, 弯多, 过弯时无可视前方角度及平坦的土路, 碎石路面;(4X2)
第三级:土路, 碎石, 连续盘山路面,坡度10度,有20CM以下的硬底涉水,及冰雪覆盖的2级路面;(4X2)
第四级:冰雪覆盖的3级路面及较多10CM左右的凹凸, 石块,10CM深的长距离泥路,35CM的硬底涉水,坡度18度以下的非铺装路面,长距离软性沙地;(4X4或配有驾驶经验丰富的4X2车辆)
第五级:20CM积雪路面,20CM深的长距离泥路,坡度23以下碎石路面;(4X4)
第六级:道路很窄,有30cm高的石块,50CM的硬底涉水,有需要查看才能通过的泥潭,坡度25度以下碎石路面障碍,需要熟练的越野车驾驶水平,偶尔需要副驾驶员协助;(4X4)
第七级:道路极其狭窄,仅够车辆勉强通过,经常有30cm凹凸,30cm深的泥潭并且上坡,70cm的硬底涉水,需要熟练的越野车驾驶水平和丰富道路判断经验,需要副驾驶协助驾驶通过,有些风险,车辆需要适当改造;(4X4)
第八级:难度高于以上级别, 车辆需高可靠性的改装和携带辅助装置,及人为选择必须通过以上全部级别障碍的路面,需 要极其丰富的驾驶经验和必须依靠辅助驾驶员协助,风险比较大;(4X4)
系统安全:Linux 系统下的病毒发展及其分类
1996年的Staog是Linux系统下的第一个病毒,它出自澳大利亚一个叫VLAD的组织(Windows 95下的第一个病毒程序Boza也系该组织所为)。Staog病毒是用汇编语言编写,专门感染二进制文件,并通过三种方式去尝试得到root权限。 Staog病毒并不会对系统有什么实质性的损坏。它应该算是一个演示版。它向世人揭示了Linux可能被病毒感染的潜在危险。Linux系统上第二个被发现的病毒是Bliss病毒,它是一个不小心被释放出来的实验性病毒。与其它病毒不同的是,Bliss本身带有免疫程序,只要在运行该程序时加上 “disinfect-files-please”选项,即可恢复系统。
如果说刚开始时Linux病毒向人们展示的仅仅是一个概念,那么,在2001年发现的Ramen病毒,则已经开始引起很多人的担心。Ramen病毒可以自动传播,无需人工干预,所以和1988年曾使人们大受其苦的 Morris蠕虫非常相似。它只感染Red Hat 6.2和7.0版使用匿名FTP服务的服务器,它通过两个普通的漏洞RPC.statd和wu-FTP感染系统。
表面看来,这不是一个危险的病毒。它很容易被发现,且不会对服务器做出任何有破坏性的事情。但是当它开始扫描时,将消耗大量的网络带宽。
从1996年至今,新的Linux病毒屈指可数,这说明Linux是一个健壮的具有先天病毒免疫能力的操作系统。当然,出现这种情况,除了其自身设计优秀外,还有其它的原因。
首先,Linux早期的使用者一般都是专业人士,就算是今天,虽然其使用者激增,但典型的使用者仍为那些有着很好的电脑背景且愿意帮助他人的人, Linux 高手更倾向于鼓励新手支持这样一种文化精神。正因为如此,Linux使用群中一种倾向就是以安全的经验尽量避免感染病毒。其次,年轻,也是Linux很少受到病毒攻击的原因之一。事实上,所有的操作系统(包括DOS和Windows)在其产生之初,也很少受到各种病毒的侵扰
然而, 2001年3月,美国SANS学院的全球事故分析中心(Global Incident Analysis Center——GIAC)发现,一种新的针对使用Linux系统的计算机的蠕虫病毒正通过互联网迅速蔓延,它将有可能对用户的电脑系统造成严重破坏。这种蠕虫病毒被命名为“狮子”病毒,与Ramen蠕虫病毒非常相似。但是,这种病毒的危险性更大,“狮子”病毒能通过电子邮件把一些密码和配置文件发送到一个位于china.com的域名上。Dartmouth学院安全技术研究所工程师威廉·斯蒂恩斯说:“攻击者在把这些文件发回去之后就可以通过第一次突破时的缺口再次进入整个系统。这就是它与Ramen蠕虫病毒的不同之处。事实上,Ramen病毒是一种比较友善的病毒,它在侵入系统后会自动关闭其中的漏洞,而这个病毒却让那些漏洞敞开并开辟新的漏洞。以至于如果你的系统感染了这个病毒,我们不能百分之百确信这个系统有挽救的价值,更加合理的选择很有可能是转移你的数据并且重新格式化硬盘。”
一旦计算机被彻底感染,“狮子”病毒就会强迫电脑开始在互联网上搜寻别的受害者。不过,感染“狮子”病毒的系统少于感染Ramen病毒的系统,但是它所造成的损失却比后者大得多。
随着Klez病毒在Linux平台上的传染,防毒软件厂商开始提醒我们微软的操作系统不再是唯一易受病毒攻击的操作系统了。即使Linux和其他一些主流 UNIX平台的用户可能不是微软捆绑应用软件的大用户,不可能通过这些软件造成病毒的泛滥,Linux和UNIX仍然有它们自身并不引人注目的脆弱点。除了Klez以外,其他Linux/UNIX平台的主要威胁有:Lion.worm、OSF.8759病毒、Slapper、Scalper、 Linux.Svat和BoxPoison病毒,这些都很少被提及。
病毒的制造者是一些精通编写代码的黑客,他们远比那些胡乱涂改网站却对编写病毒知之甚少的黑客要危险。一个被黑掉的网站可以很快修好,而病毒却更加隐蔽,会带来潜在的安全隐患,它会一直潜伏,直到给系统带来不可挽回的损害。
另外,越多的Linux系统连接到局域网和广域网,就会有越多受攻击的可能,这是因为很多Linux病毒正在快速地扩散着。使用WINE的 Linux/UNIX系统特别容易受到病毒的攻击。WINE是一个公开源代码的兼容软件包,能让Linux平台运行Windows应用软件。 WINE系统特别容易遭受病毒的攻击,因为它们会使无论是对Linux的还是对 Windows的病毒、蠕虫和木马都能对系统产生威胁。
Linux平台下的病毒分类
可执行文件型病毒:可执行文件型病毒是指能够寄生在文件中的,以文件为主要感染对象的病毒。病毒制造者们无论使用什么武器,汇编或者C,要感染ELF 文件都是轻而易举的事情。这方面的病毒如Lindose,当其发现一个ELF文件时,它将检查被感染的机器类型是否为Intel 80386,如果是,则查找该文件中是否有一部分的大小大于 2,784字节(或十六进制AEO),如果满足这些条件,病毒将用自身代码覆盖它并添加宿主文件的相应部分的代码,同时将宿主文件的入口点指向病毒代码部分。一个名为Alexander Bartolich的学生发表了一篇名为《如何编写一个Linux的病毒》的文章,详细描述了如何制作一个感染在Linux/i386的ELF可执行文件的寄生文件病毒。有了这样具启发性的、在网上发布的文档,基于Linux的病毒数量只会增长的更快,特别是自Linux的应用越来越广泛之后。
蠕虫(worm)病毒:1988年Morris蠕虫爆发后,Eugene H. Spafford 为了区分蠕虫和病毒,给出了蠕虫的技术角度的定义,“计算机蠕虫可以独立运行,并能把自身的一个包含所有功能的版本传播到另外的计算机上。” (worm is a program that can run by itself and can propagate a fully working version of itself to other machines. )。在Linux平台下,蠕虫病毒极为猖獗,像利用系统漏洞进行传播的ramen,lion,Slapper……这些臭名远播的家伙每一个都感染了大量的 Linux系统,造成了巨大的损失。它们就是开放原代码世界的nimda,红色代码。在未来,这种蠕虫病毒仍然会愈演愈烈,Linux系统应用越广泛,蠕虫的传播程度和破坏能力也会随之增加。
脚本病毒:目前出现比较多的是使用shell脚本语言编写的病毒。此类病毒编写较为简单,但是破坏力同样惊人。我们知道,Linux系统中有许多的以.sh结尾的脚本文件,而一个短短十数行的shell脚本就可以在短时间内遍历整个硬盘中的所有脚本文件,进行感染。因此病毒制造者不需要具有很高深的知识,就可以轻易编写出这样的病毒,对系统进行破坏,其破坏性可以是删除文件,破坏系统正常运行,甚至下载一个木马到系统中等等。
后门程序:在广义的病毒定义概念中,后门也已经纳入了病毒的范畴。活跃在Windows系统中的后门这一入侵者的利器在Linux平台下同样极为活跃。从增加系统超级用户账号的简单后门,到利用系统服务加载,共享库文件注射,rootkit工具包,甚至可装载内核模块(LKM),Linux平台下的后门技术发展非常成熟,隐蔽性强,难以清除。是Linux系统管理员极为头疼的问题。
病毒、蠕虫和木马基本上意味着自动化的黑客行为,也许被病毒攻击比被黑客攻击更可能发生。直接的黑客攻击目标一般是服务器,而病毒是等机会的麻烦制造者。如果你的网络包含了Linux系统,特别危险的是服务器,不要在作出反应之前等待寻找Linux病毒、蠕虫和木马是否存在。做一些调查然后选择一个适合你系统的防毒产品,它们能帮你防止病毒的传播。至于Linux平台病毒在未来的发展,一切皆有可能。Windows下的病毒发展史,也有可能在 Linux上重演,这取决于Linux的发展。
发布人:snow 来自:eNet硅谷动力
CSDN - 文档中心 - 其他 阅读:72 评论: 0 参与评论
标题 FireFox的几个小技巧(提高浏览速度) 选择自 ycool1984 的 Blog
关键字 FireFox的几个小技巧(提高浏览速度)
出处
1. Enalbe IPv6。大部分网站使用IPv4协议,在FF里IPv6默认是disabled的,所以打开IPv6,对支持IPv6的网站会提高浏览速度。 具体步骤: a. 在FF地址栏里输入:about:config; b. 然后找到Network.dns.disableIPv6,双击后,其键值由"false"变为"true"; c. 重启FF后生效。 2. 另外如下设置也会提高浏览速度:具体步骤同上。 network.http.max-connections: 48 network.http.max-connections-per-server: 24 network.http.max-persistent-connections-per-proxy: 12 network.http.max-persistent-connections-per-server: 6 network.http.pipelining: true network.http.pipelining.maxrequests: 32 network.http.proxy.pipelining: true 3。地址栏自动填入完成。 FF虽然也能记忆以前输入的地址,但只是在下拉菜单里,并不直接把最相近的地址显示在地址栏里。如下设置会完成此功能: a. 在FF地址栏里输入:about:config; b. 右击任何空白处,选new->boolean,然后输入browser.urlbar.autoFill,设置成"true"; c. 同上步骤建立browser.urlbar.autocomplete.enabled d. 重启FF后生效。
作者Blog:http://blog.csdn.net/ycool1984/
What's new in Python 2.4
Here are the (subjective) highlights of what's new in Python 2.4.
Faster
A number of modules that were added in Python 2.3 (such as sets and heapq) have been recoded in C. In addition, there's been a number of other speedups to the interpreter. (See section 8.1, Optimizations, of the "What's New" document for more).
New language features
* multi-line imports - when using imports in the form from foo import bar, baz, bing, bang, you can surround the imported names with brackets, and they can be split across lines. This is part of PEP 328.
* Farewell to OverflowWarning - as documented in PEP 237, Python no longer generates OverflowWarnings.
* function/method decorators - function and method decorators, first described in PEP 318, have been added to the language, using 'pie-decorator' syntax. Decorators are on the line before the 'def', and prefixed with an '@' sign. (PEP 318)
* Assigning to None - the compiler now treats assigning to None as a SyntaxError.
* Failed import cleanup - when a module import failed, versions of Python prior to 2.4a2 would leave a broken module in sys.modules - subsequent attempts to import the failing module would silently succeed, but use the broken module object. The import machinery now removes the failing module from sys.modules if the import fails.
* The -m command line option - python -m modulename will find a module in the standard library, and invoke it. For example, python -m pdb is equivalent to python /usr/lib/python2.4/pdb.py
New or upgraded built-ins
* built-in sets - the sets module, introduced in 2.3, has now been implemented in C, and the set and frozenset types are available as built-in types (PEP 218)
* unification of integers and long integers - an operation that would return a number too big for an integer will automatically return a long integer. (PEP 237)
* generator expressions - generator expressions are similar to a list comprehension, but instead of creating the entire list of results they create a generator that returns the results one by one. This allows for efficient handling of very large lists. (PEP 289)
* reversed() - a new builtin that takes a sequence and returns an iterator that loops over the elements of the sequence in reverse order (PEP 322)
* new sort() keyword arguments - sort() now accepts keyword arguments cmp, key and reverse
* sorted() - a new builtin sorted() acts like an in-place list.sort() but can be used in expressions, as it returns a copy of the sequence, sorted.
* string methods - strings gained an rsplit() method, and the string methods ljust(), rjust() and center() accept an argument to specify the fill character.
* eval() now accepts any form of object that acts as a mapping as its argument for locals, rather than only accepting a dictionary. There's all sorts of new and shiny evil possible thanks to this little change.
New or upgraded modules and packages
* a new subprocess module for spawning processes in a platform-independent way (see PEP 324)
* decimal - a new numeric type that allows for the accurate representation of floating point numbers (avoiding the problems of binary floating point) (PEP 327)
* os.urandom() has been added for systems that support a source of random data (entropy)
* The mpz, rotor and xreadlines modules have been removed.
* The difflib module now includes an HtmlDiff class that creates an HTML table showing a side by side comparison of two versions of a text.
* The socket module gained the socketpair() function, on systems that support it.
* os.path.lexists(), which tests whether the path is a symlink.
* The doctest module has been massively refactored, with many new features added, and many new hooks for customizing behavior.
* Non-blocking SSL sockets work again.
* time.strptime() can now infer the date using %U or %W (week of the year) when the day of the week and year are also specified.
* The optparse module was updated to Optik 1.5a1.
* The new module cookielib supports client-side HTTP cookies. urllib2 gained a new class HTTPCookieProcessor that uses this new module.
* The CJKCodecs collection of East Asian codecs, maintained by Hye-Shik Chang, was integrated into 2.4.
* The email package's Parser was completely rewritten to better handle malformed email messages. It should now never fail to parse a message and will annotate the parsed message to indicate what problems were found during the parsing. There is also a new FeedParser that allows messages to be fed into the parser as they are read in.
* The bisect module now has an underlying C implementation for improved performance.
* There is a new collections module for various specialized collection datatypes. Currently it contains just one type, deque, a double-ended queue that supports efficiently adding and removing elements from either end.
* The asyncore module's loop() now has a count parameter that lets you perform a limited number of passes through the polling loop. The default is still to loop forever.
* The curses module now supports the ncurses extension use_default_colors(). On platforms where the terminal supports transparency, this makes it possible to use a transparent background.
* imaplib now supports the IMAP THREAD command
* heapq has two new functions nlargest() and nsmallest() to find the N largest or smallest values in a dataset.
* itertools has a new function groupby() that acts a little like an SQL "GROUP BY" statement. It also gained a function tee() that returns N independent iterators that replicate the iterator passed as an argument.
* A new function basicConfig() was added to the logging package to simplify setup for logging. There is also a new TimedRotatingLogFileHandler which automatically rotates log files at a fixed interval.
* The operator module gained functions attrgetter() and itemgetter()
* The posix module (available as os) has a new function getsid()
* poplib supports POP over SSL
* profile can now profile C extension functions
* random has a new method getrandbits(N) to return a random integer N bits long.
* The re module was extended to allow simple conditional expressions in regular expressions. In addition, the underlying SRE engine is now non-recursive (previously, certain types of regular expression would run into troubles with recursion).
* The weakref module now supports a wider variety of Python objects includes Python functions, class instances, sets, frozensets, deques, arrays, files, sockets and regular expression objects. In addition, the weakref type is now a new-style object which can be subclassed.
* xmlrpclib now supports a multi-call extension for transmitting multiple XML-RPC calls in a single HTTP operation.
* The base64 module now supports Base64, Base32 and Base16 encoding and decoding, and more complete support for RFC 3548.
LOOP=0
LOOP=`expr $LOOP+1`
这个时候LOOP结果是多少?
LOOP=0
LOOP=`expr $LOOP + 1`
这个时候LOOP结果是多少?
第一个结果是“0+1”
第二个结果是“1”
俺们这有个VPN,这个可以理解,因为不能让任何人在任何地方
都能访问到公司内部的资源。
可是有个麻烦就是回家之后连公司的mail都收不到了
现在都globalization/internationalization了
经常要跟世界各地的人联系,
如果赶上周末,再加上时差的问题,会在礼拜一收到
很多的mail,加上公司的mail不一定都是公事等等其他原因,
迫切需要一个在家能收mail的方案。
俺鼓捣了个把小时,终于成功了。那就是用fetchmail收下来
再转到一个普通的帐户上去。当然了,熟的话几下子就设好了,
俺不是不熟么。。。。。。
这样单位机器不关就可以收下mail给家里发回去了
######################################
####.esmtprc
######################################
hostname=paowang.com:25
username="hufey"
password="*******************"
starttls=enabled
######################################
#### .fetchmailrc
######################################
defaults
mda "/usr/bin/esmtp -f %F %T"
poll pop3.mailserver proto POP3 iudl
user "username" there with password "***************" is "hufey @ paowang.com" keep
######################################
#### .muttrc
######################################
set pop_host="pop://hufey:**************@paowang.com"
set sendmail="/usr/bin/esmtp -v -X ~/.esmtplog"
my_hdr From: hufey
my_hdr Reply-To: hufey
500 OOPS: vsftpd: refusing to run with writable anonymous root
很多人问这个问题
google中文没人回答
google英文说的都含糊
其实只要把anon_root目录本身的 w权限去掉就可以了
比如 在配置文件中设定了 anon_root=/var/ftp
那么 /var/ftp就是这样:
dr-xr-xr-x 4 root root 4096 Nov 11 09:52 /var/ftp/
/var/ftp里就是这样:
drwxrwxrwx 3 ftp ftp 4096 Nov 11 11:15 incoming
dr-xr-xr-x 2 ftp ftp 4096 Jul 6 14:24 pub
cat /etc/vsftpd/vsftpd.conf
# Example config file /etc/vsftpd.conf
#
# The default compiled in settings are very paranoid. This sample file
# loosens things up a bit, to make the ftp daemon more usable.
#
# Allow anonymous FTP?
anonymous_enable=YES
#
# Uncomment this to allow local users to log in.
local_enable=YES
#
# Uncomment this to enable any form of FTP write command.
write_enable=YES
#
# Default umask for local users is 077. You may wish to change this to 022,
# if your users expect that (022 is used by most other ftpd's)
local_umask=022
#
# Uncomment this to allow the anonymous FTP user to upload files. This only
# has an effect if the above global write enable is activated. Also, you will
# obviously need to create a directory writable by the FTP user.
anon_upload_enable=YES
#
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
anon_mkdir_write_enable=YES
anon_root=/var/ftp
#
# Activate directory messages - messages given to remote users when they
# go into a certain directory.
dirmessage_enable=YES
#
# Activate logging of uploads/downloads.
xferlog_enable=YES
#
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES
#
# If you want, you can arrange for uploaded anonymous files to be owned by
# a different user. Note! Using "root" for uploaded files is not
# recommended!
chown_uploads=YES
#chown_username=whoever
#
# You may override where the log file goes if you like. The default is shown
# below.
#xferlog_file=/var/log/vsftpd.log
#
# If you want, you can have your log file in standard ftpd xferlog format
xferlog_std_format=YES
#
# You may change the default value for timing out an idle session.
#idle_session_timeout=600
#
# You may change the default value for timing out a data connection.
#data_connection_timeout=120
#
# It is recommended that you define on your system a unique user which the
# ftp server can use as a totally isolated and unprivileged user.
#nopriv_user=ftpsecure
#
# Enable this and the server will recognise asynchronous ABOR requests. Not
# recommended for security (the code is non-trivial). Not enabling it,
# however, may confuse older FTP clients.
#async_abor_enable=YES
#
# By default the server will pretend to allow ASCII mode but in fact ignore
# the request. Turn on the below options to have the server actually do ASCII
# mangling on files when in ASCII mode.
# Beware that turning on ascii_download_enable enables malicious remote parties
# to consume your I/O resources, by issuing the command "SIZE /big/file" in
# ASCII mode.
# These ASCII options are split into upload and download because you may wish
# to enable ASCII uploads (to prevent uploaded scripts etc. from breaking),
# without the DoS risk of SIZE and ASCII downloads. ASCII mangling should be
# on the client anyway..
#ascii_upload_enable=YES
#ascii_download_enable=YES
#
# You may fully customise the login banner string:
ftpd_banner=Welcome to MontaVista Beijing R&D Center FTP service.
#
# You may specify a file of disallowed anonymous e-mail addresses. Apparently
# useful for combatting certain DoS attacks.
# deny_email_enable=YES
# (default follows)
# banned_email_file=/etc/vsftpd.banned_emails
#
# You may specify an explicit list of local users to chroot() to their home
# directory. If chroot_local_user is YES, then this list becomes a list of
# users to NOT chroot().
#chroot_list_enable=YES
# (default follows)
#chroot_list_file=/etc/vsftpd.chroot_list
#
# You may activate the "-R" option to the builtin ls. This is disabled by
# default to avoid remote users being able to cause excessive I/O on large
# sites. However, some broken FTP clients such as "ncftp" and "mirror" assume
# the presence of the "-R" option, so there is a strong case for enabling it.
#ls_recurse_enable=YES
pam_service_name=vsftpd
userlist_enable=YES
#enable for standalone mode
listen=YES
tcp_wrappers=YES
记得以前买过一本杂志
有一段代码是杀掉所有指定名字的进程
很感兴趣,因为像evolution这样的程序经常不会自己退出去
再起来之前必须手工杀掉,而且他有好几个进程,所以
必须一个一个手工杀掉
不过那本杂志忘了丢哪去了,只好自己琢磨着写了一个
#!/bin/sh
for you in `ps ax|grep $1|grep "^[ |0-9]"|grep -v "grep"|grep -v "$0"|awk '{print $1}'`
do
kill -9 $you
done
折腾了好几天。
开始想写一个给gaim用的机器人,发现gaim.sf.net
上有个perl写的plugin例子。照着抄了一个发现基本不知他在不在跑。其实根本没跑。
因为:gaim安装时会给perl加Gaim module,否则use Gaim如何能生效呢?
可我的perl早就升到了5.8.5,目录位置早就不对了。找到一些用C写的例子,
不过代码太多了,嗯,我越来越发现自己岁数大了,什么也不原意深究了。
结果鼓捣perl鼓捣了两天。
Gaim的官方网站上根本没有用C写plugin的例子。
后来下载了一个SmartEar的plugin,才几十K,终于有兴趣往下看了......
一编译发现需要头文件,于是下载gaim-devel的rpm装。
还不对,
只好下载gaim的源代码,装了之后竟然启动就会segment fault,而root下就没问题。
想了想把自己用户目录下的 .gaim改个名。果然就启动好了。
其实,gaim.sf.net给的perl例子已经不能运行在最新的1.0.2下了。抓狂
偶尔在看版本信息的时候发现了gaim的irc在 freenode。
于是irc,/join #gaim。又问里面的人,终于有一个大概是gaim的开发者告诉了我
How to write a plugin for gaim by C language
还好,照葫芦画瓢搞出了第一个plugin。
接下来就是完善它,再搞搞NLP。。。。。。
Movable Type Spam Vulnerability
11.26.2003
The "Email this to a friend" functionality in the mt-send-entry.cgi script is vulnerable to being used by spammers to send spam messages. In principle, all "email this to a friend" programs are vulnerable to being used by spammers, because they allow the user to specify a To: address and a message body. But in practice, MT's implementation of this is not as robust as it should be, and a new version is available below.
This fix is already included in all versions of MT 2.64 downloaded from today on.
If you're not using this functionality at all, we recommend that you simply remove mt-send-entry.cgi from your MT directory. MT doesn't have any hooks to use this script by default anyway, so you won't be breaking your MT installation.
If you are using this functionality on your MT weblog, you should download this package with a new version of mt-send-entry.cgi, unzip it, and replace the version of mt-send-entry.cgi on your server. The new version:
* fixes a vulnerability that allows spammers to inject extra headers into messages;
* removes the ability to send the message to multiple recipients;
* restricts the message to 250 characters.
All of these fixes serve to discourage the script being used by spammers.
为了正常编译glibc+nptl必须升级gas到2.15
于是升级binutils
tar xvzf glibc+nptl.tar.gz
mkdir glibc-build
cd glibc-build
../glibc+nptl/configure --prefix=/usr/lib/nptl --enable-add-ons=nptl --with-tls
编译glibc+nptl中
本来需要把同一段程序分别链接nptl版的pthread和LinuxThreads的pthread
但是发现无论如何设置 gcc -L/usr/tls 最后连的都是 /lib下老的pthread
最后发现是自己在升级kernel到2.6的时候,为了让老版本的rpm 能正常
工作而 export LD_ASSUME_KERNEL=2.2.5 导致的
重新 export LD_ASSUME_KERNEL=2.4.20就可以了
这个问题也有些奇怪,待考!
而立
-adobe-helvetica-medium-r-normal--12-*-*-*-*-*-iso8859-1,-isas-fangsong ti-medium-r-normal-*-*-160-*-*-c-*-gb2312.1980-0
如果CGE, CEE 或 PRO的开发包装到同一台电脑上
由于路径的关系,很多script会调用到其他版本的程序
得到错误的路径。比如CGE的mvl-update-package会调用
hhl-whereami可能得出CEE的路径
解决办法就是临时把需要的路径提到前面去,反正重启动后
会恢复到原样--虽然原样也还是不能同时使用几个版本
#export PATH=/opt/montavista/cge/host/bin:$PATH
man [path]file
当前路径就是 man ./file
奇怪,这个man man和man -h都没有说
如果在.config里写入参数,直接make zImage是不会把改动的参数写到binary image的。
需要删去 arch/cpu/boot/common/misc-simple.o 才行
昨天发现lmbench跑的特别快,别人要几个小时我这里居然只要几分钟。
不过马上就下班了,就没细琢磨。
今天发现很多数据都特别好,好的不可思议。明显是workload不够嘛。
回头查lmbench的log,才发现无数的segmantation fault 。
最后自己写了个helloworld,发现跟本没连接对crt1.o。
终于想起来了,原来某天发现自己的home空间不够了,就把fs目录
recursive 地strip了一遍,结果把lib里的.o的符号表都给弄没了。
copy原来的之后,好了!
这个也是google不出来的
去掉telnetlogin 的S属性位即可
另外,apache启动不起来是因为 /var/run 不可写
以上为今天的工作日记
什么unexpect end of file
明明知道哪少个括号,硬是找不到
最后一个函数一个函数地copy到另一个script
终于找到原因
因为 一个 大括号 写到一行的末尾
而不是另一行的开始
由于vi的显示却正好像是一行的开始
虽然颜色是不一样的,但是红和紫并不容易分辨
shift+%方法找匹配也能找到
TNND vi
给eclipse写了个plugin,就一句helloworld
照着网上介绍的文章一步一步来
很顺利,只是后来发现只能在run as workspace里能看到结果
真copy到eclipse的plugins目录就没有
google了一整天
才找到一个人写到了window -> Customize Prespective -> Other里去
turn on,否则默认不会出来地
难道他们那些写文章的人都不真正把自己写的plugin拿出来用吗?
安装了 eclipse,结果启动的时候出现Problems during startup的dialog,遍寻
google而无解,奇怪,很多人也遇到过,很多人据说是不知怎么多启动
几次就好了,完全是搞封建迷信。
只好自己解决,最后是发现要启动参数如下:
eclipse -vm /usr/java/jdk/bin/java
才行
当然,jdk要有
Linux has a unique implementation of threads. To the Linux kernel, there is no concept of a thread. Linux implements all threads as standard processes. The Linux kernel does not provide any special scheduling semantics or data structures to represent threads. Instead, a thread is merely a process which shares certain resources. Each thread has a unique task_struct and appears to the kernel as a normal process (which shares resources, such as an address space, with other processes).
This approach to threads contrasts greatly with operating systems such as Microsoft Windows or Sun Solaris, which have explicit kernel support for threads (and sometimes call threads lightweight proesses). The name "lightweight process" sums up the difference in philosophies between Linux and other systems. To these other operating systems, threads are an abstraction to provide a lighter, quicker execution unit that the heavy process. To Linux, threads are simply a manner of sharing resoures between processes.
Threads are created like normal tasks with the exception that the clone() system call is passed flags corresponding to specific resources to be shared:
clone( CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND, 0 ) ;
The Process Descriptior and Task Structure
The kernel strores the processes in a circular doubly linked list called the task list. Each element in the task list is a process descriptor of the type struct task_struct, which is defined in include/linux/sched.h. The process deescriptor contains all the information about a specific process.
The task_struct is a relatively large data structure at around 1.7 kilobytes on a 32-bit machine. This size, however, is quite small considering that the structure contains all the information the kernel needs about a process. The process descriptor contains the data that describe the executing program -- open files, the process's address space, pending signals, the process's state, and much more.
Allocating the Process Descriptor
The task_struct is allocated via the slab allocator to provide object reuse and cache coloring. Prior to the 2.6 kernel series, the task_struct was stored at the end of the kernel stack of each process. This allowed architectures with few registers, such as x86, to calculate the location of the process descriptor via the stack pointer without using an extra register to store the location. With the process descriptor now dynamically created via the slab allocator, a new structure, struct thread_info, was created that again lives at the bottom of the stack (for stacks that grow down) or at the top of the stack (for stacks that grow up).
Each task's thread_info structure is allocated at the end of its stack. The task element of the structure is a pointer to the task's actual task_struct.
Storing the Process Descriptor
The system identifies processes by a unique proess identification value or PID. The PID is a numerial value that is represented by the opaque type pid_t, which is typially an int. Because of backward compatibility with earlier Unix and Linux versions, however, the default maximum value is on 32767 (that of a short int). The kernel stores this value as pid inside each process descriptor.
If the system is willing to break comatibility with old applications, the administrator may increase the maximum value via /proc/sys/kernel/pid_max.
Contrast this approach with that taken by PowerPC, which stores the current task_struct in a register. Thus, current on PPC merely returns the value stored in the register r2. PPC can take this approach because, unlike x86, it has plenty of registers. Because accessing the process descriptor is a common and important job, the PPC kernel developers deem using a register worthy for the task.
Processes provide two virtualizations: a virtualized processor and virtual memory. The virtual processor gives the process the illusion that it alone monopolizes the system, despite possibly sharing the processor amongst dozens of other processes. Virtual memory lets the process allocate and manage memory as if it alone owned all the memory in the system.
Note that a program itself is not a process; a process is an active program and related resources. Indeed, two or more processes can exist that are executing the same program. In fact, two or more processes can exist that share various resources, such as open files or an addressspace. A process beins its life when, not surprisingly, it is created. In Linux,this occurs by means of the fork() system call, which creates a new process by duplicating an existing one. The process that calls fork() is the parent, whereas the new process is the child. The parent resumes execution, and the child starts execution, at the same place, where the call returns. Often, following a fork it is desirable to execute a new, different, program. The exec() - family of funcation calls is used to create a new address space and load a new program into it.
Finally, a program exits via the exit() system call. This function termiates the process and frees all its resources. A parent process can inquire about the status of a terminated child, via the wait4() system call that enables a process to wait for the termination of a specific process. When a process exits, it is placed into a special zombie state that is used to represent terminated processes until the parent calls wait() or waitpid().
A Beast of a Different Nature
No libc
There are multiple reasons for this, including some chicken and the egg situations, but the primary reason is speed and size. The full C library -- or even a decent subset of if -- is too large and too inefficient for the kernel.
GNU C
Like any self-respecting Unix kernel, the Linux kernel is programmed in C. Perhaps surprising, the kernel is not programmed in strict ANSI C. Instead, where applicable, the kernel developers make use of various language extensions available in gcc.
The kernel developers use both ISO C99 and GNU C extensions to the C language. These changes wed the Linux kernel to gcc , although recently compilers, such as the Intel C compiler, have sufficiently supported enough gcc features that they too an compile the Linux kernel. The ISO C99 extensions that the kernel uses are nothing special and, because C99 is an official revision of the C language, are slowly cropping up in a lot of other code. The more interesting, and perhaps unfamiliar, deviations from standrd ANSI C are those provided by GNU C. Let's look at some of the more interesting extensions that may show up in kernel code.
Inline Function
Inline Assembly
Branch Annotation
The kernel wraps the directive in very easy to use macros, likely() unlikely() .
No Memory Protection
When a user-space application attempts an illegal memory access, the kernel can trap the error and kill the process. If the kernel attempts an illegal memory access, the results are less controlled. Memory violations in the kernel result in an oops, which is a major kernel error. It should go without saying that you must not access illegal memory, dereference a NULL pointer, and so on -- but within the kernel, the stakes are much higher!
Additionally, kernel memory is not pageable. Therefore, every byte of memory you consume is one less byte of available physical memory. Keep that in mind next time you have to add one more feature to the kernel!
No (Easy) Use of Floating Point
Unlike user-space, the kernel does not have the luxury of seamless support for floating point. Using floating point inside the kernel requires manually saving and restoring the floating point registers, among possible other chores. The short answer is: Don't do it; no floating point in the kernel.
Small, fixed Size Stack
The kernel stack is neither large nor dynamic; it is small and fixed in size. The kernel stack is fixed at 8KB on 32-bit architectures and 16KB on most 64-bit architectures.
For more discussion on the kernel stack, see the section Statically Allocating on the Stack in Chaper 10, "Memory Management".
Synchronization and Concurrency
Portability Is Important
Linux Versus Classic Unix Kernels
apt-get error
若apt-setup出現"E:Dynamic MMap ran out of room"錯誤,在/etc/apt/apt.conf
加入
APT
{
Cache-Limit "141943904"
}
增加cache的可用空間。
google来的,来自台湾龍潭國小drbl學習日誌 :)
装了debian 3.0的第一张盘,只有基本系统
印象里安装过程没有问过我要不要设网卡IP什么的
启动之后发现只有lo
ifconfig -a后发现eth0设成了自动ip
只好自己改interfaces的内容再ifup什么的
问题:我现在家里用一台台式机ADSL上网,做Proxy Server
IP地址是192.168.0.1,DNS,GATEWAY都是它
笔记本固定IP地址设好后,能ping到192.168.0.1的机器
ping 不通外边的名字或地址
但是我用base-config,tasksel居然可以下载pkg!
我虽然可以下载了,但是另一个console仍然不能ping通外边
发现/opt分区太小,windows留的分区太大
用pqmagic挪鸭挪
结果/boot是不能挪的,挪的linux不能启动了
只好重装 :(
在网上翻了翻电子书,看了看FreeBSDChina
的论坛。下载freebsd 4.9的iso,刻盘,安装。
其实在6年前我就装过freebsd,看了看大概就改装Linux了
以前看FreeBSD和Linux的fans吵架比较多,所以总觉得
两者个方面应该在伯仲之间吧。结果,这个安装就给了我一个
下马威
首先是他的slice概念和partition不太一样,freebsd不能用扩展分区
所以我只好把整个硬盘都给了他。
装的时候还可以,装完了发现写磁盘经常很慢,说什么cable or device
只有IDE33,然后就狂读写硬盘好长时间,后来就干脆resetting -- done
个不停。重起之后的fsck不能自动运行,晕!
XWindow的配置工具只能相当于Linux几年前的水平,不过还好,我还没忘,
至少把KDE弄出来了,光电鼠标好像还有手工改。。。再晕
PPPoE还不对,网上很多人写的都不详细,而且网上的文章太老了,FreeBSD
本身版本之间的区别也不小,这个不解决就不好办了,我总不能老把硬盘
卸来卸去吧
pkg-xx工具看来挺好用的,/stand/sysinstall,呵呵,目录结构的设计让我很不习惯
待解决的问题还不少,网络的配置还不对呢
用ppcboot 1.0.4 tftpboot传文件出现 Retry count exceeded TTTTTTT的错误
查google也有几个人问,都没有答案
后来发现跟写错文件名找不到文件的提示是一样的
原来是tftpd的路径搞错了
:-)
Write Your Own Operating System [FAQ]
zt:超级无聊大彩蛋(谴责)
提交者 : 狂马 于 北京时间 2004-04-06 22:47:50
大家可以在word中写一个“胡”字,然后加大到“小初”大小,然后选“空心”效果,然后选“隶书”或“幼圆”。放大一些之后大家就可以在字上看见效果了:胡万进印!!!
俨然是信息时代的到此一游啊!
彩蛋是软件行业惯有的花招,很多程序员都喜欢以此来炫耀一下,不过那些彩蛋只会通过特殊的方法激活,而不会干扰任何正常的用户使用。但是这个卑劣的字体彩蛋,却干扰了用户对于字体的正常使用——虽然遇到的概率很低,但是用户是有在任何时间任何场景下正常使用的权利的,而这种权利却被卑劣的彩蛋制作者剥夺了,可耻阿!
再说说其人吧:
信息技术信息交换用汉字编码字符集基本集的扩充(报批稿)2000-03-17 发布2000-03-17 实施
中华人民共和国国家标准国家质量技术监督局发布
前 言
本标准作为 GB 2311 体系的字符编码标准,规定了信息交换用的基本图形字符及其二进制编码的十六<制表示。
本标准适用于图形字符信息的处理、交换、存储、传输、显现、输入和输出。
本标准是对 GB 2312 的扩充。
本标准具体规定了图形字符的单字节编码和双字节编码,并对四字节编码体系结构做出了规定。
本标准的附录 A、附录 B、附录 C 和附录 D 是标准的附录。
本标准从生效之日期起,同时代替原国家技术监督局标准化司和原电子工业部科技与质量监督司联合以技监标函[1995]229 号文发布和实施的技术规范指导性文件《汉字内码扩展规范(GBK)》1.0 版。
本标准由中华人民共和国信息产业部提出。
本标准由信息产业部电子工业标准化研究所归口。
本标准起草单位:信息产业部电子工业标准化研究所、北京大学计算机技术研究所、北大方正集团、北京方正新天地信息网络科技有限责任公司、四通集团公司、中科院软件所、长城软件公司、四通利方公司、中软总公司、金山软件公司、联想公司。
本标准主要起草人:陈堃銶、黄疆、胡万进、张建国、陈壮。
除了“胡”字,已知包括这个卑劣彩蛋的还有以下汉字:卞、翟、淠、惡、讫、玍、扎、哟、岡、汚、汩、浞、珐、杌、柿、殻、砼、鉢、錯、镁、秫、耒、岡、玍、翟、卯、卞、畋、曰、莱、隹

Making System Calls from Kernel Space
Robert Love--KernelTrap访谈 之二(中文版)
摘要
本次采访中(2002年10月), Robert和我们讨论了Linux抢占式内核的现状, 他最近参与0(1) 级调度器开发的情况, 以及他在 VM overcommit方面的工作。他还对linus使用Bitkeeper,Linux的未来以及最近在Ottawa举行的kernel summit会议发表了自己的看法。(2003-09-22 09:51:38)
By Anlin
Kernel trap在2001年10月对Robert love进行了第一次采访;之后不久, 他的抢占式内核补丁被收入2.5系列内核;他在内核开发方面一直很活跃。最近,他再次接受了我们的采访。
本次采访中, Robert和我们讨论了Linux抢占式内核的现状, 他最近参与0(1) 级调度器开发的情况, 以及他在 VM overcommit方面的工作。他还对linus使用bitkeeper,Linux的未来以及最近在Ottawa举行的kernel summit会议发表了自己的看法。
Robert现在在加州为MontaVista公司工作,但8月底他将回到佛罗里达州立大学继续他的大学三年级的学业。请继续阅读我们采访的全部内容:
//JA for Jeremy Andrew @ KernelTrap
//RL for Robert.M.Love
JA: 我上次访问你到现在已经有8个多月了, 那时你已经对Linux内核做出了令人印象深刻的贡献。几个月前你的抢占式内核补丁被收入2.5 版内核的开发树,而且你投入很大精力参与了O(1) 级调度器的开发工作。 除了这些以外,您在 Gainesville的工作和生活怎样呢?
RL: 都还不错。4月份我完成了在佛罗里达大学的第二年学业。我很喜欢大部分课程,尤其是数学。8月底我将开始第三年的学习。
摄影是我的爱好之一, 我买了新的照相机---Canon Elan 7e。这是一个SLR 35毫米 beast的单反相机(但不是数码的)。我拍了很多照片,从中获得了很大的乐趣。
一月份我就开始在MontaVista, 一家嵌入式Linux公司,工作了。 我在实时和性能工作组做内核hacking方面的工作。 MontaVista 是开源软件的坚定支持者,因此我可以同时为社
区的很多项目工作。 公司一直对抢占式内核很有兴趣,这一直是他们的开发项目(note: 抢占式内核最初是由Monta Vista提出并初步实现的), 而且他们也支持我对2.4 和 2.5 版内核的维护工作。
JA:听起来您可以做自己喜欢的工作,并可以因此得到报酬?
RL: 我真的很幸运。
JA:您提到Monta vista是一家嵌入式Linux公司, 但是我必须承认,除了他们对抢占式内核的贡献之外我对他们并不是很熟悉。 您可以更多介绍些他们的工作吗?
RL: Monta vista为开发者提供了一套开源的基于Linux的嵌入式系统的解决方案。 对于着眼于嵌入式产品的开发者来说, Linux是一个广泛的选择。 我们提供了一个产品和多样
的服务来满足他们的需求。
JA:这个夏天您准备怎么渡过?
RL:在学期中我通常会兼职,但是这个暑假我会在硅谷为Monta Vista作全职工作。 这是一个非常值得的经历。这儿我有一辆车,所以我可以借着这个机会去旅游。北加州真的很美。
JA: 来这儿以后您去了哪些地方旅游呢?
RL: 我在south bay 居住和工作,所以我花了很多时间在附近游览。我经常去 San Francisco, 也去过 Santa Cruz 并且徒步穿过山谷附近的山脉。我很喜欢那些大学城,像 Stanford所在地 Palo Alto和 UC Berkeley 所在地Berkeley。我还去过Yosemite ,很喜欢那里。
JA:回到您在内核方面的工作。 您是什么时候得知您的抢占式内核补丁将被Linus收入2.5 的开发树的?
RL: 当Linus说 "Ok" 的时候 :-)
糟糕,我几乎想不起来了。我们曾经讨论过这个问题并且这也常常在社区中被提出来。我给了他针对2.5.4-pre5 的补丁,他提出了很多问题,这些问题在我后来的一个补丁进行了处理。
瞧,结果就是,2.5.4-pre6 有了一个抢占式的内核!
JA:作为Linux台式机用户,我很高兴听到您的补丁被采用了。 但是,我仍然记得不久前争论中,很多人不赞成抢占式内核应该成为Linux内核主干(mainline)的一部分。您从其他的内核hacker那里得到的反映如何?
RL: 各式各样的。有些人很喜欢这个而且在为进一步的增强而工作,有些人不喜欢,其他的则持中立的态度。 最重要的家伙(Linus)很喜欢这个;而且我也从两个最具天才(我的个
人看法)的内核hacker Andrew Morton和Ingo Molnar那里得到了支持,对此我十分感激。
JA:现在您对已经被收入mainline development tree的补丁做多少维护工作呢?
RL:比还是作为外部补丁的时候少多了。 在此之前我要花很多的时间跟踪开发树,保持事情的同步并发布补丁。现在我则不必担心类似的事情。实际上是其他的补丁要注意和抢占式内核保持一致。
JA:抢占式内核增加了哪些复杂的因素呢?
RL:有per-cpu数据的问题。由于内核已经是可抢占式的了, 我们有一个规则是内核代码不能假定当前使用的cpu不会被其他代码夺走,这也是被抢占的结果。因此,必须依靠per-cpu
数据运行的代码必须确定抢占被临时禁止。
JA:内核的哪些部分必须因此禁止抢占呢?
RL:举个例子吧, 比如一个图片, 就值数千本 jacky handy书,
int cpu = smp_processor_id();
extern stats[NR_CPUS];
do_stuff(stats[cpu]);
more_stuff(stats[cpu]);
以上的代码中, 因为有了内核抢占( kernel preemption),你可以在任何地方进行抢占。当重新调度时,你可能在使用另外一个cpu并且'cpu'的值不再指向当前的cpu了。 这样并不好。
解决方法是:
int cpu = get_cpu();
extern stats[NR_CPUS];
do_stuff(stats[cpu]);
more_stuff(stats[cpu]);
put_cpu();
函数get_cpu()和put_cpu()返回当前的cpu值, 但同时也禁止了抢占。需要注意的是只有当前没有锁并且允许中断时才需要做这些,并不是每次使用都会产生问题。我们已经修正了所有已发现的问题.须注意的是以上的方法在单处理器系统中可能造成问题,因为单处理器的数据是“隐式锁定”的, author可能因为不能在同一个cpu上再次读入数据(执行代码)而没有对数据进
行保护。抢占改变了这一切,因此你可能需要禁止抢占。
JA:全部的抢占式补丁都被收入2.5内核了吗?
RL:是的,而且2.5包括了很多2.4的补丁没有收入的变化。2.5还包括了对当前多数处理器结构上内核抢占的支持,体现了支持该补丁的开发者的产生。
JA:2.5现在支持哪些处理器体系结构呢?
RL: ARM, I386, PPC, sparc64和x86-64. Monta Vista已经为2.4提供了支持SH和MIPS的补丁并且这些也可以很方便地进行移植。
JA:除去对额外处理器结构的支持, 2.5的内核抢占式补丁还有哪些2.4的补丁不具备的呢?
RL:我们改变了一些补丁的工作模型。总的结果是一样的,但是实现上有了一些改进。
具体的说, 我们把一些preempt_enalbe()宏移入prrmpt_schedule() 从而减少了一些行间代码。
preempt_enable()在每个spinlock中都是inline的,这减少了目标代码的长度,尤其对于RISC结构的机器。 其次, 我们把preempt_schedule() inline进entry.S 的中断返回路径。我们可以在两个时机进行抢占调度:中断处理完成后(这是一个理想的时机,因为通常中断会唤醒一个进程并且置need_resched标志)和某个锁的释放后。对于中断处理方面的抢占,我们在entry.S的返回代码里加入了汇编。这些代码做些 preempt_enable()之类的检查而后调用preempt_schedule(),如果必要的话。preempt_schedule()再调用 schedule()。我们只是专注在返回路径中preempt_schedule()的逻辑以避免某种重定向。
除此之外,还有一些其他方面的小的改进…
JA:您未来对Linux内核抢占有什么改进计划呢?
RL:这里有一些我或者其他人正在做的事情…
Ingo Molnar, Dave Miller, Linus和我一直在tossing around一些补丁来移除整个local_bh_count和local_irq_stat的概念(大致的讲,就是一个关于有多少个中断或者BH正在进行的计数)并且将他们封装入preempt_count。这将会使我们能够将preempt_count作为
一种接近原子性的计数器使用并减少很多代码。
我认为仍有一些代码路径可以更好地利用抢占式内核,我会寻找使这个新的视角得到应用的地方。最后,也是惯例的是:减少锁持有的时间以减少延迟。
JA:您的scheduler hint补丁得到了多少回馈信息呢?
RL:不是很多,而且遗憾的是,最有用的回馈却是在list(note: lkml)之外得到的。我并不会过分相信scheduler hints是一件好的事情。它们在Solaris上表现很好, 但是对我来说只是一个提醒我scheduler需要fixing的标记。 换句话说, 它们是一种band aid。唯一我认为有
些用处的是HINT_TIME, 这是Solaris系统的成功之处。困难在于分是实现公正以及判定我们所增加的复杂性是否值得,或许不。
JA:您可以描述些正在做的关于O(1) scheduler的工作吗?
RL: 当Ingo第一次将他的scheduler张贴出来的时候,它设计上的完美给我留下了很深的印象。 我对Ingo作为一个程序员和结构设计者有着极大的尊重,但我仍感到十分惊讶。我
开始对其做出贡献,给出我的认识并修正bug,让抢占式内核在新的scheduler上工作。最近, 我完成了task affinity cpu系统调用, 实时的增强, 可配置的优先级并编写了些相关的文
档。 现在Ingo和我共同维护这个scheduler, 我还将更新的内容应用到Alan的 2.4-ac树上并且维护stock2.4树的o(1) scheduler补丁。
JA:O(1)对Alan的2.4-ac树的backport是我仍使用它的一个主要的原因。加上你的抢占式补丁和rmap,它工作地非常好。说句老实话,我有很长时间没有运行其他的程序了,甚至都忘了它的样子。与2.5的scheduler相比,Alan的 2.4-ac树中的scheduler有什么缺少的吗?
RL: 在2.5中已经证明相当稳定的代码移植到2.4-ac的过程肯定会有延迟,Alan合并了它们,但是并没有出现过于特殊而无法解决的情况。 2.4 将会和2.5保持合理的同步。
JA:您对2.5内核开发的进展是否感到高兴呢?
RL:是的,整个开发过程看起来进行得不错。我给Linus的所有代码都成功地被接受了,这总是一件好事情。
JA:对于2.5您仍然希望Linus收入的有影响的补丁有哪些?
RL: 非常不幸运的是还未收入的补丁中,只有很少是未决定(pending)的。现在我更感兴趣的是那些我们希望可以在万圣节冷冻期(Halloween freeze)前完成的事情。 但愿SCSI层可以引入一些sanity,我还祈祷tty层更多的工作。余下的Patrick Mochel's优秀的设备模型和driverfs代码是我非常欢迎的。
最后, 我希望Andrew Morton能够将Rik 的 rmap vm分成逻辑块并由Linus掌管它们。 期望这样所有的VM开发者都可以改进它,我自己也很喜欢为它工作。
JA;您曾经单独在虚拟内存上花过时间吗?
RL: 一点点。虚拟内存是我感兴趣的方面之一,但是我还没有贡献很多代码。实际上, 我围绕rick的 rmap vm做过一些工作;现在,我为rick's vm和 the stock 2.4 vm两
方面做strict vm overcommit的工作。严格的虚拟内存overcommit工作是一个有趣的挑战。其中大部分的工作是alan cox为他的2.4-ac树做的。 现在,Linux将会高高兴兴的overcommit memory –也就是说,在没有空闲内存作为保证(back)的情况下,内存分配也会成功。这个策略通常工作良好,因为一个系统往往拥有大量自由的内存。更进一步的说,很多内存的分配并没有充分地利用或者很快就被释放了。因此 overcommit减轻了虚拟内存系统的压力,从而减少了页交换的频率。现在我们已经成功完成了一种基于简单的启发式规则的分配方法,这会在允许足够的 overcommit
"fixing"有两层含义。首先,我们必须严格地计算分配的内存块的大小。举例而言, 一个在很多进程间共享 的"Copy On Write" 的页只占用一页的内存, 因为这就是它物理上消耗的。但是在任意时刻,一个进程都可以对此页执行写操作从而不再共享它而是拥有自己的拷贝。因此,我们需要对每一个可写的共享实例计算一次而不是总共只计算一次.其次, 既然我们已经有了一个合适的accounting, 我们就必须制定一个严格的规则。比如,"committed memory will not exceed swap"。有了这些改变, 内存过度使用的情况就不会发生了。所有失败的情况都被归结到分配函数上
(fork,mmap,malloc,etc)。对内存的访问也不会造成OOM(Ouf Of Memory) kill的情况了,如果内存块已经被分配,它就应该是存在的。
JA:听了您的解释以后, 我感到不解的是为什么现存的虚拟内存系统不采用严格的虚拟内存overcommit呢? Overcommit听起来是一件好事, 是不是它存在什么不足?
RL:是的, 主要有两点:(a) 额外的accounting. (或许是不足考虑的吧。实际上, 无论严格的overcommit是否存在, 我完成的部分都进行accounting的工作) 。(b) 禁止overcommit之后, 虚拟内存系统的压力就会提高而且页替换频率也会跟着增加。
JA:您曾提到对于对称多处理器scalability的兴趣,那么对于Linux对称多处理器scalability的未来你有什么看法呢?
RL:那就看你想scale些什么了 :-)
2到4个处理器的现在的情况(note: Linux运行于2~4 CPU的smp系统之上)是很理想的, 或许我们可以再顺利地扩充一些。但是继续扩充到无限则会将Linux置于一种扭曲的混乱状态。
JA:您还提到了对锁机制的兴趣, 能否举些例子?
RL: 你看,我并不知道自己为什么会对锁机制感兴趣的。大多数人或许并不会认真考虑他们所使用的锁是如何实现的。但是我读一个操作系统时做的第一件事就是理解它的锁机制。 我想或许我就是这么古怪吧…
总之,我对于我们实现的各种原语(primitive)以及它们的使用方式都是很感兴趣。我们已经实现了一个非常棒的轻量的(lightweight) spinlock。在内核summit会议上,我曾提出要实现一种新的轻量级的互斥锁,也就是一种没有我们现有信号量的复杂特性的二进制信号量,或许具有 spin-then-sleep行为。
JA:2.5的锁机制相比以前的内核来说有什么改进呢?
RL: 它实现地更好, 尤其是在VFS层。我对于2.5做的第一件事就是把BKL(BigKernelLock)从高层的llseek()函数中去除,把它放入单独的llseek实现中去。这样现在每个函数都可以决定它需要哪些锁了。因此,普通磁盘操作使用的llseek就只需要i_node信号量了。
这种 “锁下推”(pushing locks down)工作在 VFS层的很多VFS例程(methods)中继续。 其他领域的工作也在继续, 尤其是移除BKL的工作。当rmap被收入时, 我知道Bill Irwin有一些可以减少锁竞争的补丁。Andres Morton也做了一些在VM中减少VFS层高度竞争的工作。
JA:那么Linux的锁机制与其他操作系统, 比如FreeBSD和Solaris的比起来怎样呢?
RL: Solaris 要比Linux grain得好很多(note:具有更细粒度的锁),它在多于64个cpu的环境中仍能良好地工作。因此,Solaris有低端为高端折中的名声。 FreeBSD在它的5.0开发树中引入了一些有趣的锁构造,但他们也只是刚刚开始grain他们的内核,他们似乎把目光都放在高端的具有 scalability系统上。
JA:从2.5向上看,您希望下一个内核的开发中包括有什么工作呢?
RL: tty层的重写。哈哈。 我不能想得那么久远。我很希望看到内核得到整理,旧的cruft被移除以及类似的事情。而且有一个只是使之更精炼的发布版本。
JA:您对于Linux内核的发展方向感到担忧吗?
RL: 是的,我常对高层工作对普通情况造成的影响感到担忧。你或者扩展到128个cpu或者只是在一两个cpu上优化运行。你或者对一些少数运行的任务进行优化或者运行着上千个数据库线程而无法进行优化。
我只是对前者(scalability)进行了改进,所以你可以想象出我所担心的事情。这也是我们大多数人都担心的。
由于Linux内核演进(evolutionary)性的设计,状况会变得更糟。 我很担心我们只是对出现的问题进行hacking 和rehacking,而这将会是最大的问题。
JA:您预计我们什么时候会看到2.6版本的发布?
RL:18个月,你赌多少(place your bets)?
JA:一年半看起来很长, 尤其在几个月前的代码刚freeze的情况下。为什么您认为我们要花那么长的时间才能看到2.6的发布呢?
RL:我曾看到过早至2003年初的预测, 那就只有几个月的时间来达到稳定期了。 就过去的历史而言, 达到稳定状态所花费的时间要比 特性波动期("the flood of feature" )长得多。
我预测一个现实的日期:2003年夏天。距离现在有一年的时间。考虑历史因素,我会把这段时间加长到18个月,或许稍微少一些;但绝对是距离冻结期(freezing)有一年的时间的。
我更关注2002年10月31日的实际冻结,如果我们赶的及的话,我们可以有足够的时间来使内核达到稳定状态。不管是一个月,还是一年。
JA:除了内核以外近期您还对哪些开发计划感兴趣呢?
RL:GNOME2是令人感到惊奇的!
Metacity (一个和gnome2兼容的窗口管理器) 很漂亮而且速度很快,Havoc 真是个天才!
JA:您对于Linus采用bitkeeper的决定以及其后长时间的争论有什么看法?
RL:如果它可以让他(linus) 效率更高而且更高兴, 那么我就喜欢它。 我希望它是开源的吗? 当然了。但是它很有效而且是当前最好的解决方案,所以我对此并不抱怨。
JA:那您用BitKeeper来管理你的内核开发工作吗?
RL:没有。我用 diff, patch, grep, find和大量的目录。
JA:一个幽默的描述。那么您为什么不选择这种基于更加正式的管理系统的策略呢?
RL: 我认为很多内核开发者也是选择这种方式吧。 或者类似的是他们使用CVS来保存数据,但是大量的脚本文件或许是最普遍的代码管理工具了。我选择它是因为它适合我。
JA:您最近参加了在Ottawa举行的内核Summit会议,您觉得会上最有趣的是什么?
RL: 内核开发会议本身就是很有趣的. 这是一个为期两天的只有被邀请才能参加的会议。有大约60名核心的内核开发者出席。上次我们谈话时,你问我是否遇到过其他的内核开发者。虽然这不是一个如我预想的petting zoo,现在我仍可以说我正巧遇到了他们所有的人。
一些好的议题包括Patrick Mochel的driverfs和James Bottomley的SCSI。Patrick有包括占统治地位的driverfs开发计划。SCSI需要很多的工作,并且James有希望成功对其进行领导。我曾希望关于VM的争议应该是有争议的(当然最终是有回报的), 但Linus在一开始就明确表示他希望在2.5中给rmap一个机会,对此我感到很欣慰。最后的谈话是由Ted Ts'o 领导的,集中于内核发行版的管理。我们决定了现在声名狼藉的freeze date,2002年十月31日。Dave Jones也被惩罚了,被给予了帮助Linus进行feature freeze工作的机会。会议最有价值的部分, 则是非正式的"hallway discussion"以及在Ottawa的一些俱乐部里进行的交谈。 面对面交谈确实是一件很值得的事情, 我认为从中可以得到很多益处。
JA:您还参加了内核开发者会议之后的Ottawa Linux 会议…..
RL: OLS也很有趣。这是一个更大的群体,大概有500人左右。 大会的话题也是以内核为中心的。这对我来说很棒,虽然我很希望讨论不同的话题。尽管这样, Havoc Pennington仍然
做了一个很棒的关于GCONF的演讲。OLS的非正式的部分也是很有价值。内核开发者会议恰巧在OLS开始前结束,所以大多数的内核hacker也出席了OLS,因此我们可以继续我们的讨论并认识很多新的朋友。
JA:您还有要补充的吗?
RL: 激光是由光汇聚成的,不是由声音。
我们应当去获得普通用户的看法。
JA:非常感谢您再次接受我的采访. 您对Linux内核的贡献一直集中在我感到很有趣而且用处的领域。我将很乐意看到您的兴趣将会把您引导到哪里。
RL:谢谢。 我也很高兴和你谈话。 Take care.
--------------------------------------------------Related Links:
英文原文来自: http://www.kerneltrap.org
Robert Love's Home Page - (http://www.tech9.net/rml/)
Robert's Linux Page - (http://www.tech9.net/rml/linux/)
Robert's kernel.org FTP Directory - (ftp://ftp.kernel.org/pub/linux/kernel/people/rml)
MontaVista's Home Page - (http://www.mvista.com/)
Robert Love--KernelTrap访谈 之一
摘要
本周,KernelTrap采访了当前负责维护可抢占内核补丁的Robert Love。他使用Linux已经7年了,为现在的内核作出了很多贡献。他的话,是这一切的最佳描述...(2003-07-11 13:29:15)
By Anlin
JA: 请谈谈您的个人情况...
RL: 我现在是Gainesville佛罗里达大学计算机与数学专业的学生,家乡
在Ft. Lauderdale, FL(note: FL for Florida)。我还没结婚,但
有一个很不错的女朋友。我编程的兴趣在于操作系统和数学/科学计算。
JA: 何时毕业,毕业后有什么计划?
RL: 2004年。但我还是想留在学校里继续读书以获得更高的学位,特别是
经济仍停滞在当前的状况(remains as-is)。
JA: 来自 Ft. Lauderdale, FL.的什么地方?我住在那里的Lauderhill。
RL: 我出生于Pembroke Pines,在那里长大。
JA: 您什么时候开始接触Linux?
RL:
第一次在我的PC上运行Linux是在1994年年末,当时用的是1.0版的内核;
这也是我第一次真实的Unix体验。我的那台PC是386SX(感谢妈妈),在
转而运行Linux之前,它之上运行的操作系统是Windows 95 beta。我在
使用2.0版时进步更大,从2.2版开始则完全转向了Linux,此后一直只使
用Linux。
我转向Linux有一个显而易见的原因: 我相信Linux是一个强大健全有着优
秀应用软件的系统。然而更重要的原因是它使我能对系统以及围绕它的社区
的有充分的接触。
JA: 你可不可以描述一下1.0版内核相比现在的2.4版的几个关键区别?
RL: 如果1.0和2.4有几页代码是相同的,我将会非常惊讶。两者没有任何
相同的地方。
JA: 安装和使用1.0版的内核是什么样的情形,有哪些软件可以使用?
RL: 幸运的是,1994/1995年,Linux发展良好。那时SLS和Slackware
都提供了全功能的发行版。我最初使用Slackware2.0。那时你必须以磁盘
集(disk sets)的形式将Linux安装文件下载到磁盘上,可能你现在仍这么
做。我记得磁盘集A是核心,磁盘集N提供网络支持,等等。那时Linux已经
支持网络了,X也可以使用(XFree86 2.0),也支持很多硬件。
和今天相比,最大的问题是缺少文档,安装又非常复杂。我记得起初我曾因
为没办法让PPP用Linux;如果那时我可以使用PPP的话,我可能早就转向
Linux了。
JA: 您为内核做出的贡献有哪些?
RL: 目前我主要的时间是花在可抢占内核补丁的维护上。这个补丁可以使低
优先级的进程被剥夺,即使它当前处于核心态,结果是改善了系统的响应时间。
这个补丁最初是MontaVista-一个伟大的公司-的杰作,所以我和他们以及这
个社区(Linux社区)的其他成员密切合作。这是一个很有趣的项目。我们正把
目标是将它加入到2.5版的内核中。
我的工作是非常随机的。修正bugs,优化,作一些旨在使系统简洁的清理。我
也写过i815和AMD761 AGP GART的代码,也维护着其他一些的零碎的补丁。
JA: 为了使得内核可抢占,您的补丁对内核作了哪些必要的修改?
RL: 我们的模型是当内核不被锁定时,任何时刻都可被抢占。根据这个设计,
当一个事件激活更高优先级的进程时,系统将会剥夺当前正在运行的进程,转
而运行这个更高优先级的进程。
我们必须修改entry.S中的中断代码来避免某些情况并能在中断处理过程返回
时发生抢占。但是我们不能在临界区内抢占,这和在SMP环境下的临界区中不允
许并发的道理相同,所以我们防止了持有自旋锁(spinlock)时被抢占的情况。
bottom half handler和scheduler同样需要修改,以保证在它们运行时不
发生抢占。
JA: 时至今日,您认为您的补丁的稳定性如何?我的所有工作都在一台独立的
Linux服务器上完成,我不断为它升级内核和软件。改善系统的响应固然有吸引
力,但您有没有考虑过对一台不间断运行的服务器来说,补丁是否足够稳定呢?
RL: 补丁非常稳定。我可以非常有信心地鼓励任何人来使用它。我们有很多用户,
收到了很多反馈。我想我们已去除了明显的漏洞(bugs)。我在自己的主系统中
使用这个补丁。
最重要的是我们知道它的设计和实现是正确的。使用了我们最新的补丁之后,我
感觉我们已解决了所有的问题。
JA: 在您看来,系统响应时间上的改进有多明显呢?
RL: 非常明显。
我们曾经记录过200%的系统延迟方面的提高。安装了可抢占内核补丁后,系统的
平均延迟大约为1ms,不会超过10ms。仍有些长时间的锁占用会影响响应,导致
有些延迟达到100ms甚至更长。幸运的是这些情况只在特定情况下出现,就像切
换虚拟控制台(switching VCs)。
JA: 现在还有另外一个最终目标相同的补丁(由Andrew Morton维护),跟您的
有何不同?
RL: 这两个补丁所针对的问题都是内核是非抢占的。也就是说,处于内核态的任
务会一直运行,直到其运行结束或主动交还控制权。如果用户态事件在内核操作
的时段发生,用户程序必须等待内核完成本次运行。这个等待就导致了系统延迟,
而它(系统延迟)正是我们要去改进的。
Andrew的低延迟补丁在内核的各策略点(note: Andrew认为可能引发长时间延
迟的点)加入了条件调度调用(conditional scheduling calls),这些调度
非常有效地使长时间的内核操作作出让步:"我很乐意让别人先运行。有没有想运
行的任务啊?如果有的话,就先运行吧!"这样拆分了长时间的操作,降低了相应
内核运行点的系统延迟。
抢占式补丁工作机理则很不一样。它修改内核本身以允许核心代码被抢占,所以
上述问题甚至根本不会存在。如果有任务需要运行,它就会运行,系统响应从中
受益(note: 减少了响应时间,改善了系统响应)。
JA: 在最新的lkml 中,您提到有可能将两个补丁组合起来。这是您现在的工作
方向吗?
RL: 这当然是需要考虑的。由于我们不能在系统被锁定时抢占(note: 即使内核
打了可抢占补丁),长时间的锁对系统延迟来说是一个很大的威胁。锁的延时很可
能就成了那段时间系统的延迟。
一种解决方法是像Andrew的补丁所做的那样拆分这些锁。这将成为合并部分他的
补丁到抢占式补丁的目的,或者更现实一些,做一个他的低延迟补丁的抢占式版本。
他的patch中的在内核被锁定时的任何条件调度都可能是有用的(note: 对于改进
我们的patch)。
这个方向(note: 拆分长时间的占用锁)的第一步是标识出长时间被占用的锁,这
正是抢占统计(preempt-stats)补丁所做的。这种方法衡量禁止抢占的时间并报
告导致这个结果的锁。
以上仅仅是针对长时间锁的一种解决方法。
JA: 您所标识的内核的哪些部分会出现这种长时间锁呢?
RL: 控制台层,过去可能出现非常长时间的锁,幸运的是,最近
Andrew Morton修正了很多这方面的问题。Frame buffer的代码会屏蔽中断很
长时间以避免往其输出太多。如果滚屏太多,延迟甚至可能达到500ms。切换虚拟
终端的情况也很糟糕,blkdev_close()会很长时间的占用一个锁。有些模块操作
很耗时。如果VM开始出现颠簸(thrashing),它也会导致很多延迟,因为颠簸时
VM会占用一个锁。VFS也有一些长时间占用的锁。
JA: 将您的补丁加入2.5可能性多大?会有哪些阻碍?
RL: 这完全取决于Linus先生对这个补丁的看法以及其他hacker的意见。Linus
之前曾表示他对这个想法很感兴趣,我希望他的兴趣可以帮着将这个补丁加入内核。
作为一个独立的补丁,我们有很广泛的用户基础,这显然非常有用。我们收到了很
多反馈,包括一些显示这个patch对系统带来巨大的改善的评测。
反对意见是,抢占式内核降低了系统的吞吐量。这是关键点,也是我们需要特别说
明的。现在的多数测试显示了0~5%的吞吐量损失--我想相对于200%的响应提升这
是值得的!另一些测试则显示了系统吞吐量的提升,因为我们更好的排列了系统的处
理流程(thread better)。退一步,对于那些无法接受吞吐损失的系统,抢占式
内核只是一个可选。
JA: 您开发时主要使用哪些工具?请描述一下您的环境、计算机和使用的方法。
RL: 我使用最多的主机是PIII-733(384MB内存+U2W SCSI磁盘)。我也有一台
IBM ThinkPad,还有撒满一地的旧工具(note: 电脑原件)。我运行的是最新的
RedHat Rawhide和Ximian GNOME。
我用vi写代码,因为我不想学其他的OS。:)
我一般在X下工作,因此会打开一些gnome终端和gvim窗口以进行我的工作。我喜
欢到处grep,必要时research,然后开始coding。我几乎不在纸上设计。我经
常依赖于lkml和私人email--还喜欢在别人面前吹嘘自己的想法。
JA: 您还使用什么操作系统?与Linux相比你,喜欢它们什么,不喜欢什么?
RL: 我有一个Windows 2000的工作站,和运行Irix的老的SGI Indy。其他都是
运行Linux的机器。我保留Windows是为了可以运行PowerPoint,以防止
AbiWord不管用的情况。对其他操作系统我最不喜欢的是它们不开放源码。我不是
自由软件的忠实信徒--尽管我赞赏它的优秀--但是开放的源码和它周围的群体都是
无价的。
JA: 您有没有玩过开发源码的BSD操作系统?更具体地说,你有没有具体研究过其
他的内核?
RL: 我曾经有过OpenBSD的计算机,但后来我把它扔到了垃圾站(不是OpenBSD的
原因)。我关于系统的知识停留在理论阶段。我对Matt Dillon在FreeBSD方面的
工作印象很深(他写了包括VM在内的很多部分)。他们的SMPng工作在很好的跟上
(在SMP伸缩性方面,他们不如Linux),他们也在考虑实现抢占式内核。
JA: 您知不知道他们将采用那种形式的抢占?像你的补丁中使用的,或者Andrew的,
或两者的组合中使用吗?
RL: 他们正考虑使用一个完全抢占式的内核,就像我的补丁那样。除了这个方案
被FreeBSD核心团队讨论过之外,我不清楚他们在这方面还做了哪些工作。
JA: 您对当前2.4系列内核的印象如何?您认为它稳定吗?
RL: 从2.2以来,我想我们跨越的距离(note: 内核的改进)是令人惊奇的。2.3中
完成、现在保留在2.4中的工作是令人难以置信的。我们所做的一些改进,尤其是
Linus和Ingo的工作,都是难以置信的。2.4可以工作在非常高性能/高可扩展的
环境之中。
这并不表示我对2.4完全满意了。在这一点上,我认为,去除Rik的VM是一个错误。
如果Linus想在2.5中有新的尝试,就应该尝试所有的途径。然而,在稳定版本中,
我认为我们应该尽可能少作改变。我们不仅仅抛弃了一年多的VM工作,同时也丢弃
了所有相应的文档和理解。尽管如此,VM看起来正在很好地成型。我使用的是
Alan的内核,它采用了Rik的VM,我们正在对它进行改进工作。谁知道如果将2.4
交给Alan,VM将会是什么样子。
JA: 如果突然由您主管内核,您会如何处理这些问题?
RL: 首先,在我的统治下内核将会变成一堆垃圾。不管我如何抱怨,或者他人如何
反对Linus,他不光是一个神奇的hacker,更是一个出色的管理者。Linux需要他。
在VM问题上,我的2.4将跟随Alan的方向。Rik的VM是经过测试并有文档的。我想
我们需要对它进行更完善的测试。太多Rik的好想法和补丁被忽略了。其他不应当
被吸收的补丁却被吸收了。我们需要逐渐吸收VM的工作成果,和吸收与VM没有冲突
的补丁同步进行,测试结果。在Alan的开发树上我们有类似的机制。
对于2.5,当然,任何东西都可以进来。任何东西也可能被去除。我认为Andrea的
VM现在表现得不错。可能它比我认为的更好。但现在才发现它的优点,这不是一个
好的时机。
JA: 对于2.5您看好什么?您期望什么时候开始这方面的工作?
RL: 当然是抢占式的内核。
除此之外,我想继续探索finer-grained locking和overall cleanup。我想
块设备,SCSI层,以及控制台层的重写是有计划的。我们需要考虑NAPI以及其他
形式的IRQ控制。 Ben LaHaise的异步I/O也应该被吸收。Keith的new kbuild
看起来很好。我期待所有这些。
我认为有必要对tty系统进行彻底的重写,但我不知道谁会来做这件事... 至少我
不会。我认为,不会有人,包括Linus,清楚何时2.5问世。我曾经预测在3月份到
5月份之间--像往常那样在2.4.0之后两个月内。既然都快一年了
(2.4在2001年1月4日发布),我更无法猜测。我怀疑当VM稳定了,Alan和Linus
一致的时候,我们会见到2.5.0。但愿不会太久。
JA: 您见过Linus吗?还有Alan,或者其他的Kenerl hackers?
RL: 我没有见过任何著名的hacker。我真希望某一天能见到他们。或许在某个会
议上,或在宠物公园。
JA: 在您除Linux之外的其他时间里,喜欢做些什么?
RL: 除了Linux,学校和女朋友,我喜欢越野骑车,修整我的汽车,看rock演出。
JA: 最近看了哪些精彩的演出? Gainsville出了好多著名的音乐。
RL: 嗯,最近不是很多。Cadillac Blindside两星期前有一场演出,我喜欢他
们。 Jane's Addiction昨晚上演。当然,Less than Jake是当地的,我经常
看这样的演出。它们很棒。
JA: 对那些好学的Kernel hackers,您有什么建议和启示激励他们?
RL: 读源码,玩转源码,逐渐深入。对新手来说,O'Reilly出了一些好书
("Understanding the Linux Kernel" by Bovet and Cesati,
"Linux Device Drivers, 2ed" by Rubini and Corbet都很不错)。
最重要的是读源码。你有整个系统的源码--读、改、学。我几年前在lkml注册,
但在2.3之前我从未作过任何贡献。在lkml潜水是一个很好的方法,可以学到很
多东西。
JA: 非常感谢您花费这么多时间透彻地回答了我的所有问题!由于我们的谈话,我决定
在我的系统上使用你的可抢占内核补丁。
RL: 太好了!告诉我它运行如何,同时也谢谢MontaVista的那些伟大的家伙们。
后记:
在与Robert谈话之后,我下载了他的补丁,作了一个运行测试(应用于2.4.12-ac1)。
哇!性能改进真令人吃惊!VMWare和Mozilla之类曾经在启动和退出时让系统冻结的
应用程序在使用了Robert的补丁后,可以同时启动,并完全保持系统的响应。我还
发现当这些大程序启动时xmms不再"skips"。我将一直使用这个补丁。现在我希望
它能被吸收到2.5的源码中。
译者注:
英文原文自:www.kerneltrap.org
Robert.M.Love在大学三年级的时候,就已经成为了linux kernel的core
hacker之一,拥有了7年使用Linux的经验,不得不让人叹服。
他很谦虚,还很英俊(可以去internet上搜索他的相片:)。
KernelTrap(他的访问以有技术深度而著称) 在2001/2002年各对Robert.M.Love,
分别进行一次访问。2001年的访问(本篇访谈)时,Robert.M.Love所维护的内核
可抢占patch尚未加入2.5中。2002年的访问则是在这个patch加入2.5后进行的。
2002年的访谈翻译工作也将很快开始,请关注。
译者的email:
easyway: huyisui@zju.edu.cn
anlin: book_daemon@yahoo.com.cn
欢迎大家对我们的的翻译工作提出建议。
文章标题 我来说说 IE 与 Mozilla 中 JavaScript 的主要差异 [re: dlee]
张贴者: dlee (Pooh-Bah)
张贴日期 01/12/04 10:36
这篇帖子本身纯属原创,没有必要致谢 xxx 了,呵呵。
关于 JavaScript,O'Reilly 的《JavaScript 权威指南》(犀牛书)是最好的教材,大家可以从这本书入门。
有两个基于 JavaScript 的框架,大家感兴趣的可以找来看看。
http://webfx.eae.net
http://www.i-see.net/bindows/
我想说的是 JavaScript 是非常重要的技术,不要随便轻视它。
正文:
IE 与 Mozilla 的兼容性的问题 webfx 网站已经做了很好的尝试,他们对 IE 和 Mozilla 中 JavaScript 的差异做了很好的封装。
IE 与 Mozilla 的主要差别在于:
1、对 HTML DOM 规范的支持,IE 除了支持标准的 API,还提供了 document.all() 这个便于使用的方法。但是这个方法完全可以使用标准的 getElementById() 来替代。
2、对 XML DOM,IE 提供了 selectSingleNode() 和 selectNodes() 两个便于使用的方法,而 Mozilla 使用标准的 evaluate() 方法。解决的方法是在 Mozilla 中模拟 IE 的行为。IE 中的 XML DOM 是作为 ActiveX 插件的形式(打补丁的方式)提供的,Mozilla 则本身就支持 XML DOM。
3、IE 支持 XML Data Island,而 Mozilla 由于对 XML 有更好的支持,所以完全不需要提供 XML Data Island 这种机制。但是 Mozilla 可以模拟 IE 的 XML Data Island。
http://www.mozilla.org/xmlextras/xmldataislands/
4、对于 XMLHTTP 的支持,IE 使用 ActiveX 插件实现,Mozilla 则使用 XPCOM 组件实现。但是两者的接口是相同的。
5、访问本地文件系统的方法不同,IE 使用 ActiveX 插件,Mozilla 则使用 XPCOM 组件。
6、对于事件处理的机制完全不同,IE 采用“事件传播”(“事件起泡”)方式,Mozilla 采用“事件捕捉”方式。
问题 1、2、3、4、5 都可以通过封装的方式轻易解决,但是问题 6 要很好地封装就有些难度了。
Mozilla 中的 selectSingleNode() 和 selectNodes():
代码:
if(isMozilla) {
XMLDocument.prototype.selectSingleNode = function(tagname) {
var result = this.evaluate(tagname, this, null, 0, null);
return result.iterateNext();
}
//定义一个新的类以兼容 IE 中 selectNodes() 的返回类型。
function __XMLNodes(result) {
this.length = 0;
this.pointer = 0;
this.array = new Array();
var i = 0;
while((this.array[i]=result.iterateNext())!=null)
i++;
this.length = this.array.length;
}
XMLNodes.prototype.nextNode = function() {
this.pointer++;
return this.array[pointer-1];
}
XMLNodes.prototype.reset = function() {
this.pointer = 0;
}
XMLDocument.prototype.selectNodes = function(tagname) {
var result = this.evaluate(tagname, this, null, 0, null);
var xns = new __XMLNodes(result);
return xns;
}
}
--dlee
有人说一个人有烦恼是因为记性太好。那年开始,我忘记了很多事情,唯一有印象的,就是我喜欢桃花。
真不容易
更新modutils
更新mkinitrd
更新module-init-tools
make mrproper
make menuconfig
make bzImage
make modules
make modules_install
make install
generate-modprobe.conf /etc/modprobe.conf
修改 /etc/modprobe.conf 里的 usb-uhci 为 uhci-hcd
注释掉 /etc/rc.d/rc.sysinit 中初始化 usb kbd 和 usb mouse的部分
2004/02/29 解决All of your loopback devices are in use的问题
只要 insmod /lib/modules/kernelversion/kernel/drivers/block/loop.[ko,o]即可
原因在于loopback设备没有编译到kernel里