在舊版本的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
  • 閱讀 ( 42 )
  • 分類:網際網路

你可能感興趣的文章

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

...設定、操作中心和“開始”選單)不可靠。但是,它可以在舊的Windows應用程式和工作列之類的東西上工作。 ...

  • 發佈於 2021-03-14 03:32
  • 閲讀 ( 47 )

6款可增強mac多工處理能力的應用程式

...用一年。同時,19.99美元可以讓你獲得所有應用程式當前版本更新的終身許可。最後,所有版本的永久許可證價格為39.99美元。 ...

  • 發佈於 2021-03-19 06:27
  • 閲讀 ( 40 )

windows10的虛擬桌面可以定製桌布背景

...獨特的牆紙。 此更改是Windows10InsiderBuild21337的一部分,該版本於2021年3月17日釋出。它很可能以穩定的形式出現在windows10的21H2更新中,該更新計劃在2021年下半年釋出,可能在2021年10月釋出。 一旦安裝了更新,您就可以進入“設...

  • 發佈於 2021-03-31 11:51
  • 閲讀 ( 39 )

如何在windows 10上更改顯示器的重新整理率

...重新整理率。 一旦您對重新整理率滿意,請關閉設定。 在舊版本的windows 10上選擇重新整理率 如果您執行的是舊版本的Windows10,下面介紹如何更改顯示器的重新整理率。首先,右擊桌面並選擇“顯示設定” 在“顯示設定”中...

  • 發佈於 2021-04-01 00:54
  • 閲讀 ( 34 )

微軟視窗35年:回憶視窗1.0

...終上市時,在業界幾乎沒有引起什麼反響。然而,第一個版本為微軟的未來奠定了基礎。 使用windows 1.0 為了使用Windows1.0,您購買了該軟體的盒裝副本。然後,你要麼把它安裝到電腦裡的硬碟上,要麼用兩張軟盤執行它。Windows1.0...

  • 發佈於 2021-04-01 08:21
  • 閲讀 ( 51 )

如何從Windows10的alt+tab中刪除邊緣瀏覽器選項卡

從2020年10月的更新開始,Windows10現在預設在Alt+Tab任務切換器中顯示MicrosoftEdge瀏覽器選項卡。對某些人來說,這可能很方便。但是,如果您想在Alt+Tab中禁用製表符,那麼在設定中很容易修復。下面是方法。 在更新到Windows 2020年1...

  • 發佈於 2021-04-01 10:57
  • 閲讀 ( 28 )

如何檢視windows defender在您的電腦上發現的惡意軟體

...毒和威脅保護”。然後單擊或輕觸“保護歷史記錄”。(在舊版本的Windows 10上,此選項將改為顯示“威脅歷史記錄”。) 在“保護歷史記錄”螢幕上,您將看到Windows Defender在您的電腦上識別的威脅的完整列表。 如果你的保護...

  • 發佈於 2021-04-02 03:43
  • 閲讀 ( 59 )

Windows3.0已經有30年的歷史了:以下是它的特殊之處

...飛躍。以下是Windows 3.0的特殊之處。 第一個成功的windows版本 在IBM PC相容機的早期,大多數PC機都執行Microsoft MS-DOS,這是一種基於命令列的作業系統,通常一次只能執行一個程式。20世紀80年代初,隨著計算機的發展,“多工處...

  • 發佈於 2021-04-02 04:22
  • 閲讀 ( 53 )

如何在iphone和ipad上使用文字編輯手勢

...果你抓住捲軸並在頁面上下移動它(試試看)。 這就像在舊的Windows電腦上滾動一樣,蘋果只用了13個版本的iOS就能看到曙光。 把手指放在鍵盤上打字 當你可以滑動時為什麼要打字?蘋果iOS的原生鍵盤支援滑動輸入,即手指從...

  • 發佈於 2021-04-03 03:11
  • 閲讀 ( 44 )

如何檢查電腦中的圖形卡(gpu)

...還會在這裡看到“GPU1”等等。每個代表不同的物理GPU。 在舊版本的Windows(如Windows 7)上,可以在DirectX診斷工具中找到此資訊。要開啟它,請按Windows+R,在出現的執行對話方塊中鍵入“dxdiag”,然後按Enter。 單擊“顯示”選項...

  • 發佈於 2021-04-03 14:05
  • 閲讀 ( 47 )
5j17nxxbdh
5j17nxxbdh

0 篇文章

作家榜

  1. admin 0 文章
  2. 孫小欽 0 文章
  3. JVhby0 0 文章
  4. fvpvzrr 0 文章
  5. 0sus8kksc 0 文章
  6. zsfn1903 0 文章
  7. w91395898 0 文章
  8. SuperQueen123 0 文章

相關推薦