Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

linux 0.11 ÄÚºËѧϰ buffer.c


/*
 * buffer.c ³ÌÐòÓÃÓÚ¶Ô¸ßËÙ»º³åÇø(³Ø)½øÐвÙ×÷ºÍ¹ÜÀí¡£¸ßËÙ»º³å
 * ÇøλÓÚÄں˴úÂëºÍÖ÷ÄÚ´æÇøÖ®¼ä¡£
 *
 *  |---|---|------------------|---------------------|-------------------|
 *  |   |   |    *   *    *    |       buffer        |                   |
 *  |---|---|------------------|---------------------|-------------------|
 *    |                                   /|\
 *    |------------------------------------|
 *   \|/
 *  buffer_head (list)
 */
/*
 *  linux/fs/buffer.c
 *
 *  (C) 1991  Linus Torvalds
 */
/*
 *  'buffer.c' implements the buffer-cache functions. Race-conditions have
 * been avoided by NEVER letting a interrupt change a buffer (except for the
 * data, of course), but instead letting the caller do it. NOTE! As interrupts
 * can wake up a caller, some cli-sti sequences are needed to check for
 * sleep-on-calls. These should be extremely quick, though (I hope).
 */
/*
 * NOTE! There is one discordant note here: checking floppies for
 * disk change. This is where it fits best, I think, as it should
 * invalidate changed floppy-disk-caches.
 */
#include <stdarg.h>
#include <linux/config.h>
#include <linux/sched.h>
#include <linux/kernel.h>
#include <asm/system.h>
#include <asm/io.h>
extern int end; // ÓÉÁ¬½Ó³ÌÐòld Éú³ÉµÄ±íÃ÷³ÌÐòÄ©¶ËµÄ±äÁ¿£¬´ú±íµÄÊÇÒ»¸öÄÚ´æµØÖ·
struct buffer_head * start_buffer = (struct buffer_head *) &end;
struct buffer_head * hash_table[NR_HASH];
static struct buffer_head * free_list;
static struct task_struct * buffer_wait = NULL;
int NR_BUFFERS = 0;
/*µÈ´ýÖ¸¶


Ïà¹ØÎĵµ£º

ǶÈëʽLinux²Ù×÷ϵͳѧϰ¹æ

ǶÈëʽLinux²Ù×÷ϵͳѧϰ¹æ»®
ARM+LINUX·Ïߣ¬Ö÷¹¥Ç¶ÈëʽLinux²Ù×÷ϵͳ¼°ÆäÉÏÓ¦ÓÃÈí¼þ¿ª·¢Ä¿±ê£º 
£¨1£© ÕÆÎÕÖ÷Á÷ǶÈëʽ΢´¦ÀíÆ÷µÄ½á¹¹ÓëÔ­Àí£¨³õ²½¶¨Îªarm9£© 
£¨2£© ±ØÐëÕÆÎÕÒ»¸öǶÈëʽ²Ù×÷ϵͳ £¨³õ²½¶¨Îªuclinux»òlinux,°æ±¾´ý¶¨£© 
£¨3£© ±ØÐëÊìϤǶÈëʽÈí¼þ¿ª·¢Á÷³Ì²¢ÖÁÉÙ×öÒ ......

linuxÏß³Ìͬ²½Ö®Ìõ¼þ±äÁ¿

    Ìõ¼þ±äÁ¿Í¨¹ýÔÊÐíÏß³Ì×èÈûºÍµÈ´ýÁíÒ»¸öÏ̷߳¢ËÍÐźŵķ½·¨ÃÖ²¹ÁË»¥³âËøµÄ²»×㣬Ëü³£ºÍ»¥³âËøÒ»ÆðʹÓá£Ê¹ÓÃʱ£¬Ìõ¼þ±äÁ¿±»ÓÃÀ´×èÈûÒ»¸öỊ̈߳¬µ±Ìõ¼þ²»Âú×ãʱ£¬Ïß³ÌÍùÍù½â¿ªÏàÓ¦µÄ»¥³âËø²¢µÈ´ýÌõ¼þ·¢Éú±ä»¯¡£Ò»µ©ÆäËüµÄij¸öÏ̸߳ıäÁËÌõ¼þ±äÁ¿£¬Ëü½«Í¨ÖªÏàÓ¦µÄÌõ¼þ±äÁ¿»½ÐÑÒ»¸ö»ò¶à¸öÕý±»´ËÌõ¼þ±äÁ¿×èÈûµ ......

Linuxϳ£ÓÃCÓïÑÔ×Ö·û´®²Ù×÷º¯Êý

stroul£¬
strdup
snprintf()
atio
 
CÖг£ÓÃ×Ö·û´®²Ù×÷º¯Êý
#include <string.h>
 
size_t strlen(const char *s)   ²âÁ¿×Ö·û´®³¤¶ÈsµÄʵ¼Ê³¤¶È¡£
ÀýÈçs[20]="abc",ÄÇôstrlen(s)µÄ½á¹ûÊÇ3£¬¶ø²»ÊÇ20.Õâ¾ÍÊÇʵ¼Ê³¤¶È
 
char *strcat(const char *s1, const *s2)  ......

LinuxÉÏautofsÅäÖü°Æä˵Ã÷....

             °æȨÉùÃ÷£ºÔ­´´×÷Æ·£¬ÔÊÐíתÔØ£¬×ªÔØʱÇëÎñ±ØÒÔ³¬Á´½ÓÐÎʽ±êÃ÷ÎÄÕ ԭʼ³ö´¦ ¡¢×÷ÕßÐÅÏ¢ºÍ±¾ÉùÃ÷¡£·ñÔò½«×·¾¿·¨ÂÉÔðÈΡ£http://blog.csdn.net/Neverland2012  
         ÎÒÃǾ­³£»áÈ¥ÏÂÔرð ......

Linux´óʦ£¨¹Å³£¬Guru£©ÍƼöʲô£¿






<!--
@page { margin: 2cm }
P { margin-bottom: 0.21cm }
-->
       ÔÚÏÖʵÉú»îÖб»ÈËÃdzÆΪ´óʦ¼¶µÄÈËÎïȷʵºÜÉÙ¼û¡£
Brian
Proffitt
ÏÈÉú¾ÍÊÇһλȫÇòÖªÃû¡¢ÊÜÈË×ð¾´µÄ
Linux
´óʦ¡£´ËÑÔÓкθù¾Ý£¿½üÈÕ£¬ËûÏòÎÒÃÇÍƼöÁËʲô£¿
 
   ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