include vmm.inc
VMMCall End_Crit_And_Suspend
jc not_released
Releases the critical section and immediately suspends the current virtual machine. Virtual devices use this service to block a virtual machine until another virtual machine can process an event. Uses Flags.
This service releases the critical section only if the virtual machine has claimed the section once. This service returns an error if the system could not suspend the virtual machine, or could not release the critical section because the claim count was not 1. In such cases, the service does not decrement the claim count and the critical section is not released.
The following example uses this service to display a dialog box in the system virtual machine. The Show_Dialog_Box function enters a critical section to prevent the Call_Priority_VM_Event service from switching to the system virtual machine immediately. It then calls End_Crit_And_Suspend which blocks the current virtual machine. The Show_Dialog_Event function runs in the system virtual machine and actually displays the dialog box. When it is finished it resumes the virtual machine that called Show_Dialog_Box by calling the Resume_VM service.
Show_Dialog_Box:
VMMCall Get_Crit_Section_Status
jc Cant_Do_It ; critical section already
; claimed
VMMCall Begin_Critical_Section
mov eax, Low_Pri_Device_Boost
VMMCall Get_System_VM_Handle
mov ecx, 11b
mov edx, OFFSET32 Dialog_Box_Data_Structure
mov esi, OFFSET32 Show_Dialog_Event
VMMCall Call_Priority_VM_Event
VMMCall End_Crit_And_Suspend
jc Did_Not_Work
; When End_Crit_And_Suspend returns, the dialog box
; will have been displayed
Show_Dialog_Event:
; Call Windows to display the dialog box
mov ebx, [Suspended_VM_Id]
VMMCall Resume_VM
jc Error
ret
The End_Crit_And_Suspend service predates most of the synchronization services provided by Windows 95 and exists primarily for backward compatibility. New virtual devices should avoid this service, since there are better mechanisms available.
End_Critical_Section, Resume_VM, Suspend_VM