⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ufs_machdep.c

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻 C
字号:
#ifndef lintstatic	char	*sccsid = "@(#)ufs_machdep.c	4.1	(ULTRIX)	7/2/90";#endif/************************************************************************ *									* *			Copyright (c) 1985, 1986 by			* *		Digital Equipment Corporation, Maynard, MA		* *			All rights reserved.				* *									* *   This software is furnished under a license and may be used and	* *   copied  only  in accordance with the terms of such license and	* *   with the  inclusion  of  the  above  copyright  notice.   This	* *   software  or  any  other copies thereof may not be provided or	* *   otherwise made available to any other person.  No title to and	* *   ownership of the software is hereby transferred.			* *									* *   This software is  derived  from  software  received  from  the	* *   University    of   California,   Berkeley,   and   from   Bell	* *   Laboratories.  Use, duplication, or disclosure is  subject  to	* *   restrictions  under  license  agreements  with  University  of	* *   California and with AT&T.						* *									* *   The information in this software is subject to change  without	* *   notice  and should not be construed as a commitment by Digital	* *   Equipment Corporation.						* *									* *   Digital assumes no responsibility for the use  or  reliability	* *   of its software on equipment which is not supplied by Digital.	* *									* ************************************************************************//************************************************************************ * *			Modification History * *	Koehler 11 Sept 86 -- moved size into register * *	Stephen Reilly, 06-Sept-85 * 001- Added a check to make sure that we don't allocate more than *	MAXBSIZE. * *	ufs_machdep.c	6.1	83/07/29 ***********************************************************************/#include "../machine/pte.h"#include "../h/param.h"#include "../h/systm.h"#include "../h/dir.h"#include "../h/user.h"#include "../h/buf.h"#include "../h/conf.h"#include "../h/proc.h"#include "../h/seg.h"#include "../h/vm.h"/* * Machine dependent handling of the buffer cache. *//* * Expand or contract the actual memory allocated to a buffer. * If no memory is available, release buffer and take error exit */allocbuf(tp, size)	register struct buf *tp;	register int size;{	register struct buf *bp, *ep;	int sizealloc, take;	sizealloc = roundup(size, CLBYTES);	/*	 *		001	 * Make sure that we don't allocate more than MAXBSIZE	 */	if (sizealloc > MAXBSIZE)		panic( "allocbuf: allocating space greater than MAXBSIZE ");	/*	 * Buffer size does not change	 */	if (sizealloc == tp->b_bufsize)		goto out;	/*	 * Buffer size is shrinking.	 * Place excess space in a buffer header taken from the	 * BQ_EMPTY buffer list and placed on the "most free" list.	 * If no extra buffer headers are available, leave the	 * extra space in the present buffer.	 */	if (sizealloc < tp->b_bufsize) {		ep = bfreelist[BQ_EMPTY].av_forw;		if (ep == &bfreelist[BQ_EMPTY])			goto out;		notavail(ep);		pagemove(tp->b_un.b_addr + sizealloc, ep->b_un.b_addr,		    (int)tp->b_bufsize - sizealloc);		ep->b_bufsize = tp->b_bufsize - sizealloc;		tp->b_bufsize = sizealloc;		ep->b_flags |= B_INVAL;		ep->b_bcount = 0;		brelse(ep);		goto out;	}	/*	 * More buffer space is needed. Get it out of buffers on	 * the "most free" list, placing the empty headers on the	 * BQ_EMPTY buffer header list.	 */	while (tp->b_bufsize < sizealloc) {		take = sizealloc - tp->b_bufsize;		bp = getnewbuf();		if (take >= bp->b_bufsize)			take = bp->b_bufsize;		pagemove(&bp->b_un.b_addr[bp->b_bufsize - take],		    &tp->b_un.b_addr[tp->b_bufsize], take);		tp->b_bufsize += take;		bp->b_bufsize = bp->b_bufsize - take;		if (bp->b_bcount > bp->b_bufsize)			bp->b_bcount = bp->b_bufsize;		if (bp->b_bufsize <= 0) {			bremhash(bp);			binshash(bp, &bfreelist[BQ_EMPTY]);			bp->b_dev = (dev_t)NODEV;			bp->b_error = 0;			bp->b_flags |= B_INVAL;		}		brelse(bp);	}out:	tp->b_bcount = size;	return (1);}/* * Release space associated with a buffer. */bfree(bp)	struct buf *bp;{	bp->b_bcount = 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -