2012年12月25日 星期二

Virtualization相關Conference

Red: A class top conf.
Orange: B class top conf.
Green: Other conf.

Virtualization

  •  VEE - International Conference on Virtual Execution Environments

OS

  • OSDI - Operating Systems Design and Implementation
  • SOSP - Symposium on Operating Systems Principles
  • USENIX - USENIX Technical Conference
  • RTSS - IEEE Real-Time Systems Symposium
  • USITS -- USENIX Symposium on Internet Technologies and Systems 
  • HotOS(WWOS) - Workshop on Workstation Operating Systems
  • Hybrid Systems
  • CASES - Compilers, Architecture, and Synthesis for Embedded Systems
  • SDSDI - Unix Symposium on Operating Systems Design and Implementation 
  •  

Architecture and Compiler

  • ISCA - International Symposium on Computer Architecture
  • MICRO - International Symposium on Microarchitecture
  • ASPLOS - Architectural Support for Programming Languages and Operating Systems
  • HPCA - International Symposium on High-Performance Computer Architecture 
  • PACT - International Conference on Parallel Architectures and Compilation Techniques
  • CGO - Symposium on Code Generation and Optimization

Mobile and embedded system

  • EMSOFT - International Workshop on Embedded Systems
  • MOBICOM: ACM/IEEE Intl Conf on Mobile Computing and Networking
  • MOBISYS: International Conference on Mobile Systems, Applications, and Services
  • SCOPES - International Workshop on Software and Compilers for Embedded Systems
  • LCTES - ACM SIGPLAN Conference on Languages, Tools, and Compilers for Embedded Systems 

參考資料: 清交資工系升等與博班點數標準

2012年5月12日 星期六

如何讓vim能自動parse出ARM的組合語言

在開發Linux kernel for ARM的時候,我們時常會使用vim來編寫程式碼,在一般以C語言撰寫的部份,vim皆能正確地對程式碼標色。但是在組合語言( Assembly language )檔案的部份,許多時候並不能對指令、參數等正確標色,實為缺憾。

但是我們發現在vim.sourceforge網站上,有人提供了armasm.vim的檔案,能夠讓vim能夠正確的對arm的組合語言標色。不過可惜的是只有Support到v5以前的指令,在v6之後的指令就只能自行修改armasm.vim檔案來支援,不過對於大多數的指令來說已經很夠用了。

其網頁於此:http://vim.sourceforge.net/scripts/script.php?script_id=888


其使用方法如下:
(註:我的使用環境是Ubuntu 11.10,VIM 7.3 for Ubuntu)

1. armasm.vim要放置的資料夾建置

   在家目錄下,建置.vim資料夾,再於.vim資料夾下建置syntax資料夾
   前述資料夾若已經存在則不需再另外建立

2. 取得並放置armasm.vim檔案

     (1) 去http://vim.sourceforge.net/scripts/download_script.php?src_id=4029 下載armasm.vim檔案

     (2) 將方才下載的armasm.vim檔案放置到~/.vim/syntax下

3. 修改家目錄下的.vimrc檔案,使vim能預設啟用armasm.vim檔案

    增加下列字串:
let asmsyntax='armasm' 
let filetype_inc='armasm'


調整好後,用vim開啟arm組合語言檔案就能正確標色




Creative Commons Licence

2012年4月14日 星期六

Alignment & Padding (English)

In order to prevent alignment exception, compiler will pad some empty data into memory to let it fit the alignment restriction.
Here is an example in C:

If we declare a structure like this:

struct align{
   char a;
   int b;
   short int c;
};

We will consider that it will use 7 bytes. However, because it has to prevent alignment exception,compiler will add some padding to let it fit 32-bit (i.e. 4 bytes). It may consider like this:

struct align{
   char a;
   char padding_0[3]; // add by compiler, programmer cannot use   
 
   int b;
   short int c;
   char padding_1[2]; // add by compiler, programmer cannot use   
};

Its memory allocation will look like this:
(放圖)

It is obvious to see that padding will waste lots of memory space. As a result, in order to save memory space, sometimes compiler also provide some pragma to let programmer to add in their code, and compiler can use these pragma to let compiler reallocate the memory allocation of this structure.

Here is an example:

#pragma pack(push)
#pragma pack(4)
        struct align
        {
                char a; //1 byte
                int b;  //4 bytes
                short int c;  //2bytes
        };
#pragma pack(pop)
It will let compiler to reallocate its memory allocation and use memory more efficiently.



Creative Commons Licence



Ref: http://en.wikipedia.org/wiki/Data_structure_alignment

About me

Junior System Software Programmer

M.S. in CS
B.S. in EE

In EECS area

Major research interest: Virtualization, Kernel
Minor research interest: Computer Architecture, Compiler, Other system software
More minor research interest: Digital Signal Process
Just for fun: Probability, Electromagnetism

