perl print @
#!/usr/bin/perl@rocks=qw(ab cd ef gh);
print @rocks; #打印出abcdefgh
print @rocks."\n"; #打印4
posted @ 2009-02-18 15:00 九寶 閱讀(345) | 評(píng)論 (0) | 編輯 收藏
posted @ 2009-02-18 15:00 九寶 閱讀(345) | 評(píng)論 (0) | 編輯 收藏
什么是JIT?
JIT是just in time,即時(shí)編譯技術(shù)。使用該技術(shù),能夠加速java程序的執(zhí)行速度。下面,就對(duì)該技術(shù)做個(gè)簡單的講解。
首先,我們大家都知道,通常javac將程序源代碼編譯,轉(zhuǎn)換成java字節(jié)碼,JVM通過解釋字節(jié)碼將其翻譯成對(duì)應(yīng)的機(jī)器指令,逐條讀入,逐條解釋翻譯。很顯然,經(jīng)過解釋執(zhí)行,其執(zhí)行速度必然會(huì)比可執(zhí)行的二進(jìn)制字節(jié)碼程序慢。為了提高執(zhí)行速度,引入了JIT技術(shù)。
在運(yùn)行時(shí)JIT會(huì)把翻譯過的機(jī)器碼保存起來,已備下次使用,因此從理論上來說,采用該JIT技術(shù)可以,可以接近以前純編譯技術(shù)。下面我看看,JIT的工作過程。
當(dāng)JIT編譯啟用時(shí)(默認(rèn)是啟用的),JVM讀入.class文件解釋后,將其發(fā)給JIT編譯器。JIT編譯器將字節(jié)碼編譯成本機(jī)機(jī)器代碼,下圖展示了該過程。
什么是JIT?
JIT是just in time,即時(shí)編譯技術(shù)。使用該技術(shù),能夠加速java程序的執(zhí)行速度。下面,就對(duì)該技術(shù)做個(gè)簡單的講解。
首先,我們大家都知道,通常javac將程序源代碼編譯,轉(zhuǎn)換成java字節(jié)碼,JVM通過解釋字節(jié)碼將其翻譯成對(duì)應(yīng)的機(jī)器指令,逐條讀入,逐條解釋翻譯。很顯然,經(jīng)過解釋執(zhí)行,其執(zhí)行速度必然會(huì)比可執(zhí)行的二進(jìn)制字節(jié)碼程序慢。為了提高執(zhí)行速度,引入了JIT技術(shù)。
在運(yùn)行時(shí)JIT會(huì)把翻譯過的機(jī)器碼保存起來,已備下次使用,因此從理論上來說,采用該JIT技術(shù)可以,可以接近以前純編譯技術(shù)。下面我看看,JIT的工作過程。
當(dāng)JIT編譯啟用時(shí)(默認(rèn)是啟用的),JVM讀入.class文件解釋后,將其發(fā)給JIT編譯器。JIT編譯器將字節(jié)碼編譯成本機(jī)機(jī)器代碼,下圖展示了該過程。
通過上面的解釋,我們了解了JIT的工作原理及過程,同樣也發(fā)現(xiàn)了個(gè)問題,由于JIT對(duì)每條字節(jié)碼都進(jìn)行編譯,造成了編譯過程負(fù)擔(dān)過重。為了避免這種情況,當(dāng)前的JIT只對(duì)經(jīng)常執(zhí)行的字節(jié)碼進(jìn)行編譯,如循環(huán)等。
需要說明的是,JIT并不總是奏效,不能期望JIT一定能夠加速你代碼執(zhí)行的速度,更糟糕的是她有可能降低代碼的執(zhí)行速度。這取決于你的代碼結(jié)構(gòu),當(dāng)然很多情況下我們還是能夠如愿以償?shù)摹?/p>
posted @ 2009-01-13 14:18 九寶 閱讀(2140) | 評(píng)論 (0) | 編輯 收藏
* 嵌入式系統(tǒng)中主要的存儲(chǔ)介質(zhì) Flash 是稀有資源,為數(shù)不多的 RAM 也是。在嵌入式
系統(tǒng)開發(fā)中,開發(fā)人員十分珍惜這兩種資源,也想出了許多辦法解決資源短缺的問題。
* Linux 中,rootfs 是必不可少的。PC 上主要實(shí)現(xiàn)有 ramdisk 和直接掛載 HD(
Harddisk,硬盤) 上的根文件系統(tǒng);嵌入式中一般不從 HD 啟動(dòng),而是從 Flash 啟
動(dòng),最簡單的方法是將 rootfs load 到 RAM 的 RAMDisk,稍復(fù)雜的就是 直接從
Flash 讀取的 Cramfs,更復(fù)雜的是在 Flash 上分區(qū),并構(gòu)建 JFFS2 等文件系統(tǒng)。
* RAMDisk 將制作好的 rootfs 壓縮后寫入 Flash,啟動(dòng)的時(shí)候由 Bootloader load 到
RAM,解壓縮,然后掛載到 /。這種方法操作簡單,但是在 RAM 中的文件系統(tǒng)不是壓
縮的,因此需要占用許多嵌入式系統(tǒng)中稀有資源 RAM。
* initrd 是 RAMDisk 的格式,kernel 2.4 之前都是 image-initrd,Kernel 2.5 引入
了 cpio-initrd,大大簡化了 Linux 的啟動(dòng)過程,附合 Linux 的基本哲學(xué):Keep it
simple, stupid(KISS). 不過,cpio-initrd 作為新的格式,還沒有經(jīng)過廣泛測(cè)試,
嵌入式 Linux 中主要采用的還是 image-initrd。
* Cramfs 是 Linus 寫的很簡單的文件系統(tǒng),有很好的壓縮綠,也可以直接從 Flash 上
運(yùn)行,不須 load 到 RAM 中,因此節(jié)約了 RAM。但是 Cramfs 是只讀的,對(duì)于需要運(yùn)
行時(shí)修改的目錄(如: /etc, /var, /tmp)多有不便,因此,一般將這些目錄做成
ramfs 等可寫的 fs。
* SquashFS 是對(duì) Cramfs 的增強(qiáng)。突破了 Cramfs 的一些限制,在 Flash 和 RAM 的使
用量方面也具有優(yōu)勢(shì)。不過,據(jù)開發(fā)者介紹,在性能上可能不如 Cramfs。這也是一種
新方法,在嵌入式系統(tǒng)采用之前,需要經(jīng)過更多的測(cè)試。
* XIP(exece-in-place,就地運(yùn)行) 是一種不須將應(yīng)用程序 load 到 RAM 就可以運(yùn)行
的技術(shù),無疑可以減少 RAM 的使用。不過在嵌入式系統(tǒng)我還沒有遇到這種技術(shù)的使用
posted @ 2008-12-29 16:58 九寶 閱讀(909) | 評(píng)論 (0) | 編輯 收藏
ct mkview -tag <view_tag> <view_storage_path> |
example:
ct mkview -tag alex_test /net/nj2/ |
Other Command:
ct lsview list all the views reside in the hosts |
ct lsview | grep name list specified view by name |
ct rmview -tag <view_tag> remove an exist view |
2. After you create a vew, you need to Set the View to enter it. Then you are able to see the vob content only when you set the view.
ct setview <view_tag> |
Example:
ct setview alex_test |
Other Commands
ct pwv see which view you are currently in |
exit quit from current view |
3. When you are in a view, you need to set the config spec correctly to pick up the right version of element.
ct catcs view your config spec |
ct edcs edit your config spec by vi editor |
Other Commands
ct catcs > filename Copy your config spec to a file |
ct setcs filename Set your config spec from a file |
What doew config spec say ? For example:
element* CHECKEDOUT element* .../ISGcq00123456/LASTEST element* BLUETOOTH_00.07.00 element* AP_SIPC.01.32.00 element* AP_IB2.00.38_ARM element* /main/LATEST |
Command
element <file path> <version path> |
file path: hello.c, *, /vob/su_java/...
version path: Label or Branch
4. Now you may have a task to do. You have a CR assigned, and you know the baseline version.
ct mkbrtype ISGcq00123456 |
ct mkbranch ISGcq00123456 hello.c@@/main/2 |
Result: hello.c@@/main/ISGcq00123456/0 is created and checked out(a copy of hello.c in the dir was created and you can edited it. If there is not hello.c in the dir, the clearcase would submit a error).
element* .../ISGcq00123456/LATEST |
Accessional:
ct mkbranch -nco ISGcq00123456 hello.c@@/main/2 |
ct rmbranch hello.c@@/main/ISGcq00123456. |
Make sure no checked out version on this branch
ct rename brtype:old_name brtype:new_name |
It will apply to all the created branch.
ct rmtype -rmall brtype:ISGcq00123456 |
5. After making your CR branch on the file to be changed, check out the version if it hasn't been checked out(checkout后會(huì)產(chǎn)生一個(gè)自己的私有文件,你可以自己修改,別人看不到,只有這個(gè)文件被checkin后才會(huì)放到vobs里).
ct co -nc hello.c@@/main/ISGcq00123456/0 |
Then, you are able to edit this file. After you finish the change, check in the file to vob.
ct ci -nc hello.c |
The result is, the element will increase one version on the branch:
hello.c@@/main/ISGcq00123456/1 |
Accessional
A checked out version is only in your view. Other engineer can not see it. If you remove that view, you will lost the checked out version.
You can undo checkout by:
ct unco hello.c |
If a checked version has no change, it can't be checked in. You will get an error message like "The file is identical"
An unreserved checked out will not block other people check out the same version. Normally, we just use reserved checkout.
You can only check out a file on the branch which has mastership role.
6. If your task is to create a new file, you need to do below steps:
ct mkbranch ISGcq00123456 /vob/su_jave/code/src |
ct mkelem -nco hello.c |
Create a folder
ct mkelem -eltype directory test |
Dont check it out, because you need to make the CR branch on this file.
ct mkbranch ISGcq00123456 hello.c |
ct ci -nc /vob/su_java/code/src |
Accessional
ct lsco -cview -r |
7. Now, your task is ongoing. In coding and testing, you may need to merge your file to other version. below example gives the merge steps:
Example: Merge file from hello.c@@/main/branchfrom/5 to hello.c@@/main/branchto/2
ct co -nc hello.c@@/main/branchto/2 |
ct merge -to hello.c hello.c@@/main/branchfrom/5 |
Usually you may also need to compare two versions
ct diff hello.c hello.c hello.c@@/main/branchfrom/5 hello.c@@/main/branchto/2 |
Compare this version from the previous version
ct diff -pre hello.c@@/main/branchto/2 |
Accessional
ct lsvt hello.c |
include the merge info
ct lsvt -merge hello.c |
Remove a merge arrow:
ct rmmerge hello.c@@/main/branchfrom/5 hello.c@@/main/branchto/2 |
Dont do actual merge, just draw a merge line
ct merge -ndata hello.c@@/main/branchfrom/5 hello.c@@/main/branchto/2 |
In what cases we need merge:
8. If you want to remove an un-use version, use the command
ct rmver hello.c@@/main/branchto/2 |
Then the version 2 will be removed, but next time the version will increase from 1 to 3.
If you want to remove a file, you can use remove name command:
ct rmname hello.c |
Be sure to make branch and check out the current directory before rmove it, just like the steps of make element.
If you want to rename a file, you can use
ct mv old_name new_name |
If you want to create an element link, you can use
ct ln source_file file_link |
(checkout current folder like above)
9. Now you may have completed the task of coding, testing, inspection, and prepare to release it. You need to check your developed version is complied with below rules:
10. How to label the version
Make the label type:
ct mklbtype BLUETOOTH_00.07.00 |
Make label on a version:
ct mklabel BLUETOOTH_00.07.00 hello.c@@/main/branchto/2 |
Move a label from the old version to a new version:
ct mklabel -replace BLUETOOTH_00.07.00 hello.c@@/main/branchto/3 |
Remove label on a version:
ct rmlabel BLUETOOTH_00.07.00 hello.c@@/main/branchto/3 |
Remove the label type
ct rmtype lbtype:BLUETOOTH_00.07.00 |
11. How to search the reuqired version
Find all files with the version(.../ISGcq00373766/LATEST) and with no label SAMBA_AP_DSL_BLUETOOTH_00.00.07:
ct find /vob/directory -version 'version(.../ISGcq00373766/LATEST) && !version(SAMBA_AP_DSL_BLUETOOTH_00.00.07)' -print |
Find all files with the version SAMBA_AP_DSL_BLUETOOTH_00.00.07, and then search STRING in all found files:
ct find .-version 'version(SAMBA_AP_DSL_BLUETOOTH_00.00.07)' -exec 'grep STRING $CLEARCASE_PN' |
posted @ 2008-11-12 14:14 九寶 閱讀(1239) | 評(píng)論 (0) | 編輯 收藏
1、cramfs的特點(diǎn)
在嵌入式的環(huán)境之下,內(nèi)存和外存資源都需要節(jié)約使用。如果使用RAMDISK方式來使用文件系統(tǒng),那么在系統(tǒng)運(yùn)行之后,首先要把外存(Flash)上的映像文件解壓縮到內(nèi)存中,構(gòu)造起RAMDISK環(huán)境,才可以開始運(yùn)行程序。但是它也有很致命的弱點(diǎn)。在正常情況下,同樣的代碼不僅在外存中占據(jù)了空間(以壓縮后的形式存在),而且還在內(nèi)存中占用了更大的空間(以解壓縮之后的形式存在),這違背了嵌入式環(huán)境下盡量節(jié)省資源的要求。
使用cramfs就是一種解決這個(gè)問題的方式。cramfs是一個(gè)壓縮式的文件系統(tǒng),它并不需要一次性地將文件系統(tǒng)中的所有內(nèi)容都解壓縮到內(nèi)存之中,而只是在系統(tǒng)需要訪問某個(gè)位置的數(shù)據(jù)的時(shí)侯,馬上計(jì)算出該數(shù)據(jù)在cramfs中的位置,將其實(shí)時(shí)地解壓縮到內(nèi)存之中,然后通過對(duì)內(nèi)存的訪問來獲取文件系統(tǒng)中需要讀取的數(shù)據(jù)。cramfs中的解壓縮以及解壓縮之后的內(nèi)存中數(shù)據(jù)存放位置都是由cramfs文件系統(tǒng)本身進(jìn)行維護(hù)的,用戶并不需要了解具體的實(shí)現(xiàn)過程,因此這種方式增強(qiáng)了透明度,對(duì)開發(fā)人員來說,既方便,又節(jié)省了存儲(chǔ)空間。
cramfs擁有以下一些特性:
采用實(shí)時(shí)解壓縮方式,但解壓縮的時(shí)侯有延遲。
cramfs的數(shù)據(jù)都是經(jīng)過處理、打包的,對(duì)其進(jìn)先寫操作有一定困難。所以cramfs不支持寫操作,這個(gè)特性剛好適合嵌入式應(yīng)用中使用Flash存儲(chǔ)文件系統(tǒng)的場合。
在cramfs中,文件最大不能超過16MB。
支持組標(biāo)識(shí)(gid),但是mkcramfs只將gid的低8位保存下來,因此只有這8位是有效的。
支持硬鏈接。但是cramfs并沒有完全處理好,硬鏈接的文件屬性中,鏈接數(shù)仍然為1.
cramfs的目錄中,沒有“.”和“..”這兩項(xiàng)。因此,cramfs中的目錄的鏈接數(shù)通常也僅有一個(gè)。
cramfs中,不會(huì)保存文件的時(shí)間戳(timestamps)信息。當(dāng)然,正在使用的文件由于inode保存在內(nèi)存中,因此其時(shí)間可以暫時(shí)地變更為最新時(shí)間,但是不會(huì)保存到cramfs文件系統(tǒng)中去。
當(dāng)前版本的cramfs只支持PAGE_CACHE_SIZE為4096的內(nèi)核。因此,如果發(fā)現(xiàn)cramfs不能正常讀寫的時(shí)侯,可以檢查一下內(nèi)核的參數(shù)設(shè)置。
2、使用cramfs
可以從http://sourceforge.net/projects/cramfs/下載cramfs-1.1.tar.gz。然后執(zhí)行
tar zxvf cramfs-1.1.tar.gz
進(jìn)入解包之后生成cramfs-1.1目錄,執(zhí)行編譯命令:
make
編譯完成之后,會(huì)生成mkcramfs和cramfsck兩個(gè)工具,其中cramfsck工具是用來創(chuàng)建cramfs文件系統(tǒng)的,而mkcramfs工具則用來進(jìn)行cramfs文件系統(tǒng)的釋放以及檢查。
下面是mkcramfs的命令格式:
mkcramfs [-h] [-e edition] [-i file] [-n name] dirname outfile
mkcramfs的各個(gè)參數(shù)解釋如下:
-h:顯示幫助信息
-e edition:設(shè)置生成的文件系統(tǒng)中的版本號(hào)
-i file:將一個(gè)文件映像插入這個(gè)文件系統(tǒng)之中(只能在Linux2.4.0以后的內(nèi)核版本中使用)
-n name:設(shè)定cramfs文件系統(tǒng)的名字
dirname:指明需要被壓縮的整個(gè)目錄樹
outfile:最終輸出的文件
cramfsck的命令格式:
cramfsck [-hv] [-x dir] file
cramfsck的各個(gè)參數(shù)解釋如下:
-h:顯示幫助信息
-x dir:釋放文件到dir所指出的目錄中
-v:輸出信息更加詳細(xì)
file:希望測(cè)試的目標(biāo)文件
posted @ 2008-08-14 15:43 九寶 閱讀(504) | 評(píng)論 (0) | 編輯 收藏
linux下沒有文件后綴來比較文件格式的用法
只有兩種文件基于文本格式的sh和可以執(zhí)行的2進(jìn)制文件
vi filename
在編輯好你的文件后可以用wq!保存
這樣就可以生成一個(gè)你以編輯好的文件
還有vim gedit等文件編輯器
也可以用上樓說的生成一個(gè)文件
touch filename
posted @ 2008-07-10 15:50 九寶 閱讀(266) | 評(píng)論 (0) | 編輯 收藏
set -o 打印所以的選項(xiàng)
set -o vi 打開選項(xiàng)
set +o vi 關(guān)閉選項(xiàng)
shopt -p 打印所以的選項(xiàng)
shopt -s cdspell打開選項(xiàng)
shopt -u cdspell關(guān)閉選項(xiàng)
posted @ 2008-07-10 15:49 九寶 閱讀(280) | 評(píng)論 (0) | 編輯 收藏
Shell 運(yùn)算和進(jìn)制轉(zhuǎn)換 Shell 提供大量的基本運(yùn)算操作,在腳本中非常有用。Shell 對(duì)您提供的算術(shù)表達(dá)式求值,執(zhí)行運(yùn)算展開式,此時(shí)使用得出的結(jié)果替換表達(dá)式。以下面的格式提供運(yùn)算表達(dá)式:
您可以使用 清單 5. Bourne Shell 中的運(yùn)算展開式
您還可以將展開式分配給變量。嘗試清單 6 所顯示的結(jié)果。 清單 6. 將運(yùn)算展開式分配給 Shell 變量
表 2 列出了在大多數(shù) Bourne 以及與 Bourne 兼容的 Shell中可以使用的運(yùn)算符。正如上面第二個(gè)示例,使用圓括號(hào)括起來的語句有更高的優(yōu)先級(jí)。實(shí)際上,Shell 算術(shù)優(yōu)先級(jí)通常根據(jù) C 語言的規(guī)則來確定。 表 2. Shell 條件表達(dá)式
使用 Shell 運(yùn)算進(jìn)行進(jìn)制轉(zhuǎn)換 假定在您的腳本中有一些數(shù)字,您需要以另外的進(jìn)制處理這些數(shù)字。使用 Shell 運(yùn)算可以很容易地自動(dòng)實(shí)現(xiàn)這類轉(zhuǎn)換。一種情況是使用 Shell 運(yùn)算把一個(gè)數(shù)字從給定的進(jìn)制轉(zhuǎn)換位十進(jìn)制。如果數(shù)字以運(yùn)算展開式的形式提供,那么假定它帶有十進(jìn)制符號(hào),除非 它前面帶有 0(這種情況假定是八進(jìn)制)或 0x(這種情況假定是十六進(jìn)制)。鍵入以下內(nèi)容以得到一些八進(jìn)制和十六進(jìn)制值的十進(jìn)制輸出:
您還可以使用以下格式指定 2 到 64 之間的任意進(jìn)制:
通過在 Shell 提示符后鍵入清單 7 中所示的行,嘗試將二進(jìn)制、八進(jìn)制、十六進(jìn)制以及其他進(jìn)制的數(shù)轉(zhuǎn)換為十進(jìn)制。 清單 7. 在 Shell 中將任意進(jìn)制的數(shù)以十進(jìn)制輸出
在 Shell 中進(jìn)行進(jìn)制轉(zhuǎn)換的另一個(gè)訣竅是使用
清單 8. 使用 bc 執(zhí)行進(jìn)制轉(zhuǎn)換
要快速執(zhí)行進(jìn)制轉(zhuǎn)換,可以聯(lián)合使用 清單 9. Shell 單命令行 bc 程序
警告:當(dāng)您設(shè)置 清單 10. 設(shè)置輸入和輸出進(jìn)制的先后順序的重要性
|
posted @ 2008-07-09 14:46 九寶 閱讀(1654) | 評(píng)論 (0) | 編輯 收藏
posted @ 2008-07-08 10:21 九寶 閱讀(206) | 評(píng)論 (0) | 編輯 收藏
posted @ 2008-05-20 13:22 九寶 閱讀(382) | 評(píng)論 (0) | 編輯 收藏