我記得freebsd好像是有linux程序虛擬機吧,是不是所有程序都能虛擬運行呢?


http://www.freebsd.org/doc/handbook/linuxemu.html

However, some Linux?-specific operating system features are not supported under FreeBSD. For example, Linux? binaries will not work on FreeBSD if they overly use i386? specific calls, such as enabling virtual 8086 mode.

http://www.freebsd.org/doc/handbook/linuxemu-advanced.html

Technically, this is not really emulation, it is an ABI implementation. It is sometimes called 「Linux? emulation」 because the implementation was done at a time when there was no other word to describe what was going on. Saying that FreeBSD ran Linux? binaries was not true, since the code was not compiled in.

之前玩過一陣子FreeBSD,很多的帶源碼的軟體運行都沒有問題的。

一個比較蛋疼的是Linux下直接用socket.h就能做到的東西,BSD下要用BPF。


大部分可以的,但偶爾可能會出現依賴性的問題。

osx其實也可以二進位兼容運行一些
理論上FreeBSD支持Linux程序。FreeBSD有著Linux兼容的ABI(也就是說直接二進位兼容),我在用FreeBSD的時候,偶爾有Linux程序把FreeBSD直接識別成Red Hat。


兩者的API十分相似,只用到兩者公共API交集的程序可以相互用。早期linux參考unix做的API,但這兩玩意分家時間太長了,就有一部分不兼容的API和Lib集,所以會有很大一部分程序不能同時跨兩個平臺。好在大多數程序都是有源碼的,調整一下編譯宏也就能用了(相當於不同代碼編出來的)。

有些很好用的Linux-special(Linux專有的系統調用),FreeBSD下沒有,這種的顯然FreeBSD無法使用。

另外,同一個系統調用的同一個參數的同一個選項,可能FreeBSD的效果和Linux又不一樣,能跑起來也未必可靠。

用了FreeBSD很久了,基本上沒用過所謂的Linux兼容。

很好奇,到底什麼叫Linux程序?Vim算Linux程序嗎?難道Vim直接使用Linux內核的系統調用?Firefox算Linux程序嗎?Firefox直接使用Linux內核的系統調用?

Linux程序到底是個什麼概念?
推薦閱讀:
相關文章