Familiar develop environment:
Processor: ARM, x86, TI-C64xx;
OS: Linux, Mac OS X;
Compiler: GCC, Clang-LLVM

Preferred Software License: BSD License
Preferred Kernel: XNU ( Darwin Kernel )
Preferred Compiler: LLVM


於EECS領域研究興趣:
主要研究作業系統核心、虛擬化技術。對於計算機架構與其他系統軟體亦有相當的研究興趣。因過去大學時的經驗,對DSP、機率、電磁相關領域的知識,亦會作為業外新知來吸收。

熟悉的開發平台與環境:
在處理器架構上,主要對ARM有相對較高的熟悉,對x86、TI-C64xx系列亦有些微了解。在作業系統環境上,主要開發對象為Linux,主要使用環境為Mac OS X與Ubuntu。在編譯器環境上,傳統上使用GCC,最近亦對LLVM有興趣接觸與使用。

C語言:函式的Coding-style

傳統上,我們學C語言的時候,大多使用的寫法方式大多如下:
int main(int argc,char **argv)
{
 ... 
}

會直接把傳進函數的參數的type與名稱打在函式名稱右邊的小括弧中。

也因此,有些人的Coding-style,會傾向把函式的左括弧和函式名稱放在同一行,就例如這樣:
int main(int argc,char **argv) {
 ... 
}

這樣的寫法並不違背C語言的語法,拿去編譯器編譯也當然會過,說實在的如果只是寫給自己看、或是工作的環境並沒有特別指定Coding-style的話,只要自己習慣並沒有什麼不好。

