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²Ù×÷ϵͳѧϰ¹æ»®
ARM+LINUX·Ïߣ¬Ö÷¹¥Ç¶ÈëʽLinux²Ù×÷ϵͳ¼°ÆäÉÏÓ¦ÓÃÈí¼þ¿ª·¢Ä¿±ê£º
£¨1£© ÕÆÎÕÖ÷Á÷ǶÈëʽ΢´¦ÀíÆ÷µÄ½á¹¹ÓëÔÀí£¨³õ²½¶¨Îªarm9£©
£¨2£© ±ØÐëÕÆÎÕÒ»¸öǶÈëʽ²Ù×÷ϵͳ £¨³õ²½¶¨Îªuclinux»òlinux,°æ±¾´ý¶¨£©
£¨3£© ±ØÐëÊìϤǶÈëʽÈí¼þ¿ª·¢Á÷³Ì²¢ÖÁÉÙ×öÒ ......
Ìõ¼þ±äÁ¿Í¨¹ýÔÊÐíÏß³Ì×èÈûºÍµÈ´ýÁíÒ»¸öÏ̷߳¢ËÍÐźŵķ½·¨ÃÖ²¹ÁË»¥³âËøµÄ²»×㣬Ëü³£ºÍ»¥³âËøÒ»ÆðʹÓá£Ê¹ÓÃʱ£¬Ìõ¼þ±äÁ¿±»ÓÃÀ´×èÈûÒ»¸öỊ̈߳¬µ±Ìõ¼þ²»Âú×ãʱ£¬Ïß³ÌÍùÍù½â¿ªÏàÓ¦µÄ»¥³âËø²¢µÈ´ýÌõ¼þ·¢Éú±ä»¯¡£Ò»µ©ÆäËüµÄij¸öÏ̸߳ıäÁËÌõ¼þ±äÁ¿£¬Ëü½«Í¨ÖªÏàÓ¦µÄÌõ¼þ±äÁ¿»½ÐÑÒ»¸ö»ò¶à¸öÕý±»´ËÌõ¼þ±äÁ¿×èÈûµ ......
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) ......
°æȨÉùÃ÷£ºÔ´´×÷Æ·£¬ÔÊÐíתÔØ£¬×ªÔØʱÇëÎñ±ØÒÔ³¬Á´½ÓÐÎʽ±êÃ÷ÎÄÕ Ôʼ³ö´¦ ¡¢×÷ÕßÐÅÏ¢ºÍ±¾ÉùÃ÷¡£·ñÔò½«×·¾¿·¨ÂÉÔðÈΡ£http://blog.csdn.net/Neverland2012
ÎÒÃǾ³£»áÈ¥ÏÂÔرð ......
<!--
@page { margin: 2cm }
P { margin-bottom: 0.21cm }
-->
ÔÚÏÖʵÉú»îÖб»ÈËÃdzÆΪ´óʦ¼¶µÄÈËÎïȷʵºÜÉÙ¼û¡£
Brian
Proffitt
ÏÈÉú¾ÍÊÇһλȫÇòÖªÃû¡¢ÊÜÈË×ð¾´µÄ
Linux
´óʦ¡£´ËÑÔÓкθù¾Ý£¿½üÈÕ£¬ËûÏòÎÒÃÇÍƼöÁËʲô£¿
......