operating-system

Page number and offset

自闭症网瘾萝莉.ら 提交于 2021-02-05 13:05:29
问题 I am learning the different types of memory management. I don't understand the point of having an offset bits in a virtual address. And also why page sizes are made power of 2 ? My primary confusion is: give me an example of an offset being used in instruction to access a certain virtual address? My second confusion is: The usual statement is that if the size of logical address is 2^m and page size is 2^n , then the high-order m-n bits of a logical address designate the page number. 回答1: I

Why page faults are usually handled by the OS, not hardware?

爱⌒轻易说出口 提交于 2021-02-05 12:24:31
问题 I find that during TLB missing process, some architecture use hardware to handle it while some use the OS. But when it comes to page fault, most of them use the OS instead of hardware. I tried to find the answer but didn't find any article explains why. Could anyone help with this? Thanks. 回答1: If the hardware could handle it on its own, it wouldn't need to fault. The whole point is that the OS hasn't wired the page into the hardware page tables, e.g. because it's not actually in memory at

Why page faults are usually handled by the OS, not hardware?

家住魔仙堡 提交于 2021-02-05 12:23:18
问题 I find that during TLB missing process, some architecture use hardware to handle it while some use the OS. But when it comes to page fault, most of them use the OS instead of hardware. I tried to find the answer but didn't find any article explains why. Could anyone help with this? Thanks. 回答1: If the hardware could handle it on its own, it wouldn't need to fault. The whole point is that the OS hasn't wired the page into the hardware page tables, e.g. because it's not actually in memory at

How to avoid python running file in the directory where the code is located?

[亡魂溺海] 提交于 2021-02-05 11:49:00
问题 I'm writing a script that will download an executable from the internet, which will create more files. Now, if I download the file, it will be downloaded to the directory I told it, but when I open it using os.startfile(), it creates the files to the directory where the python script is located. How can I avoid that? 回答1: Either you can move the .py file to any other directory. or You can use os.chdir() to change the current working directory of the script during the runtime. os.chdir('/path

How to avoid python running file in the directory where the code is located?

此生再无相见时 提交于 2021-02-05 11:48:24
问题 I'm writing a script that will download an executable from the internet, which will create more files. Now, if I download the file, it will be downloaded to the directory I told it, but when I open it using os.startfile(), it creates the files to the directory where the python script is located. How can I avoid that? 回答1: Either you can move the .py file to any other directory. or You can use os.chdir() to change the current working directory of the script during the runtime. os.chdir('/path

Instruction pointer value after the page fault trap has been handled

喜欢而已 提交于 2021-02-05 06:52:09
问题 Honestly, I am really confused with this particular virtual memory related concept. Q1) When a page fault occurs, does the processor first finishes the execution of the current instruction and then moves the IP register contents (address of next instruction) to the stack? Or, it aborts current instruction being executed and moves the contents of instruction pointer register to stack? Q2) If the second case is true, then how does it resume the instruction which was aborted because when if it

What happens in the CPU when there is no user code to run?

戏子无情 提交于 2021-02-05 05:50:09
问题 It sounds reasonable that the os/rtos would schedule an "Idle task". In that case, wouldn't it be power consuming? (it sounds reasonable that the idle task will execute: while (true) {} ) 回答1: This depends on the OS and the CPU architecture. On x86 (Intel compatible) the operating system might execute HLT instructions, making the CPU wait until something interesting happens, such as a hardware interrupt. This supposedly consumes very little power. Operating systems report the time spent doing

Why the operating system says it can't allocate memory to jvm when it has enough memory

╄→гoц情女王★ 提交于 2021-02-05 05:31:30
问题 I'm trying to start a new jvm with the command: java -version , but it report a error: # There is insufficient memory for the Java Runtime Environment to continue. # Native memory allocation (malloc) failed to allocate 160088 bytes for AllocateHeap # An error report file with more information is saved as: # /users/xxx/xxx/hs_err_pid12365.log Then I checked file /users/xxx/xxx/hs_err_pid12365.log , and I find out it say: # Native memory allocation (malloc) failed to allocate 295856 bytes for

What jobs OS does when we use mmap function?

隐身守侯 提交于 2021-01-29 22:20:41
问题 Here is a example that maps a given file to memory using mmap function. In this example, I didn't use fwrite or write function to write something into a disk file(just print contents to stdout), but the modified memory content is actually reflected on the disk file. I'm guessing that OS tracks mapped memory and writes to disk when mapped memory is modified. I'd like to know the detail of what OS does. example.c #include <stdio.h> #include <sys/mman.h> #include <stdlib.h> #include <sys/stat.h>

Virtualbox debugging — g: error: The VM is already running

雨燕双飞 提交于 2021-01-29 17:55:43
问题 I'm trying to debug an operating system that I am developing. When I start up the VM machine with VirtualBoxVM --startvm "X" --debug the VM starts paused, but when I execute the 'g' command to continue execution I get this error: g: error: The VM is already running But when I start my virtual machine without --debug , everything works fine, but I can't debug. Why does that error message appear? The VM starts stopped, so the message doesn't make sense and it doesn't allow me to debug my OS. 来源