然而,如果開發OpenSource相關專案的人,或多或少都會和開源社群交流,也會去trace甚至更改Source code,在這樣的狀況下,規範一個固定的Coding-style實屬必要。以Linux社群為例,就有著一份 "Documentation/CodingStyle and Beyond" (http://kernel.org/doc/ols/2002/ols2002-pages-250-259.pdf) 來約束大家的Coding-style,以便其他完全素昧平生的開發者,也能輕易的(?)看懂你寫的原始碼。

在"Documentation/CodingStyle"這篇文章當中,對函式寫法的標準是:
int foo(int x)
{
 ... 
}

一開始我在看到這段的時候,覺得只是一個換行符號的差別,僅是社群內自行約束的習慣而已,並不以為意。

然而,後來因緣際會看到一些特殊的函式寫法例子之後,就覺得將左括弧換行是有其必要性,我們來看一個例子:
int main(argc,argv)
    int argc;
    char **argv;
{
 ... 
}

上面的程式碼是在GNU Bash當中,實作printenv指令時,main function的寫法。從上面我們可以看到,他在函式名稱旁邊的小括弧當中,其傳遞進函式的參數,僅將其名字列出,並不指定type,而是換行之後才將其宣告寫入,最後再換行打入左大括號。

初次看到此種寫法之時,會以為這個寫法是有問題的,但將此種寫法拿去編譯器編譯,並不會出現問題,此種寫法是早期C語言的寫法,而在此寫法中,函式變數旁的小括弧和負責包住函式本體的大括弧中間,確實有可能出現其他內容,甚至有換行之必要,故在此寫法下,會希望負責包住函式本體的左大括弧,和括住傳入函式參數的小括弧中間有需要換行,而此習慣便延續到現在Linux kernel的Coding-style當中。



Creative Commons Licence

2012年2月17日 星期五

Introduction to Xen-ARM (1) : Brief introduction to Xen-ARM

We has studied on virtualization for years. And we want to share some interesting information on virtualization nowadays. And we also want to have communicate with others who are also interesting in virtualization. The following article is a summary from the Xen-ARM's website and related public documents.




Section 1: Brief introduction to Xen-ARM

Xen-ARM is a hypervisor which is based on ARM architecture. It means that you can run different operating system at the same time when you are using hypervisor. In the category of hypervisor, Xen-ARM is categorized as Type-1 hypervisor[1] . Besides, it's necessary to patch guest OS when you want to use it running on Xen-ARM.
i.e. Xen-ARM is using para-virtualization.

Xen-ARM is based on Xen[2] which is a hypervisor running on x86-platform. Most of  developers of Xen-ARM are come from Samsung instead of XenSource which is main maintainer of Xen.

In the early stage of developing time of Xen-ARM, they had only supported FreeScale develop board. However, Xen-ARM has support several develop boards, such as XScale PXA310, Versatile, Realview-PB, Cortex-A9, etc. Meanwhile, Xen-ARM also supports Goldfish which is a QEMU emulator patched for Android. Otherwise, in software part, Xen-ARM had only supported for Linux 2.6.11 as guest OS in the early stage of developing time of Xen-ARM. But, Xen-ARM has supported for Linux 2.6.11, 2.6.18, 2.6.21, 2.6.24, 2.6.27 as guest OS nowadays.


2011年12月5日 星期一

虛擬化技術淺論:(1) What is virtualization?

虛擬化技術(Virtualization)於近年雲端運算(Cloud computing)逐漸熱門之後,漸漸廣為討論。實作雲端運算的基礎架構的方式很多,並非得利用虛擬化技術不可,而虛擬化技術除了在雲端運算的應用外,也有著許多其他的應用層面。

本系列文章是整理作者對虛擬化技術的所見所聞,希望讓讀者能夠了解虛擬化技術的前世今生,並以一個更廣泛的角度來看虛擬化技術。當然如果敘述中有缺漏或理解錯誤的部份,也歡迎諸位指教。

What is "virtualization"?

要談虛擬化技術(Virtualization),或是要談虛擬機器(Virtual Machine)是什麼之前,我們可以先來探討「虛擬」這個字眼在電腦科學領域到底有什麼含義?

在電腦科學領域當中,有著許多帶有"Virtual"字眼的技術,舉凡「虛擬記憶體」(virtual memory)、「Java虛擬機」(Java Virtual Machine)、「虛擬私人網路」(Virtual Private Network)。這些看似無關的技術之間,都有著共同的"virtual"字眼。他們雖然在電腦科學當中分屬不同子領域,但是都蘊含著「把本來不是......的東西,透過軟體來讓他們變成都是......」,例如VPN,他把本來在實體網路上並不是在同一個網域當中的電腦,透過軟體的方式讓他們看似待在同一個網域。又或像JVM,本來在不同種CPU、OS運行的可執行檔都要事先編成對應的Native code才能執行,例如要在Windows for x86、Linux for x86、Linux for ARM需要分別編成三種不同的可執行檔才能運行,但是透過JVM,我們能夠只要編成一樣的Bytecode,在執行的時候再透過JVM去轉成Native code即可,透過JVM我們把本來不是同一種的Runtime(處理器、OS不同),讓他看似變成同樣的Runtime。

Why should we "virtualize" something?

那為何我們會需要虛擬化技術呢?本來既有的硬體配置不好嗎?為什麼沒事要用軟體去把實體不存在的環境用軟體模擬出來呢?

通常我們會使用虛擬化技術主要著眼於下列幾點的好處:

  • 資源分享:
    以RAID為例,我們可以把兩顆實體500GB的硬碟透過RAID讓使用者看成1TB去存取,那假設本來每顆硬碟都只剩下30GB的容量,亦即兩顆共剩60GB的容量,但是使用者想放一個50GB的檔案卻無法放入,透過RAID把儲存空間虛擬化,使用者就可以把50GB的檔案放入,而讓後端的虛擬化技術去處理檔案區塊放置的問題,這就達到了資源分享的效果。
  • 安全性考量:
    以JVM為例,我們可以把網路上下載來不確定安不安全的程式放在JVM裡面跑,由於JVM提供了一整套的Runtime environment,在裡面跑的程式不會直接和OS與硬體溝通,這也增加了一層防護,若在JVM裡面跑的程式Crash或是想去越權探知OS當中的訊息,這些越權行為都會被JVM擋住。
  • 彈性:
    以JVM為例,用Java寫程式的程式設計師,不需要為了Windows for x86、Linux for x86、Linux for ARM分別編出三套不同的執行檔再分送出去,只需要編出一組Bytecode,就能在各種執行環境下執行。在程式開發的階段,也不需要去思考這隻程式是在什麼OS、什麼處理器下運行,為高階語言程式開發者增加了許多彈性。
  • ...




虛擬化技術的分類


目前談虛擬化技術通常大多指涉系統虛擬化(System virtualization),意即像VMware、Parallels、Xen、KVM等System VM,然而系統虛擬化並非虛擬化技術的全部,通常我們談虛擬化技術多分為下列三種:

  • Process virtualization:
    是以讓一個Process能夠跨平台運行為目標的虛擬化技術。例如Java Virtual Machine、Apple Rosetta(Apple設計能讓原本運行在PowerPC處理器上的可執行檔能夠無痛運行在x86的處理器上的Process VM)
  • Device virtualization:
    是針對周邊裝置來進行虛擬化,用軟體來模擬周邊裝置,或是將實體上為多台的周邊裝置透過軟體讓使用者看起來只有一台等等。例如:RAID、VPN
  • System virtualization:
    是以讓一個Operating System能夠運行在別的OS上,或是能夠讓一台實體機器同時運行多個OS為目標。例如:VMware、Parallels、Xen、KVM等

我們接下來將會以System virtualization為繼續討論的主題。



To be continue...


本文同步發佈在http://nthusslab.blogspot.com/