• 沒有找到結果。

Switch from user to kernel mode

N/A
N/A
Protected

Academic year: 2021

Share "Switch from user to kernel mode"

Copied!
2
0
0

加載中.... (立即查看全文)

全文

(1)

1. Which of the following instructions should be privileged(in kernel mode)?

a. Set value of timer.

b. Read the clock.

c. Clear memory.

d. Issue a trap instruction.

e. Turn off interrupts.

f. Modify entries in device-status table.

g. Switch from user to kernel mode.

h. Access I/O device.

Answer:

The following operations need to be privileged: Set value of

timer, clear memory, turn off interrupts, modify entries in device-status table, access I/O device. (a,c,e,f,h)

The rest can be performed in user mode.(b,d,g)

2. Name three ways in which the processor can transition form user mode to kernel mode?

Answer:

1) The user process can execute a trap instruction (e.g. system call). A trap is known asa synchronous software interrupt.

2) The user process can cause an exception (divide by zero, access bad address, bad instruction, page fault, etc).

3) The processor can transition into kernel mode when receiving an interrupt.

3. (2.3)Describe three general methods for passing parameters to the operating system.

Answer:

a. Pass parameters in registers

b. Registers pass starting addresses of blocks of parameters

c. Parameters can be placed, or pushed, onto the stack by the program, and popped off the stack by the operating system.

4. What is the difference between kernel mode and user mode? Why is the difference important to an operating system?

Answer:

In Kernel mode, the executing code has complete and unrestricted access to the underlying hardware. It can execute any CPU instruction and reference any memory address .

In User mode, the executing code has no ability to directly access

(2)

hardware or reference memory. Code running in user mode must delegate to system APIs to access hardware or memory.

The difference rather protect the computer system resources, while preventing from errant users.

5. What are exceptions? Name two different types of exceptions and give an example of each type.

Answer:

Exceptions are events that stop normal execution, switch the execution mode into kernel mode, and begin execution at special locations within the kernel. Examples include

system calls, divide by zero errors, illegal instructions, and page faults.

參考文獻

相關文件

– Set the corresponding bits in TCCRnX(n=1,2,3 X=A,B) re gisters for mode selection and timer prescaler. – Set OCRnX for “frequency”(OCRnA) or

At migration or load time, the Roam agent can compare the device requirements from the application components with the target device capabilities and decide the best

² Stable kernel in a goals hierarchy is used as a basis for establishing the architecture; Goals are organized to form several alternatives based on the types of goals and

– Runs replay mode to search for a solution – Reports to the user to run observation

• To the right of the Draw mode buttons you find push buttons through which you can access all the functions that you need to define and solve the PDE problem: define

An alternative way to proceed would be to directly estimate that one of the unknown constants C 1 :::C 4 which is appropriate to the context (e.g. C 1 if we were using the excess

Now, nearly all of the current flows through wire S since it has a much lower resistance than the light bulb. The light bulb does not glow because the current flowing through it

Simulation conditions are introduced first and various characteristics in three defect designs, such as single mode laser wavelength shift and laser mode change, are analyzed.