⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 arch3.c

📁 虚拟地址空间基于文件的操作系统
💻 C
字号:
#include"memory.h"
#include"../include/os.h"
#define FILE_SYSTEM_ERROR	(-1)

void mount_page_table(int file_id,int map_length)
{
	int i,block_number;
	block_number=(map_length+PAGE_SIZE)/(PAGE_SIZE*1024);
	for(i=0;i<block_number;i++){
		file_page_table[file_id].number=i;
		file_page_table[file_id].page_table_block[i]=(-1);
		file_page_table[file_id].item_number[i]=0;
		file_page_table[file_id].reference_number[i]=0;
	}
	return;
}
void unmount_page_table(int memory_process_id,int file_id)
{
	int i,j;
	for(i=0;i<=file_page_table[file_id].number;i++){
		j=file_page_table[file_id].page_table_block[i];
		if(j>=0)
			free_free_block(memory_process_id,j);
		file_page_table[file_id].page_table_block[i]=(-1);
		file_page_table[file_id].item_number[i]=0;
		file_page_table[file_id].reference_number[i]=0;
	}
	file_page_table[file_id].number=0;
	return;	
}

int memory_set_file_capability(int file_window,int right,
	struct capability *file_capability)
{
	int return_value,eflag;
	eflag=disable_interruption();
	return_value=set_system_file_capability(
		memory_body->my_memory_body,
		file_window,right,file_capability);
	restore_interruption(eflag);
	return return_value;
}

int migrate_to_file_system(int processor_process,
	struct thread_physical_block *pb)
{
	struct thread_environment r;
	union system_call_parameter *par;
	struct capability c;

	par=get_kernel_parameter();

	COPY_CAPABILITY((par->capability.capability_1),c);
	COPY_CAPABILITY((os->system_capability),
		(par->capability.capability_1));

	r.system_call=2;
	r.system_call_arg1=processor_process;
	r.system_call_arg2=pb->stack_memory_id;
	r.system_call_arg3=pb->stack_block_id;
	r.system_call_arg4=pb->memory_id;
	r.system_call_arg5=pb->block_id;
	call_kernel(&r);

	COPY_CAPABILITY(c,(par->capability.capability_1));

	if((r.system_call!=0)||(!r.system_call_arg1))
		return	FILE_SYSTEM_ERROR; 
	else
		return	r.system_call_arg2;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -