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

📄 main.c

📁 国内一位牛人自己开发的操作系统
💻 C
字号:
#include"../include/os.h"
extern void test(void );
void my_test()
{
	for(;;){
		int n;
		n=get_number();
		set_print_thread(n);
	}
};
void test_main(void )
{
	int i,n;
	REG r;
	struct kernel_time t1,t2;
	extern void init_file_system(void ),init_memory(void ),init_file(void );
	union system_call_parameter *par=get_kernel_parameter();

	print_string("\n\n\n\n\n\n                              Congratulation\n\n");
	print_string("\n\n     Your operating System that Basing Virtual Address Space on files has been installed and bootted successfully!");
	print_string("\n\n     Next, I am going to initialize the file system processor process, push any key to continue ...\n");
	get_char();

	init_file_system();
	print_string("\n\n     File system processor process has been initialized.Next,I am going to initialize the memory management processor process, after that I will migrate to the memory management processor process to initialize the memory body. push any key to continue ...\n");
	get_char();

	init_memory();

	print_string("\n\n     Memory management processor process and file system processor process have all been initialized.Next I am going to open 48 files,after that I will create some threads to run on these opened files,thus implement Programms Running on Files, that is, Basing Virtual Address Space on Files. Push any key to begin opening files......\n");
	get_char();
	
	init_file();

print_string("\n\n\n\n     Both file system processor process and memory management processor process have been initialized,memory body has been initialzed too,also files have been opened. Next I am going to create some threads to run on these opened files. When these threads are running, the programm that it is running,the code that it is executing, and the data that it is accessing, all these information are in these files,thus implementing Basing Virtual Address Space on Files.Push any key to continue .....");
get_char();


print_string("\n\n\n\n     When these threads are running, they will acesses data in these opened files simultaneously, some file data has been loaded into memory, some not. If file data doesn't exit in memory, the first thread that accesss the data will do thread migration system call, migrating to memory management processor process to allocate memory frame, after that migrate from memory processor process to file system processor process to read data into memory, when thread return from file system to memory management processor process, the data has been loadded in memory,it will set up memory map, therefor when the thread return from memory management processor process,it can continue to run. Push any key to continue ......");
get_char();


print_string("\n\n\n\n     Because so many thread access these opened files simultaneously, executing code or access data, some file data has been loaded into memory, some file data not, some file data is being loaded into memory, some file data is being written to file system, therefor memory management processor process is much complcated, through semaphore mechnism and P V operation, the memory management processor process  runs corrently");

print_string("\n\n     When these threads runninig, they count the sum in each page of the opened files, and display the following information:\n");

print_string("\n\n          1.time ticks: this is how many clock ticks has passed. Because whenever a clock tick come, the kernel will do thread switch,this is also the number of how many thread switch the kernel has  done");

print_string("\n          2.thread ID: this is which thread is running");
print_string("\n          3,4.values in two loop variables");
print_string("\n          5.the sum in current accessing page");

print_string("\n\n     Push any key to continue ...");
get_char();
print_string("\n\n     These threads run on these opened files simultaneously, access data in these files simultaneously, some file data is in memory, some is being swapped in, some is being swapped out, even the code that threads are executting may be swapped in or swapped out. Because these threads run and display information simultaneously, so the screen maybe much of chaos.");
print_string("\n\n     Now I am ready to create threads, How many threads do you want to be created ? Input a number please ");

	n=get_number();
	r.ax=22;r.bx=0;r.cx=512;r.dx=READ_ONLY;
	r.si=0; r.di=1;
	RESET_CAPABILITY(get_kernel_parameter()->capability.capability_1);
	call_kernel(&r);

	get_current_time(&t1);

	for(i=0;i<n;i++){
		RESET_CAPABILITY(par->capability.capability_1);
		r.ax=6;
		r.bx=1;
		r.cx=(int)(55*PAGE_SIZE);
		if(i==0)
			r.cx=(int)my_test;
			/* this is the entry point
				where the new thread will execute */
		r.dx=DEFAULT_SP;
			/*this is stack pointer for the new thread */
		call_kernel(&r);
			/* call os kernel to create a new thread */
		print("\ncreate thread with id is ",r.ax);
		get_current_time(&t2);
		print("time is ",t2.v_l-t1.v_l);
	}
	for(;;){
		r.ax=0;r.bx=14;r.cx=10;r.dx=1024;
		call_memory(&r);
		r.ax=(-1);call_kernel(&r);
	}

	return ;
}

⌨️ 快捷键说明

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