核心FAQ 舉例說明 (轉)
核心FAQ(2001.05.01~2001.05.06)
">axing〖〗〖轉發〗
1、 我編譯核心時選了音效卡支援,還把oss加入了模組,為什麼出如下問題!
2、 bootsect.s 中的一個小問題:movsw的問題
3、 0x20,&timer_interrupt它在哪裡做過schedule
4、 linux每10ms中斷一次,它在哪裡做了schedule()
5、 編譯核心後的問題:xwindow-->console看不見!
6、 kernel_thread
7、 請問如何得到linux下的命令程式碼
1、我編譯核心時選了音效卡支援,還把oss加入了模組,為什麼出如下問題!
我編譯核心時選了音效卡支援,還把oss加入了模組,為什麼出如下問題!
資訊是:
you dont seem to have a kernel with sound module
enabled,
你編譯核心時是不是把音效卡安模組方式編譯
我音效卡支援選擇的是y
oss選擇的是m
我的音效卡買了是YMH734的,可是查出是Aztech的音效卡,
以前用oss試過也沒沒用,不知您有沒有裝過這種爛音效卡!
這樣整一遍核心看行不行:
#make mrproper
#make clean
#make menuconfig
在模組的選項中全選為Yes,即 或[*]方式
音效卡這部分中:
sound card support選[*]
其它的都選[M]
儲存退出後,
#make dep
#make bzImage
#make modules
#make modules_install
為了能找到你編譯的模組,(以2.4.2為例)將所生成的
模組從/lib/modules/2.4.2/misc/中cp到/lib/modules/misc/
然後再probe你的soundcoard,也許能成功。
2、bootsect.s 中的一個小問題:movsw的問題
ibm的中,movsw進行的操作是:((DI))
所幹的事永遠是一樣的,不過彙編文法的格式不同而已。
some example:
movw %bx,%ax //mov ax,bx
xorl %eax,%eax //xor eax,eax
movw $1,%ax //mov ax,1
movb x,%ah //mov ah,byte ptr x
movw x,%ax //mov ax, ptr x
movl x,%eax //mov eax,x
b(8-bit),w(16-bit),l(32-bit)
Most opcodes are ntical between AF&T and format,except for
these:
movsSD //movsx
movzSD //movz
S,D are the and destinaion operand size suffixes.
movswl %ax,%ecx //movsx ecx,ax
Maybe mean something to you!!
3、0x20,&timer_interrupt
0x20,&timer_interrupt它在哪裡做過schedule
100箇中斷/秒(即10ms)每次中斷都可能schedule(),許多其它情況也會引起schedule(),比如在資源缺乏時會主動請求重新排程,以讓出CPU。0x20 timer_interrupt的大致過程如下:
來時鐘中斷-->儲存現場-->標記資訊-->do_bottomhalf--->應該重新排程嗎?
Yes-->排程
No -->從中斷返回
4、linux每10ms中斷一次,它在哪裡做了schedule()
linux每10ms中斷一次,它在哪裡做了schedule()。
每當一個系統或中斷完成時,將呼叫ret_from_sys_call(),其中有一句:
cmpl $0,__need_resched
jne reschedule
進行排程,時鐘中斷沒10ms一次返回時依據具體情況進行排程選擇。
5、編譯核心後的問題:xwindow-->console看不見!
我編譯了2.4.2,編譯過程中一切正常,但重新用新核心啟動後,可以進入console和xwindow,但是進入了xwindow後,我用Ctrl+Alt+Backspace想回到console,卻黑屏,無論進行什麼操作都不行。但是可以使用Ctrl+Alt+Del重新啟動,stop過程中也是什麼都看不到,但這個命令可以起作用。我用的是7.0,請各位大俠幫忙!謝謝!
極有可能是顯示切換與設定時出了問題,建議你:
#cp /etc/X11/XF86Config /etc/X11/XF86Config_save_00
#xf86config
重新一遍X系統,看行不行
6、kernel_thread
kernel_thread(int.....)
{
.
.
.
cmp %%sp,%%si
je 1f 這裡是不是永遠都會跳到1:???????
.
.
.
.
1:
kernel_thread呼叫clone系統呼叫建立一個新的程式(根據標誌決定是用同一個程式號或另一個程式號),clone實際完成和fork幾乎相同的工作,根據返回值為零和非零決定當前是新建立程式和父程式,父程式則跳轉到1,新程式則呼叫fn,對照fork應該可以理解,另外三個“:”後面涉及一些linux下彙編的mov語法,你最好熟悉一下。
7、請問如何得到linux下的命令程式碼
請問如何得到linux下的各種命令的程式碼,例如,adduser
系統中並沒有提供,你只有從網上自己找了
ping原始碼:
* PING.C
/*
/* ping source code distribute by cpu || digger.
/* for family only. compil and link success in unix.
/* i think linux no problem too. u can try it.
/* before read this code, you shoud know about the principle of
/* , especially icmp protocol, u also should also know some
/* about socket , and unix system signal programming.
/*
/* cc -o ping ping.c -lsocket, then u will get executable file,
/* but must act as when cc it, and then set euid attribute
/* for this ping, then u can execute it as common user.
/* because only root can have authority to creat raw socket.
/*
/* i love socket, if so do u,
/* call me, cpu == digger
# include
# include
# include
# include
# include
# include
# include
# include
# include
# include
# define ICMP_ECHO 8 /* icmp echo requir */
# define ICMP_ECHOREPLY 0 /* icmp echo reply */
# define ICMP_HEADSIZE 8 /* icmp packet header size */
# define IP_HEADSIZE 20 /* ip packet header size */
typedef struct tagIpHead /* icmp packet header */
{
u_char ip_verlen; /* ip version and ip header lenth*/
u_char ip_tos; /* ip type of service */
u_short ip_len; /* ip packet lenghth */
u_short ip_id; /* ip packet identification */
u_short ip_fragoff; /* ip packet fragment and offset */
u_char ip_ttl; /* ip packet time to live */
u_char ip_proto; /* ip packet protocol type */
u_short ip_chksum; /* ip packet header checksum */
u_long ip_src_addr; /* ip source ip adress */
u_long ip_dst_addr; /* ip destination ip adress */
} IPHEAD;
typedef struct tagIcmpHead /* icmp header */
{
u_char icmp_type; /* icmp service type */
/* 8 echo require, 0 echo reply */
u_char icmp_code; /* icmp header code */
u_short icmp_chksum; /* icmp header chksum */
u_short icmp_id; /* icmp packet identification */
u_short icmp_seq; /* icmp packet sequent */
u_char icmp_data[1]; /* icmp data, use as pointer */
} ICMPHEAD;
u_short ChkSum( u_short * pIcmpData, int iDataLen )
/* for check sum of icmp header */
{
u_short iSum;
u_short iOdyte;
iSum = 0;
while ( iDataLen > 1 ) { /* xor the next unsigned int data */
iSum ^= *pIcmpData++;
iDataLen -= 2;
}
if ( iDataLen == 1 ) { /* the rest odd byte */
iOddByte = 0;
*((u_char *)&iOddByte) = *(u_char *)pIcmpData;
iSum ^= iOddByte;
}
iSum ^= 0xffff; /* xor 0xffff == not it */
return(iSum);
}
long time_now() /* return time passed by */
/* since 1970.1.1 00:00:00, */
/* in 1/1000000 second */
{
struct timeval now;
long lPassed;
gettimeofday(&now, 0);
lPassed = now.tv_sec * 1000000 + now.tv_usec;
/* now.tv_sec in second */
/* now.tv_usec in 1/1000000 second */
return lPassed;
}
char* host; /* destination host */
char* prog; /* program name */
extern errno; /* system global parameter */
long lSendTime; /* each time when send, change it */
u_short seq; /* the icmp packet seqence */
int iTimeOut; /* time out parameter */
int sock, sent, recvd, max, min, total;
/* sent : icmp packet already sent */
/* recvd: proper icmp packet received */
/* max, min: max min round trip time */
/* total: total round trip time */
/* store to calculate average */
u_long lHostIp; /* host ip adress */
struct sockaddr_in it; /* destination host information */
int ping();
void stat();
main(int argc, char** argv)
{
struct hostent* h;
char buf[200];
char dst_host[32];
int i, namelen;
IPHEAD* pIpHead;
ICMPHEAD* pIcmpHead;
if (argc /* every timeout second */
/* default timeout is 1 second */
printf("usage: %s [-timeout] host|IP ", argv[0]);
exit(0);
}
prog = argv[0];
host = argc == 2 ? argv[1] : argv[2];
iTimeOut = argc == 2 ? 1 : atoi(argv[1]);
/* creat the raw socket for icmp */
if ((sock = socket(AF_, SOCK_RAW, IPPROTO_ICMP)) perror("socket");
exit(2);
}
/* set destination host information */
bzero(&it, sizeof(it));
it.sin_family = AF_INET;
/* check host format */
if ( ( lHostIp = inet_addr(host) ) != INADDR_NONE ) {
/* is available ip adress */
it.sin_addr.s_addr = lHostIp;
strcpy( dst_host, host );
} else if ( h = gethostbyname(host) ) {
/* is available host name */
/* from hosts file of local host */
/* or from */
bcopy(h->h_addr, &it.sin_addr, h->h_length);
sprintf( dst_host, "%s (%s)", host,
inet_ntoa(it.sin_addr) );
} else {
/* bad ip adress or host name */
/* exit */
fprintf( stderr, "bad IP or host " );
exit(3);
}
namelen = sizeof(it);
printf(" Digger pinging %s, send %d bytes ",
dst_host,
IP_HEADSIZE + ICMP_HEADSIZE + sizeof(long)
);
seq = 0; /* first icmp_seq = 0 */
sigset(SIGINT, stat); /* when press del or ctrl+c, call stat */
/* to statistic the result , and then exit */
sigset(SIGALRM, ping); /* hook ping function to timer */
alarm(iTimeOut); /* start timer, call ping every timeout */
/* seconds */
ping();
for ( ;; ) { /* waiting for every echo back */
/* icmp packet and check it */
register size;
register u_char ttl;
register delta;
register iIpHeadLen;
/* block to received echo back datagram */
size = recvfrom(sock, buf, sizeof(buf), 0,
(struct sockaddr *)&it, &namelen);
if (size == -1 && errno == EINTR) {
/* receive error or system call */
/* interrupted */
continue;
}
/* calculate the round trip time, */
/* time when receive minus time when send */
delta = (int)((time_now() - lSendTime)/1000);
/* get echo back packet and check its ip header */
pIpHead = (IPHEAD *)buf;
/* get the ip packet lenth */
/* if too small, not the icmp echoreply packet */
/* give it up */
iIpHeadLen = (int)((pIpHead->ip_verlen & 0x0f) <if (size continue;
}
ttl = pIpHead->ip_ttl; /* time to live param */
/* get the icmp header information */
pIcmpHead = (ICMPHEAD *)(buf + iIpHeadLen);
/* not icmp echo reply packet, give it up */
if (pIcmpHead->icmp_type != ICMP_ECHOREPLY) {
continue;
}
/* not proper icmp sequent number, give it up */
if (pIcmpHead->icmp_id != seq || pIcmpHead->icmp_seq != seq) {
continue;
}
/* print out result for each icmp */
/* echo reply information */
sprintf( buf, "icmp_seq=%u bytes=%d ttl=%d",
pIcmpHead->icmp_seq, size, ttl );
fprintf(stderr, "reply from %s: %s time=%d ms ",
host, buf, delta);
/* calculate some statistic information */
/* max, min, average round trip time */
/* received icmp echo reply packet numbers */
max = MAX(delta, max);
min = min ? MIN(delta, min) : delta;
total += delta;
++ recvd;
/* for next icmp sequence */
++ seq;
}
}
ping()
{
char buf[200];
int iPacketSize;
/* make the icmp header information */
ICMPHEAD *pIcmpHead = (ICMPHEAD *)buf;
pIcmpHead->icmp_type = ICMP_ECHO;
pIcmpHead->icmp_code = 0;
pIcmpHead->icmp_id = seq;
pIcmpHead->icmp_seq = seq;
pIcmpHead->icmp_chksum = 0;
/* store time information as icmp packet content, 4 bytes */
/* u may store other information instead */
*((long *)pIcmpHead->icmp_data) = time_now();
iPacketSize = ICMP_HEADSIZE + 4; /* icmp packet length */
/* icmp header check sum */
pIcmpHead->icmp_chksum = ChkSum((u_short *)pIcmpHead,
iPacketSize );
/* remember the time when send for calculate round trip time */
lSendTime = time_now();
/* send the icmp packet to des host */
if ( sendto(sock, buf, iPacketSize, 0, (struct sockaddr *)&it,
sizeof(it) ) perror("send failed");
exit(6);
}
/* packet number been sent */
++sent;
/* reset the timer hooker to me again */
alarm(iTimeOut);
}
void stat() /* print the statistic information for this time's ping */
{
if (sent) {
printf(" ----- %s ping statistics summerized by Digger----- "
, host );
printf("%d packets sent, %d packets received, %.2f%% lost ",
sent, recvd, (float)(sent-recvd)/(float)sent*100 );
}
if (recvd) {
printf("round_trip min/avg/max: %d/%d/%d ms ",
min, total/recvd, max );
}
exit(0);
}
'
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10752043/viewspace-989531/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Mysql 左右連線舉例說明MySql
- 反直覺SQL舉例說明SQL
- java中的單例模式,舉例說明。Java單例模式
- 說一下泛型原理,並舉例說明泛型
- PIGOSS售前使用說明(FAQ)Go
- 說說Vue 3.0中Treeshaking特性?舉例說明一下?Vue
- 什麼叫執行緒安全,舉例說明。執行緒
- 舉例說明在組合語言中,"[]"的用法組合語言
- 時間複雜度計算和舉例說明時間複雜度
- 舉例說明Oracle資料庫審計的用法Oracle資料庫
- 為什麼我們要學習DMAIC?—舉例說明AI
- 舉例說明什麼是IIFEs?它有什麼好處?
- MySQL的information_schema資料庫表說明及用法舉例MySqlORM資料庫
- 舉例說明陣列和物件的迭代方法分別有哪些?陣列物件
- CentOS 7升級核心簡明說明CentOS
- 五款智慧電視機型標準配置對比舉例說明
- 說說你對BEM規範的理解,同時舉例說明常見的CSS規範有哪些?CSS
- RHEL 7特性說明(四):核心
- 舉例說明你對尾遞迴的理解,有哪些應用場景遞迴
- 轉換說明
- oracle12c新特性列舉說明Oracle
- linux常用核心引數說明Linux
- 在Linux中,什麼是系統監控和效能分析工具?舉例說明。Linux
- 以例項說明 OAuth2OAuth
- php.ini 核心配置選項說明PHP
- linux核心裁剪選項說明Linux
- pureftpd安裝配置簡明說明 (轉)FTP
- (轉)Oracle Logminer 說明Oracle
- WINDOWS訊息說明 (轉)Windows
- 這是一篇比較詳盡的核心編譯說明(轉)編譯
- Linux核心調優部分引數說明Linux
- 轉載:__builtin_expect 說明UI
- (轉)oracle dump block格式說明OracleBloC
- Emacs 的 info 使用說明(轉)Mac
- Emacs簡易操作說明(轉)Mac
- Emacs詳細使用說明(轉)Mac
- latch free 等待事件說明(轉)事件
- 【轉載】ArcGIS中topolopy說明