struct buf
*bufps
[NBLOCKS
];
char *nbase
[NBLOCKS
]; /* normal allocations */
short nmap
[NBLOCKS
]; /* 1 bit == 32 bytes */
char log
[] ={0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4};
* getepack: get empty packet
* with size specified by bitmask.
base
= nbase
; map
= nmap
;
for(i
=0; i
<NBLOCKS
; i
++) {
if (m
==FULL
|| base
[i
]==NULL
)
for (offset
=0; n
> 16; n
>>= 4)
for(n
=17; --n
; bits
<<= 1)
return(base
[i
] + 32*offset
);
* grab another block from the system
bufps
[i
] = bp
= geteblk();
base
[i
] = bp
->b_un
.b_addr
;
* sleep until something is released
sleep((caddr_t
)&bwaiting
, XPRI
);
* freepack: release space beginning
* at address p with length specified
base
= nbase
; map
= nmap
;
wakeup((caddr_t
)&bwaiting
);
* integer to bitmap conversion