在旧版本的windows中,多任务是如何实现的?

考虑到DOS是一个单任务操作系统,以及它与早期版本Windows的联系,那么早期版本Windows是如何实现多任务的呢?今天的超级用户问答帖子将探讨这个问题的答案。...

在旧版本的windows中,多任务是如何实现的?

考虑到DOS是一个单任务操作系统,以及它与早期版本Windows的联系,那么早期版本Windows是如何实现多任务的呢?今天的超级用户问答帖子将探讨这个问题的答案。

今天的问答环节是由SuperUser提供的,SuperUser是Stack Exchange的一个分支,是一个由社区驱动的问答网站分组。

维基百科提供的Windows95屏幕截图。

问题

超级用户读者LeNoob想知道旧版本的Windows是如何作为多任务系统运行的?:

I read that DOS is a single-tasking OS. But if older versi*** of Windows (also including Windows 95?) were just wrappers for DOS, how could they run as a multi-tasking OS?

好问题!旧版本的Windows是如何作为多任务系统运行的?

答案

超级用户贡献者Bob和Pete为我们提供了答案。首先,鲍勃:

Windows 95 was far more than “just a wrapper” for MS-DOS. Quoting Raymond Chen:

  • MS-DOS served two purposes in Windows 95: 1.) It served as the boot loader. & 2.) It acted as the 16-bit legacy device driver layer.

Windows 95 actually hooked/overrode just about all of MS-DOS, keeping it as a compatibility layer while doing all the heavy lifting itself. It also implemented pre-emptive multi-tasking for 32-bit programs.

Pre-Windows 95

Windows 3.x and older were mostly 16-bit (with the exception of Win32s, a kind of compatibility layer that bridges 16 and 32, but we will ignore that here), were more dependent on DOS, and used only cooperative multi-tasking – that is the one where they do not force a running program to switch out; they wait for the running program to yield control (basically, say “I am done” by telling the OS to run the next program that is waiting).

  • Multi-tasking was cooperative, just like in old versi*** of MacOS (though unlike Multi-tasking DOS 4.x, which sported pre-emptive multi-tasking). A task had to yield to the OS in order to schedule a different task. The yields were built into certain API calls, notably message processing. As long as a task processed messages in a timely manner, everything was great. If a task stopped processing messages and was busy executing some processing loop, multi-tasking was no more.

Windows 3.x Architecture

As for how early Windows programs would yield control:

  • Windows 3.1 uses cooperative multi-tasking – meaning that each application that is in the process of running is instructed to periodically check a message queue to find out if any other application is asking for use of the CPU and, if so, to yield control to that application. However, many Windows 3.1 applicati*** would check the message queue only infrequently, or not at all, and monopolize control of the CPU for as much time as they required. A pre-emptive multi-tasking system like Windows 95 will take CPU control away from a running application and distribute it to those that have a higher priority based on the system’s needs.

Source

All DOS would see is this single application (Windows or other) running, which would pass control around without exiting. In theory, pre-emptive multi-tasking can possibly be implemented on top of DOS anyway with the use of a real-time clock and hardware interrupts to forcibly give control to the scheduler. As Tonny comments, this was actually done by some OSes running on top of DOS.

386 Enhanced Mode?

Note: there have been some comments on 386 enhanced mode of Windows 3.x being 32-bit, and supporting pre-emptive multi-tasking.

This is an interesting case. To summarise the linked blog post, 386 enhanced mode was basically a 32-bit hypervisor, which ran virtual machines. Inside one of those virtual machines ran Windows 3.x standard mode, which does all the stuff listed above.

MS-DOS would also run inside those virtual machines, and apparently they were pre-emptively multi-tasked – so it seems that the 386 enhanced mode hypervisor will share CPU time slices between the virtual machines (one of which ran normal 3.x and others which ran MS-DOS), and each VM will do its own thing – 3.x would cooperatively multi-task, while MS-DOS would be single-tasked.

MS-DOS

DOS itself was single-tasking on paper, but it did have support for TSR programs that would stay in the background until triggered by a hardware interrupt. Far from true multi-tasking, but not fully single-tasked either.

All this talk of bit-ness? I asked about multi-tasking!

Well, strictly speaking, the bit-ness and multi-tasking are not dependent on each other. It should be possible to implement any multi-tasking mode in any bit-ness. However, the move from 16-bit processors to 32-bit processors also introduced other hardware functionality that could have made pre-emptive multi-tasking easier to implement.

Also, since 32-bit programs were new, it was easier to get them to work when they were forcibly switched out – which might have broken some legacy 16-bit programs.

Of course, this is all speculation. If you really want to know why MS did not implement pre-emptive multi-tasking in Windows 3.x (386 enhanced mode notwithstanding), you will have to ask someone who worked there.

Also, I wanted to correct your assumption that Windows 95 was just a wrapper for DOS.

接着是皮特的回答:

In a modern operating system, the operating system controls all hardware resources, and running applicati*** are kept in sandboxes. An application is not permitted to access memory that the OS has not allocated to that application, and it cannot directly access hardware devices in the computer. If hardware access is required, the application must communicate through device drivers.

The OS can enforce this control, because it forces the CPU to enter protected mode.

DOS, on the other hand, never enters protected mode, but stays in real mode (*see below). In real mode, the running applicati*** can perform anything that it wants to, i.e. access hardware directly. But an application running in real mode can also tell the CPU to enter protected mode.

And this last part allows applicati*** like Windows 95 to start a multi-threaded environment even though they were basically launched from DOS.

DOS (Disk Operating System) was, as far as I know, not much more than a file management system. It provided a file system, mechani**s for navigating the file system, a few tools, and the possibility to launch applicati***. It did also allow for some applicati*** to stay resident, i.e. mouse drivers and EMM emulators. But it did not attempt to control the hardware in the computer the way a modern OS does.

*When DOS was first created in the 1970s, protected mode did not exist in the CPU. It was not until the 80286 processor in the mid 1980s that protected mode became part of the CPU.

一定要浏览到原来的线程和阅读通过这个主题的生动讨论使用下面的链接!


有什么要补充的解释吗?在评论中发出声音。想从其他精通技术的Stack Exchange用户那里了解更多答案吗?在这里查看完整的讨论主题。

  • 发表于 2021-04-11 10:09
  • 阅读 ( 176 )
  • 分类:互联网

你可能感兴趣的文章

5款基于经典生产力原则的新生产力应用程序

... 穆多已经有一段时间了,但它的第三个版本是正确的。如果您的电子邮件收件箱兼作任务列表,这就是要使用的应用程序。 ...

  • 发布于 2021-03-13 07:54
  • 阅读 ( 244 )

如何在Windows10中更改文本大小和字体

...设置、操作中心和“开始”菜单)不可靠。但是,它可以在旧的Windows应用程序和任务栏之类的东西上工作。 ...

  • 发布于 2021-03-14 03:32
  • 阅读 ( 231 )

windows与linux:以下是它们的共同点

...至于各种Linux桌面环境,包括KDE和GNOME,都包含了自己的版本。 ...

  • 发布于 2021-03-14 16:05
  • 阅读 ( 281 )

用linux和自由软件维护你的修复权的6种方法

... Linux在旧硬件上工作得更好。机器存在的时间越长,就越有可能有人知道如何让所有的部件工作。因此,虽然你多年来一直没有使用过的PC可能会拒绝最新版本的Windows,但它很...

  • 发布于 2021-03-14 19:02
  • 阅读 ( 195 )

如何在windows上查看“此电脑”中的所有驱动器

...机的所有硬盘驱动器和其他卷的中心集线器是这台电脑(在旧版本的Windows中称为“我的电脑”)。这允许您访问内部存储驱动器,以及连接到PC的任何可移动媒体,如闪存驱动器。 ...

  • 发布于 2021-03-16 23:19
  • 阅读 ( 156 )

如何使用miracast和connect将android屏幕投射到windows 10

...用的Miracast设备。在Android设备上,点击Cast或Miracast选项。在旧版本的Android中,菜单将屏幕广播称为Miracast。在较新版本(android4.4及更高版本)上,它被称为Cast。它位于“设置”>“显示”>“Miracast”或“投影”中。...

  • 发布于 2021-03-17 11:05
  • 阅读 ( 218 )

联邦调查局警告Windows7用户保护他们的电脑

...用户选择用windows7进一步挖掘。一旦Windows10发布,公司就在旧版本的Windows中建立了重要的系统,并配有专门为该版本设计的软件。 ...

  • 发布于 2021-03-30 17:53
  • 阅读 ( 188 )

windows10的虚拟桌面可以定制壁纸背景

...独特的墙纸。 此更改是Windows10InsiderBuild21337的一部分,该版本于2021年3月17日发布。它很可能以稳定的形式出现在windows10的21H2更新中,该更新计划在2021年下半年发布,可能在2021年10月发布。 一旦安装了更新,您就可以进入“设...

  • 发布于 2021-03-31 11:51
  • 阅读 ( 182 )

如何检查你的电脑是否有最新版本的Windows10

...并不是每个人都能同时得到它们。一些个人电脑仍然停留在旧版本的Windows10上一年或更长时间。下面是如何检查你的电脑是否是最新的。 为什么windows10更新这么慢 例如,AdDuplex在2020年11月的报告中发现,当时只有8.8%的Windows PC...

  • 发布于 2021-04-01 01:05
  • 阅读 ( 219 )

如何在Windows10的任务栏上查看多个时区时钟

...调整日期/时间”,然后选择“其他时钟”选项卡。尽管在旧版本的Windows上,单击任务栏上的时钟后显示的面板看起来不同,但它们的工作原理都是类似的。

  • 发布于 2021-04-02 19:36
  • 阅读 ( 163 )
5j17nxxbdh
5j17nxxbdh

0 篇文章

相关推荐