CPU Two working states of , That is, the two execution states of the processor .
<>
The program of an existing operating system in a system , Also by ordinary users of the program . Among the numerous instructions , Some instructions can only be used by the system , Prohibit direct access to user programs . In order to ensure the smooth operation of the operating system and various applications , They must be limited , Otherwise, the security and stability of the system cannot be guaranteed .
<> Therefore, according to the permission of the running program to use resources and machine instructions , Set the processor to a different state . Most systems divide the working state of the processor into tube state and target state .
<>1, System state ( Also called tube state , Kernel state , Nuclear mentality , Privileged state )
System state is the state when the hypervisor of the operating system is running , It has a high level of privilege . When the processor is in tube state , It can execute all instructions , Including various privileged instructions , You can also use all resources , And it has the ability to change the state of the processor , It feels awesome . It should be pointed out that , Tube state is different from super user , The former refers to CPU State of , The latter refers to a special kind of computer user ; The former mainly executes any instruction from the perspective of hardware , The latter manages the software and hardware resources of the system from the perspective of software , Such as user account , Authority management , File access, etc . Programs executed by super users do not necessarily run in the managed state , The managed program is not necessarily started by the system administrator , Ordinary users can also start .
<>2, User state ( Also called eye state , Ordinary state )
User status is the status when the user program is running , It has a lower privilege level . Privileged instructions cannot be used in this state , System resources cannot be used directly , Nor can it change CPU Working status of , And can only access the user program's own storage space . The user state does not allow the program to perform operations requiring privileged state in the processor , To avoid operating system crashes . Each process runs in its own user space , It does not allow access to the user space of other programs .
<> In kernel state CPU Any instruction can be executed , In user mode CPU Only non privileged instructions can be executed . <>
When CPU In kernel state , You can enter user status at will ; And when CPU When in user status , The user switches from user mode to kernel mode only after system call and interrupt
Occurs in two cases , Generally, programs run in user mode at the beginning , When the program needs to use system resources , You must enter the kernel state through the soft interrupt mechanism .
<> two types CPU Transition mode between states :
<> User state —> Kernel state : system call ( By interrupt , abnormal , Trapping mechanism )
<> Kernel state —> User state : Set program status word PSW
Technology
Daily Recommendation