iczelion Vxd tut2 (转)[@more@]
Virtual Machine Manager (VMM) is the
true operating system behind
windows 95. It erects and maintains the
framework for managing virtual machines. It also prov
ides many important services to other VxDs. The three important services are:
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)
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 be chosen by the primary scheduler to run.
[.NET/">Iczelion's Win32 Assembly Homepage]
Virtual Machine Manager
- 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.
- 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 ones.
- List services. Manage fixed-size memory blocks suitable for implementing 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 tran sfer 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
The VMM uses two scheduler components to implement preemptive multitasking among threads and VMs.- primary scheduler
- time-slicer or secondary scheduler
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 be chosen by the primary scheduler to run.
You can get more detail about these subjects from Walter Oney's Systems Programming for Windows 95 and the Windows 95 DDK documentation.
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10790663/viewspace-956707/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/10790663/viewspace-956707/