📝 Sharing objects between processes in Window 7 (9 MCQs)
Cross Process Sharing of Windows Kernel Objects
Windows 7 allows processes to share selected kernel objects and memory resources through named objects, duplicated handles, and shared sections. This enables interprocess communication and coordination without removing process isolation. Object Manager naming, access-control descriptors, and memory mapping services control which processes can obtain shared references and how they use them.
Why Separate Processes Need Controlled Sharing
Process isolation protects private address spaces, but applications often need to exchange data or coordinate operations. Sharing resources directly through unrestricted memory access would weaken isolation. Windows provides controlled mechanisms that expose selected objects to multiple processes while retaining permissions and lifetime management.
Named Objects, Handle Duplication and Sections
Processes can open the same named event, mutex, or semaphore if permissions allow. DuplicateHandle can create a usable handle in another process. File mapping objects, also called sections, can map the same underlying region into multiple address spaces, allowing processes to exchange data through shared memory.
Example of Shared Memory Between Two Processes
Process A creates a named file mapping for a 4096-byte region and writes a message into it. Process B opens the same mapping and reads the data from its own mapped address. A named event or mutex coordinates access so B does not read partially updated information.
Transfer Efficiency and Synchronisation Requirements
Shared memory avoids repeated copying through message channels and can support high-volume data exchange. It requires explicit synchronisation and permission management because concurrent updates can create races. Named objects may also collide with existing names, and shared handles must be limited to the rights required by each process.
Misconceptions About Windows Object Sharing
'Sharing a handle means both processes use the same numeric handle value' is false because handle values are process-specific. 'Shared memory automatically prevents race conditions' ignores synchronisation requirements. 'Every named object is accessible to every account' overlooks object security descriptors and namespace permissions.
Exam Focus: Named Objects and Shared Sections
Compare named synchronisation objects, duplicated handles, and shared memory sections. Trace how two processes obtain access to the same object and coordinate updates. Questions may examine security descriptors, process-specific handle values, memory mapping, and the need for mutexes or events around shared data.
Key Terms of Windows Object Sharing
- Named object - Kernel object identified through a name.
- DuplicateHandle - Creates a handle in another process.
- Section - Kernel object backing mapped memory.
- Shared memory - Memory region mapped by multiple processes.
- Event - Object signalling a synchronisation condition.
📝 All Sharing objects between processes in Window 7 MCQs
Q1. A process creates an APC to notify another process that an asynchronous read has finished. Which condition must be true for the target thread to execute the APC?
📖 Explanation: The correct answer is B because an APC is only delivered when the target thread is waiting in the kernel and marked alertable. If the thread is not alertable (option A), the APC remains queued. Options C and D describe states that do not affect APC delivery. Understanding this rule helps developers design inter‑process notifications that reliably trigger code execution at the right moment.
Q2. Which of the following best defines an Asynchronous Procedure Call (APC) in Windows?
📖 Explanation: An APC is a user‑mode routine that is queued to a particular thread and executes only when that thread enters an alertable wait state. Option B captures this definition precisely. Option A confuses APCs with immediate interrupt handling, option C describes a DPC, and option D describes a timer callback. Knowing the exact definition prevents misuse of APCs for tasks that require immediate or timed execution.
Q3. Why does the dispatcher schedule Deferred Procedure Calls (DPCs) at a priority lower than device‑interrupt priority but higher than normal thread priority?
📖 Explanation: The dispatcher places DPCs below hardware interrupt priority so that the ISR can complete critical work first, but above normal thread priority so that DPCs are not delayed by regular scheduling. This ordering balances responsiveness with system stability. Option A is incorrect because DPCs can preempt each other based on their own priority levels. Option C misstates the relation to APCs, and option D is not how Windows schedules DPCs.
Q4. A thread is waiting on a synchronization object without the alertable flag set. An APC is queued to this thread. What will happen to the APC?
📖 Explanation: When a thread is not in an alertable state, any queued APC cannot be delivered; the system simply discards it rather than converting it. Option B suggests the APC will wait, which is false because the dispatcher does not retain APCs for later conversion. Option A is wrong because APCs never run while a thread is in a non‑alertable wait. Understanding this behavior prevents accidental loss of notifications.
Q5. Two processes share a named event object. Process A queues a DPC that sets the event after processing a timer. Process B is waiting on the event in an alertable state. Which outcome is most likely?
📖 Explanation: When the DPC runs, it sets the event, making the wait condition true. However, the waiting thread will not be scheduled until the current quantum ends and the scheduler selects a new thread, which is described in option C. Option A ignores the scheduling step, option B incorrectly claims DPCs cannot signal events, and option D mixes APC behavior with DPC signaling. This illustrates proper synchronization across processes using shared kernel objects.
Q6. What is the primary reason the dispatcher may forward work from an ISR or DPC to a pool of worker threads?
📖 Explanation: The dispatcher forwards work to worker threads when the operation cannot be completed quickly enough within the ISR/DPC context, often because the work needs a higher priority than the DPC can safely have. Option B captures this reason. Option A is a secondary concern (DPCs cannot page), but the main driver is priority management. Options C and D are unrelated to the dispatcher’s design goals.
Q7. A system requires two processes to share a memory‑mapped file and be notified instantly when the other process writes new data. Which combination provides the lowest latency notification?
📖 Explanation: A kernel‑mode APC queued by the writer’s thread can execute as soon as the reader thread becomes alertable, delivering notification with minimal delay. Option D therefore yields the lowest latency. Option A introduces mutex overhead and requires the thread to be alertable. Option B relies on a DPC, which runs at a lower priority than the ISR but still may be delayed by other DPCs. Option C adds unnecessary semaphore handling and a worker thread, increasing latency.
Q8. When the scheduler reaches the end of a thread’s quantum, it queues a DPC to preempt the thread. At which priority level must the DPC be placed to guarantee it runs before any normal thread on the same processor?
📖 Explanation: The DPC must be scheduled above normal thread priority so it preempts regular threads, yet still below any hardware interrupt priority to avoid interfering with critical ISR work. Option C describes this exact placement. Option A would disrupt interrupt handling, option B misplaces the DPC relative to other DPCs, and option D would allow normal threads to run before the DPC, defeating the preemptive purpose.
Q9. Which statement correctly describes how sharing a kernel object, such as a file mapping, between processes interacts with APC delivery?
📖 Explanation: When an APC is queued to a thread that will use a shared kernel object, the object's reference count is incremented to ensure it remains valid while the APC executes. Option B captures this mechanism. Option A is false because APCs can be delivered to any thread with appropriate rights. Option C incorrectly suggests duplication, and option D ignores the need for reference counting to protect the object during APC execution.