130 lines
4.3 KiB
C
130 lines
4.3 KiB
C
/****************************************************************************
|
|
|
|
|
| (C) Copyright 1995-1997 Novell, Inc.
|
|
| All Rights Reserved.
|
|
|
|
|
| This program is free software; you can redistribute it and/or
|
|
| modify it under the terms of version 2 of the GNU General Public
|
|
| License as published by the Free Software Foundation.
|
|
|
|
|
| This program is distributed in the hope that it will be useful,
|
|
| but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
| GNU General Public License for more details.
|
|
|
|
|
| You should have received a copy of the GNU General Public License
|
|
| along with this program; if not, contact Novell, Inc.
|
|
|
|
|
| To contact Novell about this file by physical or electronic mail,
|
|
| you may find current contact information at www.novell.com
|
|
|
|
|
|***************************************************************************
|
|
|
|
|
| NetWare Advance File Services (NSS) Initialization module
|
|
|
|
|
|---------------------------------------------------------------------------
|
|
|
|
|
| $Author: taysom $
|
|
| $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $
|
|
|
|
|
| $RCSfile$
|
|
| $Revision: 465 $
|
|
|
|
|
|---------------------------------------------------------------------------
|
|
| This module is used to:
|
|
| Defines constants and macros used by resource reservation.
|
|
| Resource reservation keeps us from over commiting system
|
|
| resources. It prevents deadlock of a set of requests each
|
|
| waiting for sombody to release a resource so they can continue.
|
|
| Since all resources are dirived from cache block, a request just
|
|
| has to reserve an adequate number of cache blocks.
|
|
|
|
|
| WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING!
|
|
|
|
|
| This header file should ONLY be used for NSS internal development.
|
|
| This includes Semantic Agents (SA) and Loadable Storage Services (LSS).
|
|
| Any other use may cause conflicts which NSS will NOT fix.
|
|
+-------------------------------------------------------------------------*/
|
|
|
|
#ifndef _RESERVERESOURCES_H_
|
|
#define _RESERVERESOURCES_H_
|
|
|
|
#ifndef _LATCH_H_
|
|
#include <include/latch.h>
|
|
#endif
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/*
|
|
* ASSERTIONS: Important things to keep in mind when using resource
|
|
* reservation.
|
|
*
|
|
* 1. Do not nest calls to resource reservation. If one layer of code
|
|
* reserves resources, the next or lower layers of the system
|
|
* should not reserve resources because you could end up blocking
|
|
* on yourself.
|
|
*
|
|
* 2. Reservations can be released even though you still have buffers
|
|
* locked. You can't reserve more resources until the buffers
|
|
* you have latched have been released.
|
|
*
|
|
* 3. Release the all the resources at once. If you reserve 10 then release
|
|
* 10. Don't release 4 then 6. This will help the latch debug code keep
|
|
* in sync.
|
|
*
|
|
* 4. Reads that do not hold onto buffers do not need to reserve resources
|
|
* because read only uses one buffer at a time which will not lead
|
|
* to resource deadlock.
|
|
*/
|
|
|
|
extern Latch_s ReserveResource; /* Used to pre-alloc or reserve
|
|
* cache buffers
|
|
*/
|
|
|
|
#if 0
|
|
#define RESERVE_RSRC(_num) GRAB( &ReserveResource, (_num))
|
|
#define RELEASE_RSRC(_num) DROP( &ReserveResource, (_num))
|
|
#define FSM_RESERVE_RSRC(_num, _fsm, _action) \
|
|
FSM_GRAB( &ReserveResource, (_num), (_fsm), (_action))
|
|
#else
|
|
#define RESERVE_RSRC(_num) ((void) 0)
|
|
#define RELEASE_RSRC(_num) ((void) 0)
|
|
#define FSM_RESERVE_RSRC(_num, _fsm, _action) ((void) 0)
|
|
#endif
|
|
|
|
#define INC_RSRC(_num) INC_COUNT( &ReserveResource, (_num))
|
|
#define INC_RSRC_CHECK(_num) INC_COUNT_CHECK( &ReserveResource, (_num))
|
|
#define DEC_RSRC(_num) DEC_COUNT( &ReserveResource, (_num))
|
|
#define HAVE_RESOURCES(_n) (ReserveResource.count > (_n))
|
|
#define NUM_RESOURCES() (ReserveResource.count)
|
|
|
|
#define NAME_RESERVE 16 /* Number of blocks we should reserve for naming
|
|
* related APIs
|
|
*/
|
|
/*
|
|
* The read NCP can collect several buffers before releasing them.
|
|
* The number of buffers used depends on the release of NetWare
|
|
* being used.
|
|
*/
|
|
#if defined _NWMOAB_
|
|
# define READ_RESERVE 32
|
|
#elif defined _NWGREENRIVER_
|
|
# define READ_RESERVE 6
|
|
#else
|
|
# define READ_RESERVE 32
|
|
#endif
|
|
|
|
#define WRITE_RESERVE 4 /* Number of buffers to reserve for simple
|
|
* write operations.
|
|
*/
|
|
|
|
#define TASK_RESERVE 2 /* Worst case for beginning task */
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|