📄 memory.c
字号:
#include"../include/os.h"
static int hash_function(int file_window,int logic_block)
{
int i,j;
i=(*(memory_body->file_number));
i=i*file_window;
i=i+logic_block;
j=(*(memory_body->hash_number));
return (i%j);
}
void init_memory(void )
{
int block_number,block_base;
REG r;
union memory_call_parameter *par;
par=get_memory_parameter();
r.ax=20; r.bx=0; call_kernel(&r);
block_number=r.ax; block_base=r.bx;
print("\n free memory block is ",block_number);
print("os used ",(block_base&(0x0fffffff))/PAGE_SIZE);
RESET_CAPABILITY(par->setup.capability);
RESET_CAPABILITY(par->setup.memory_body_parameter.capability);
par->setup.memory_body_parameter.base=(char *)block_base;
par->setup.memory_body_parameter.hash_function=hash_function;
par->setup.memory_body_parameter.my_processor=0;
par->setup.memory_body_parameter.my_memory_body=0;
par->setup.memory_body_parameter.block_number=block_number;
par->setup.memory_body_parameter.file_number=48;
par->setup.memory_body_parameter.process_number=16;
par->setup.memory_body_parameter.hash_number
=par->setup.memory_body_parameter.block_number;
RESET_CAPABILITY(par->setup.capability);
RESET_CAPABILITY(par->setup.memory_body_parameter.capability);
r.ax=0;r.bx=8;
call_memory(&r);
print("\n need manage area : is ",r.ax);
r.ax=((r.ax+PAGE_SIZE)/PAGE_SIZE);
block_number=block_number-r.ax;
par->setup.memory_body_parameter.block_number=block_number;
par->setup.memory_body_parameter.first_block=r.ax;
print("\n first block at ",r.ax);
RESET_CAPABILITY(par->setup.capability);
RESET_CAPABILITY(par->setup.memory_body_parameter.capability);
r.ax=0;r.bx=9;call_memory(&r);
print("\n actural management area size is:",r.ax);
print("\n actural memory pages is :",
par->setup.memory_body_parameter.block_number);
par->memory_resource.process_number=0;
RESET_CAPABILITY(par->memory_resource.capability);
r.ax=0;r.bx=0x06;call_memory(&r);
print("\n query memory process' memory resource:",r.ax);
par->memory_resource.process_number=0;
par->memory_resource.max_file_number=48;
par->memory_resource.max_block_number=block_number-500;
par->memory_resource.trigger_block_number=block_number-5000;
RESET_CAPABILITY(par->memory_resource.capability);
r.ax=0; r.bx=0x07; call_memory(&r);
print("\n allocate memory process' memory resource:",r.ax);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -