Kernel threads can access both kernel virtual memory and, if a user process is running, the user virtual memory of the running process. An attempt to access kernel virtual memory causes a page fault, handled by page_fault() in userprog/exception.c, and the process will be terminated. 그 이후로는 머신의 실제 메모리 공간의 크기에 따라 달라진다.Ī user program can only access its own user virtual memory. That is, virtual address KERN_BASE accesses physical address 0, virtual address KERN_BASE + 0x1234 accesses physical address 0x1234, and so on up to the size of the machine's physical memory. In Pintos, kernel virtual memory is mapped one-to-one to physical memory, starting at KERN_BASE. It is always mapped the same way, regardless of what user process or kernel thread is running. struct thread contains a pointer to a process's page table. When the kernel switches from one process to another, it also switches user virtual address spaces by changing the processor's page directory base register (see pml4_activate() in thread/mmu.c). User virtual memory ranges from virtual address 0 up to KERN_BASE, which is defined in include/threads/vaddr.h and defaults to 0x8004000000 Kernel virtual memory occupies the rest of the virtual address space. Virtual memory in Pintos is divided into two regions: user virtual memory and kernel virtual memory. The -f option causes the file system to be formatted, and -q causes Pintos to exit as soon as the format is done. Afterward, format the file system partition by passing -f -q on the kernel's command line: pintos SCRIPT_COMMANDS -f -q. The - is needed because -fs-disk is for the pintos script, not for the simulated kernel. pintos -fs-disk filesys.disk - KERNEL_COMMANDS.). Then, specify the disk by passing -fs-disk filesys.dsk after pintos but before - (i.e. This command creates a simulated disk named filesys.dsk that contains a 2 MB Pintos file system partition. From the userprog/build directory, execute pintos-mkdisk filesys.dsk 2. The pintos-mkdisk program provides this functionality. To put a file into the Pintos virtual machine, firstly you need to be able to create a simulated disk with a file system partition. Also, if the codes is enclosed by #ifndef VM, those codes will be omitted from project 3. This blocks will be included after enabling the virtual memory subsystem, which you will implement in the project 3. All of your codes should never located in block that enclosed by #ifdef VM. You must make sure that the user program interface meets the specifications described here, but given that constraint you are free to restructure or rewrite kernel code however you wish. From now on, we will test your operating system by running user programs. In the previous project, we compiled our test code directly into your kernel, so we had to require certain specific function interfaces within the kernel. This means that when you load and run multiple processes at a time, you must manage memory, scheduling, and other state correctly to maintain this illusion. User programs are written under the illusion that they have the entire machine. Each process has one thread (multithreaded processes are not supported). We allow more than one process to run at a time. This project deals with the consequences. Once we start running user programs on top of the operating system, this is no longer true. This means, for example, that all the test code from the last assignment ran as part of the kernel, with full access to privileged parts of the system. Up to now, all of the code you have run under Pintos has been part of the operating system kernel.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |