minix/lib/libsys/vm_yield_get_block.c
Ben Gras f78d8e74fd secondary cache feature in vm.
A new call to vm lets processes yield a part of their memory to vm,
together with an id, getting newly allocated memory in return. vm is
allowed to forget about it if it runs out of memory. processes can ask
for it back using the same id. (These two operations are normally
combined in a single call.)

It can be used as a as-big-as-memory-will-allow block cache for
filesystems, which is how mfs now uses it.
2010-05-05 11:35:04 +00:00

48 lines
1.3 KiB
C

#include "syslib.h"
#include <minix/vm.h>
#include <minix/u64.h>
/*===========================================================================*
* vm_forgetblocks *
*===========================================================================*/
PUBLIC void vm_forgetblocks(void)
{
message m;
_taskcall(VM_PROC_NR, VM_FORGETBLOCKS, &m);
return;
}
/*===========================================================================*
* vm_forgetblock *
*===========================================================================*/
PUBLIC int vm_forgetblock(u64_t id)
{
message m;
m.VMFB_IDHI = ex64hi(id);
m.VMFB_IDLO = ex64lo(id);
return _taskcall(VM_PROC_NR, VM_FORGETBLOCK, &m);
}
/*===========================================================================*
* vm_yield_block_get_block *
*===========================================================================*/
PUBLIC int vm_yield_block_get_block(u64_t yieldid, u64_t getid,
void *mem, vir_bytes len)
{
message m;
m.VMYBGB_VADDR = mem;
m.VMYBGB_GETIDHI = ex64hi(getid);
m.VMYBGB_GETIDLO = ex64lo(getid);
m.VMYBGB_LEN = len;
m.VMYBGB_YIELDIDHI = ex64hi(yieldid);
m.VMYBGB_YIELDIDLO = ex64lo(yieldid);
return _taskcall(VM_PROC_NR, VM_YIELDBLOCKGETBLOCK, &m);
}