generated from CSED421-DBS/EduBfM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathedubfm_AllocTrain.c
86 lines (75 loc) · 3.65 KB
/
edubfm_AllocTrain.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/******************************************************************************/
/* */
/* ODYSSEUS/EduCOSMOS Educational-Purpose Object Storage System */
/* */
/* Developed by Professor Kyu-Young Whang et al. */
/* */
/* Database and Multimedia Laboratory */
/* */
/* Computer Science Department and */
/* Advanced Information Technology Research Center (AITrc) */
/* Korea Advanced Institute of Science and Technology (KAIST) */
/* */
/* e-mail: kywhang@cs.kaist.ac.kr */
/* phone: +82-42-350-7722 */
/* fax: +82-42-350-8380 */
/* */
/* Copyright (c) 1995-2013 by Kyu-Young Whang */
/* */
/* All rights reserved. No part of this software may be reproduced, */
/* stored in a retrieval system, or transmitted, in any form or by any */
/* means, electronic, mechanical, photocopying, recording, or otherwise, */
/* without prior written permission of the copyright owner. */
/* */
/******************************************************************************/
/*
* Module: edubfm_AllocTrain.c
*
* Description :
* Allocate a new buffer from the buffer pool.
*
* Exports:
* Four edubfm_AllocTrain(Four)
*/
#include <errno.h>
#include "EduBfM_common.h"
#include "EduBfM_Internal.h"
extern CfgParams_T sm_cfgParams;
/*@================================
* edubfm_AllocTrain()
*================================*/
/*
* Function: Four edubfm_AllocTrain(Four)
*
* Description :
* (Following description is for original ODYSSEUS/COSMOS BfM.
* For ODYSSEUS/EduCOSMOS EduBfM, refer to the EduBfM project manual.)
*
* Allocate a new buffer from the buffer pool.
* The used buffer pool is specified by the parameter 'type'.
* This routine uses the second chance buffer replacement algorithm
* to select a victim. That is, if the reference bit of current checking
* entry (indicated by BI_NEXTVICTIM(type), macro for
* bufInfo[type].nextVictim) is set, then simply clear
* the bit for the second chance and proceed to the next entry, otherwise
* the current buffer indicated by BI_NEXTVICTIM(type) is selected to be
* returned.
* Before return the buffer, if the dirty bit of the victim is set, it
* must be force out to the disk.
*
* Returns;
* 1) An index of a new buffer from the buffer pool
* 2) Error codes: Negative value means error code.
* eNOUNFIXEDBUF_BFM - There is no unfixed buffer.
* some errors caused by fuction calls
*/
Four edubfm_AllocTrain(
Four type) /* IN type of buffer (PAGE or TRAIN) */
{
Four e; /* for error */
Four victim; /* return value */
Four i;
/* Error check whether using not supported functionality by EduBfM */
if(sm_cfgParams.useBulkFlush) ERR(eNOTSUPPORTED_EDUBFM);
return( victim );
} /* edubfm_AllocTrain */