๐ŸŽ“ BookMCQ
โ† Back to 19. Windows 7

๐Ÿ“ Windows 7 Switching between user mode and kernel mode threads (7 MCQs)

Privilege Transitions During Windows Thread Execution

Windows 7 threads normally execute application code in user mode and enter kernel mode when they request protected operating system services or encounter certain exceptions and interrupts. The same thread can execute in both modes, using separate user and kernel stack contexts. Processor privilege levels protect kernel memory and restrict direct access to critical hardware operations.

Why User Programs Cannot Execute Privileged Operations

Applications should not directly modify kernel data, processor control state, or device registers. If all code shared privileged access, a programming error could compromise the entire system. Windows therefore uses processor privilege mechanisms and controlled transitions to allow user programs to request services without receiving unrestricted authority.

System Calls and Kernel Stack Execution

When a thread invokes a system service, processor instructions transfer execution into kernel mode. Windows establishes the kernel execution context and uses the thread's kernel stack while processing the request. After the service completes, the system restores the appropriate user-mode context and returns the result to the application.

Example of a File Read Transition

A user-mode thread calls ReadFile to obtain data. The Windows I/O path enters kernel mode, validates the handle and request, and invokes the relevant filesystem and device operations. When processing completes or reaches a wait condition, the thread eventually resumes user-mode execution with the result or status.

Security Boundaries and Transition Overhead

Privilege separation protects kernel resources and allows multiple applications to operate safely. User-to-kernel transitions introduce processing overhead, but system calls are necessary for controlled resource access. A system call does not necessarily switch to another thread, and an interrupt may enter kernel mode without being initiated by the current application.

Misconceptions About User and Kernel Mode

'Every kernel-mode transition creates a new thread' is false because the existing thread can change privilege mode. 'User-mode code cannot request kernel services' ignores system calls. 'An application runs entirely in kernel mode after opening a file' is incorrect because ordinary application execution remains in user mode.

Exam Focus: System Call and Privilege Mode Transitions

Trace a thread from user-mode execution through a system call into kernel mode and back. Explain why the kernel validates handles and arguments. Questions may distinguish a privilege-mode change from a context switch or identify the security purpose of separate user and kernel stacks.

Key Terms of Windows Execution Modes

  • User mode - Restricted application execution mode.
  • Kernel mode - Privileged operating system execution mode.
  • System call - Controlled request for kernel service.
  • Kernel stack - Stack used during kernel execution.
  • Privilege transition - Change between processor protection modes.
2
Easy
2
Medium
3
Hard

๐Ÿ“ All Windows 7 Switching between user mode and kernel mode threads MCQs

Q1. A user program needs to request disk I/O. Which mechanism causes the thread to move from user mode to kernel mode to perform the operation?

A.System call โœ…
B.Interrupt
C.Exception
D.POLLING
๐Ÿ’ก Difficulty: easy | โœ… Correct: A

Q2. Why does Windows separate the HAL, kernel, and executive layers?

A.To simplify hardware abstraction โœ…
B.To improve security
C.To increase execution speed
D.TO REDUCE MEMORY USAGE
๐Ÿ’ก Difficulty: medium | โœ… Correct: A

Q3. Which of the following is one of the four main responsibilities of the Windows kernel?

A.Thread scheduling โœ…
B.File compression
C.Network routing
D.USER INTERFACE RENDERING
๐Ÿ’ก Difficulty: easy | โœ… Correct: A

Q4. A developer notices a deadlock when a thread repeatedly switches from user mode to kernel mode while acquiring a resource. Which synchronization object should be used to avoid this problem?

A.Spin lock
B.Mutex โœ…
C.Semaphore
D.EVENT
๐Ÿ’ก Difficulty: medium | โœ… Correct: B

Q5. When a thread switches from user mode to kernel mode, which processor state elements must be saved to preserve execution context?

A.Only instruction pointer
B.Instruction pointer and flags
C.Instruction pointer, flags, and stack pointer โœ…
D.ENTIRE REGISTER SET INCLUDING FLOATINGโ€‘POINT
๐Ÿ’ก Difficulty: hard | โœ… Correct: C

Q6. A driver must run on both x86 and ARM CPUs. How does the HAL simplify this development?

A.By providing identical APIs for hardware access โœ…
B.By translating C code to assembly
C.By managing memory allocation
D.BY HANDLING USERโ€‘MODE SCHEDULING
๐Ÿ’ก Difficulty: hard | โœ… Correct: A

Q7. If a thread frequently switches between user mode and kernel mode, what performance impact is most likely and which mitigation strategy is appropriate?

A.Increased latency, use asynchronous I/O
B.Higher CPU usage, batch system calls โœ…
C.Reduced memory, enable paging
D.LOWER THROUGHPUT, INCREASE THREAD PRIORITY
๐Ÿ’ก Difficulty: hard | โœ… Correct: B

๐Ÿ”— Related Topics (MCQs)