ICZelion vxd TUT2

zhaozj2021-02-11  262

Virtual Machine Manager

Virtual Machine Manager (VMM) is the true operating system behind Windows 95. It erects and maintains the framework for managing virtual machines It also provides many important services to other VxDs The three important services are..:

Memory Management Interrupt Handling Thread Scheduling

Memory Management

VMM Uses Paging Capability of Intel 80386 and Later Processors To Create A 32-Bit Virtual Address Space for the System VM. It Divides The Address Space Into Four Distinct Areas.

V86 region extending from address 0h to 10FFEFh. This region belongs to the currently executing virtual machine. Private application region extending from the address 4MB to 2GB. This is the area where win32 applications run. Each win32 process will have its own private 2GB (minus 4 MB). Shared application region extending from address 2 GB to 3 GB. This area is shared to ALL applications in the system VM. This region is where the system DLLs (user32, kernel32, and gdi32) reside. All Win16 apps run here as well because they are ill-behaved: they are used to reading / writing from / to other win16 apps in memory in this region, Win16 apps can see all other Win16 apps Memory mapped files are stored here as well as the memory allocated.. For DPMI Calls. Shared System Region Extending from The Address 3GB TO 4GB. This is where vmm and vxds live.

VMM Provides Three Types of Memory Services to vxds

Page-based memory services. This kind of services allocate / manage memory in pages of 4 KBs. It's the lowest level memory services available. All other memory services use page-based memory services as their base. Heap memory services. Manage smaller blocks of Memory. this is a higher-level of memory management services Built on top of the page-based one, limited-size memory block suitable for importling linked lists.interrupt handling

Interrupts in protected mode vector to Interrupt Descriptor Table (IDT). VMM supervises the IDTs of VMs with the help of VxDs. Normally VMM handles nearly all the entries in IDTs. It provides first-level interrupt handlers which save the state of interrupted program on the stack and transfer control to the second-level interrupt handlers which may be provided by various VxDs for the actual processing. When the second-level handler finishes its job, it transfers control to the redispatch routine which will restore the state of the interrupted program And Resume Execution At The Previous Point of Interruption.

The above description is an oversimplified one. Redispatching may not be immediate because the interrupted VM's timeslice may expire. VxDs can install interrupt handlers via VMM services such as Set_PM_Int or Hook_V86_Int_Chain. VxDs must not modify IDT entries directly (but you can do it if you Are Sure you know what you're doing

Thread Scheduling

.

Primary Scheduler Time-Slicer Or Secondary Scheduler

Primary scheduler's task is to choose the thread with highest execution priority to run. This selection occurs while the VMM is servicing an interrupt (such as timer interrupts). The outcome determines which thread / VM will be given control when the VMM returns from servicing the interrupt. Primary scheduler works under all-or-nothing rule. Either a thread will be run or it will not. Only one thread is chosen. VMM and other VxDs can boost / adjust execution priority of threads via VMM services. For example, if a hardware interrupt occurs, VMM will boost the interrupt handler's execution priority so that it will have higher chance of completion in the shortest possible time.Secondary scheduler uses the services of the primary scheduler to allocate CPU time among threads that share the highest execution priority by Giving Each Thread A Time Slice. When a Thread Executes Until ITS Time Slice Expires, The Secondary Scheduler Boosts The Execution Priority of The Next Thread So That IT Will B Chosen by the primary scheduler to run.

You Can Get More Detail About The Subjects from Walter One's Systems Programming for Windows 95 and the Windows 95 DDK Documentation.

[ICZelion's Win32 Assembly HomePage]

转载请注明原文地址:https://www.9cbs.com/read-4639.html

New Post(0)