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;
/*µÈ´ýÖ¸¶
Ïà¹ØÎĵµ£º
±¾ÎIJ¢·Ç½âÊÍʲôÊÇ·Ç×èÈûsocket£¬Ò²²»ÊǽéÉÜsocket APIµÄÓ÷¨£¬ È¡¶ø´úÌæµÄÊÇÈÃÄã¸ÐÊÜʵ¼Ê¹¤×÷ÖеĴúÂë±àд¡£ËäÈ»ºÜ¼òª£¬µ«Äã¿ÉÒÔͨ¹ýmanÊÖ²áÓëÆäËü×ÊÔ´·Ç¸»ÄãµÄ´úÂë¡£Çë×¢Òâ±¾½Ì³ÌËù˵µÄÖ÷Ì⣬Èç¹ûϸ˵£¬ÄÚÈÝ¿ÉÒÔ´ïµ½Ò»±¾ÊéÄÚÈÝ£¬Äã»á·¢ÏÖ±¾½Ì³ÌºÜÓÐÓá£
±¾½Ì³ÌÄÚÈÝÈçÏ£º
......
#define EPERM 1 /* Operation not permitted */
#define ENOENT 2 /* No such file or directory */
#define ESRCH&nbs ......
Ò»¸ö³ÌÐòµÄ¿ª·¢Àë²»¿ªÐí¶à¿âº¯ÊýµÄÖ§³Ö£¬¿ÉÊÇ¿âÈç´ËÖ®¶à£¬ÓпªÔ´Ãâ·ÑµÄÒ²ÓÐÊշѵġ£ºÜÏ£ÍûÊìϤ±à³ÌµÄǰ±²°Ñ×Ô¼ºµÄ¾ÑéÕûÀíÏ£¬³£ÓõĿⶼ°üº¬ÄÄЩ¹¦ÄÜ¡£ÏÂÎÄÊÇÔÚÍøÉÏÕÒµÄÒ»¸öÀàËÆµÄ×ÊÁÏ¡£ÆÚ´ý¸ü¶à¸üÈ«µÄÄÚÈÝ¡£
---------------------------------------------------------------------------------------------------
¿´µ ......
×ªÔØÊ±Çë×¢Ã÷³ö´¦ºÍ×÷ÕßÁªÏµ·½Ê½
ÎÄÕ³ö´¦£ºhttp://www.limodev.cn/blog
×÷ÕßÁªÏµ·½Ê½£ºÀîÏȾ² <xianjimli at hotmail dot com>
Ëæ×ÅXPµÄÁ÷ÐУ¬ÈËÃÇÔ½À´Ô½×¢ÖØÈí¼þµÄǰÆÚÉè¼Æ¡¢ºóÆÚµÄʵÏÖ£¬ÒÔ¼°¹á´©ÓÚÆäÖеIJâÊÔ¹¤×÷£¬¾¹ýÕâ¸ö¹ý³Ì³öÀ´µÄ×ÔÈ»ÊǸßÖÊÁ¿µÄÈí¼þ¡£ÉõÖÁÓÐÈËÉù³ÆXP»áÌÔ̵÷ÊÔÆ÷£¡Õ⵱ȻÊÇÓÐÒ»¶¨µÀÀíµÄ£¬È ......
/*
* linux/fs/char_dev.c
*
* (C) 1991 Linus Torvalds
*/
#include <errno.h>
#include <sys/types.h> // ¶¨ÒåÁË»ù±¾µÄϵͳÊý¾ÝÀàÐÍ
#include <linux/sched.h>
#include <linux/kernel.h> // º¬ÓÐһЩÄں˳£Óú¯ÊýµÄÔÐζ¨Òå
#include < ......