How does the operating system execute and control the execution of binary files and compiled files ? I think the OS may copy a part of the binary file to a certain memory location, jump there, return after executing the block and execute the next block. But it does not have any control over it (for example, the program can jump anywhere And will not come back).
In the case of JVM, it makes sense, the VM is interpreting every instruction. But in the case of binary files, the instructions are real CPU executable instructions, so I I don’t think the operating system is like a VM.
>Create an entry in the process table
>Create a virtual memory space for the process
>Load the program code into the process memory
>Point the process instruction pointer to the process Entry point
>Create an entry in the scheduler and set the process thread to be executable.
The program is split into blocks and does not handle concurrency. Switch between tasks through interrupts: in Before giving the CPU process, set the timer. When the timer is completed, the CPU registers an interrupt, pushes the instruction pointer to the stack and jumps to the interrupt handler defined by the operating system. This handler stores the CPU state in the memory and exchanges Virtual memory table and restore some other threads that are ready for execution. If the thread has to be paused for some other reason (waiting for user/disk/network…) or output, the same swap will occur.
http://en. wikipedia.org/wiki/Multitasking#Preemptive_multitasking.2Ftime-sharing
Please note that the process that depends on the generation of the CPU is possible but unreliable (the process may not occur, preventing other processes from running)
http://en.wikipedia.org/wiki/Multitasking#Cooperative_multitasking.2Ftime-sharing
Security is handled by switching the CPU to protected mode, where the application code cannot run certain instructions ( So random jumps are almost harmless). See the link provided by @SkPhilipp
Please note that modern JVM does not interpret every instruction (which will be slow). Instead, it compiles native code and first Run the code or (in the case of just-in-time compilation) explain, but compile “hot spots” (codes that run frequently).
When I studied process scheduling, this problem emerged In my mind.
How does the operating system execute and control binary files and compiled File execution? I think the OS may copy a part of the binary file to a certain memory location, jump there, return after executing the block and execute the next block. But it does not have any control over it (for example, the program can jump anywhere And will not come back).
In the case of JVM, it makes sense, the VM is interpreting every instruction. But in the case of binary files, the instructions are real CPU executable instructions, so I I don’t think the operating system is like a VM.
It’s exactly that. The operating system is in a certain order,
>in Create an entry in the process table
>Create a virtual memory space for the process
>Load the program code into the process memory
>Point the process instruction pointer to the process entry point
>Create an entry in the scheduler Entry, and set the process thread to be executable.
The program is split into blocks and will not handle concurrency. Switch between tasks through interrupts: set the timer before giving the CPU process. When the timer When finished, the CPU registers an interrupt, pushes the instruction pointer to the stack and jumps to the interrupt handler defined by the operating system. This handler stores the CPU state in memory, swaps virtual memory tables and restores some other threads that are ready for execution. If the thread has to be paused for some other reason (waiting for user/disk/network…) or output, the same exchange will happen.
http://en.wikipedia.org/wiki/Multitasking#Preemptive_multitasking.2Ftime- sharing
Please note that the process that depends on the generation of CPU is possible but unreliable (the process may not occur, preventing other processes from running)
http://en.wikipedia.org/wiki /Multitasking#Cooperative_multitasking.2Ftime-sharing
Security is handled by switching the CPU to protected mode, where the application code cannot run certain instructions (so random jumps are almost harmless). See the link provided by @SkPhilipp
Please note that modern JVM does not interpret every instruction (which will be slow). Instead, it compiles native code and runs the code first or (in the case of just-in-time compilation) interprets , But compile “hot spots” (codes that run frequently).