signed long ioman_findUnusedSpot(IOManager *ioman) { signed long r=-1; unsigned short c; unsigned char fr=0,lr=0xFF; for(c=0;c<ioman->numbuf;c++){ if(ioman_getUseCnt(ioman,c)==0){ if(!ioman_isWritable(c) && !fr){ fr=1; lr=0xFF; r=-1; } if(ioman_isWritable(c) && !fr){ if(ioman_getRefCnt(ioman,c)<=lr){ r=c; lr=ioman_getRefCnt(ioman,c); } } if(fr && !ioman_isWritable(c)){ if(ioman_getRefCnt(ioman,c)<=lr){ r=c; lr=ioman_getRefCnt(ioman,c); } } } } return(r); }
esint32 ioman_findUnusedSpot(IOManager *ioman) { esint32 r=-1; euint16 c; euint8 fr=0,lr=0xFF; for(c=0;c<ioman->numbuf;c++){ if(ioman_getUseCnt(ioman,c)==0){ if(!ioman_isWritable(c) && !fr){ fr=1; lr=0xFF; r=-1; } if(ioman_isWritable(c) && !fr){ if(ioman_getRefCnt(ioman,c)<=lr){ r=c; lr=ioman_getRefCnt(ioman,c); } } if(fr && !ioman_isWritable(c)){ if(ioman_getRefCnt(ioman,c)<=lr){ r=c; lr=ioman_getRefCnt(ioman,c); } } } } return(r); }
void ioman_printStatus(IOManager *ioman) { unsigned short c; DBG((TXT("IO-Manager -- Report\n====================\n"))); DBG((TXT("Buffer is %i sectors, from %p to %p\n"), ioman->numbuf,ioman->bufptr,ioman->bufptr+(ioman->numbuf*512))); for(c=0;c<ioman->numbuf;c++){ if(ioman_isValid(c)){ DBG((TXT("BP %3i\t SC %8li\t\t US %i\t RF %i\t %s %s\n"), c,ioman->sector[c],ioman_getUseCnt(ioman,c),ioman_getRefCnt(ioman,c), ioman_isUserBuf(c) ? "USRBUF" : " ", ioman_isWritable(c) ? "WRITABLE" : "READONLY")); } } }
signed long ioman_findOverallocableSpot(IOManager *ioman) { unsigned char points,lp=0xFF; unsigned short c; signed long r=-1; for(c=0;c<ioman->numbuf;c++){ if(ioman->itptr[c]<ioman->numit){ points = 0; if(ioman_isWritable(c))points+=0x7F; points += ((unsigned short)(ioman->itptr[c]*0x4D))/(ioman->numit); points += ((unsigned short)(ioman_getRefCnt(ioman,c)*0x33))/0xFF; if(points<lp){ lp=points; r=c; } } } return(r); }
esint32 ioman_findOverallocableSpot(IOManager *ioman) { euint8 points,lp=0xFF; euint16 c; esint32 r=-1; for(c=0;c<ioman->numbuf;c++){ if(ioman->itptr[c]<ioman->numit){ points = 0; if(ioman_isWritable(c))points+=0x7F; points += ((euint16)(ioman->itptr[c]*0x4D))/(ioman->numit); points += ((euint16)(ioman_getRefCnt(ioman,c)*0x33))/0xFF; if(points<lp){ lp=points; r=c; } } } return(r); }