在ubuntu上安裝完整的man pages
難得三更半夜有動力coding一下,熊熊要查一system call卻沒書可翻用到的函數網路資料又少...,最後向man求援居然沒資料,原來ubuntu的man pages有給它偷工減料(畢竟人家使用者是針對普羅大眾...就不跟他計較了XD)。
如果要安裝完整system call的man pages可以:
sudo apt-get install manpages-dev
當你遇到左右為難時,其實你不需要煩惱, 代表兩方都有優點, 你的機會還比別人多
難得三更半夜有動力coding一下,熊熊要查一system call卻沒書可翻用到的函數網路資料又少...,最後向man求援居然沒資料,原來ubuntu的man pages有給它偷工減料(畢竟人家使用者是針對普羅大眾...就不跟他計較了XD)。
sudo apt-get install manpages-dev
@
凌晨2:00
0
Reply
Tag:
Linux,
Linux Programming
目前以Linux為核心的Distribution已經多到則以讓新手眼花撩亂了,究竟哪套Distribution適合自己呢?或許可以參考一下Linux Distribution Chooser網站,做幾個選擇測驗找出可能適合自己的Distribution吧!
$ ls -l /proc/version上面指令使用ls觀察/proc/version檔案,可以看到兩個特點:其一,檔案大小為0,亦即不占據任何空間;其二,檔案的修改時間為下指令時的時間。
-r--r--r-- 1 root root 0 2010-02-03 10:36 /proc/version
$ cat /proc/version使用cat指令觀看該檔案內容則可以看到得知該檔案紀錄著Linux Kernel的相關資訊,在上述訊息中可以得知目前使用的核心版本是2.6.31,使用gcc-4.4.1版本的編譯器編譯而成等訊息。
Linux version 2.6.31-14-generic (buildd@rothera) (gcc version 4.4.1 (Ubuntu 4.4.1-4ubuntu8) ) #48-Ubuntu SMP Fri Oct 16 14:04:26 UTC 2009
$ cat /proc/cpuinfo上面範例可以知道/proc/cpuinfo檔案儲存著關於系統處理器的相關資訊,若處理器具備多顆核心則會有多組訊息。底下程式示範如何運用/proc下的檔案內容擷取CPU的工作時脈:
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 15
model name : Intel(R) Core(TM)2 CPU 6320 @ 1.86GHz
stepping : 6
cpu MHz : 1866.837
cache size : 0 KB
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 5
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 constant_tsc up pni monitor
bogomips : 3733.67
clflush size : 64
#include <stdio.h>
#include <string.h>
float get_cpu_clock_speed() {
FILE *fp ;
char buffer[2048] ;
size_t bytes_read ;
char *match ;
float clock_speed ;
fp = fopen("/proc/cpuinfo", "r") ;
bytes_read = fread(buffer, 1, sizeof(buffer), fp) ;
fclose(fp) ;
/* Bail if read failed or if buffer isn't big enough */
if(bytes_read == 0 || bytes_read == sizeof(buffer))
return 0 ;
/* NUL-terminate the text */
buffer[bytes_read] = '\0' ;
/* Locate the line that starts with "cpu MHz" */
match = strstr(buffer, "cpu MHz") ;
if(match == NULL)
return 0 ;
/* Parse the line to extract the clock speed */
sscanf(match, "cpu MHz : %f", &clock_speed) ;
return clock_speed ;
}
int main() {
printf("CPU clock speed: %4.2f Mhz\n", get_cpu_clock_speed()) ;
return 0 ;
}
@
上午10:25
0
Reply
Tag:
Linux,
Linux Programming