Skip to Content
LINUX系統程式設計 第二版
book

LINUX系統程式設計 第二版

by Robert Love
December 2013
Intermediate to advanced
496 pages
8h 57m
Chinese
GoTop Information, Inc.
Content preview from LINUX系統程式設計 第二版
190
|
第六章
單處理器(single-processor)機器上,
多任務
multitasking
)作業系統可以交錯執
行一個以上的行程,這會給人一個錯覺,彷彿有多個行程同時運行一般。多處理器
multiprocessor)機器上,多任務作業系統允許多個行程實際地在不同的處理器上同時
運行。非多任務的作業系統,例如 DOS,同一時間只能執行一個應用程式。
多任務作業系統又分成兩類:
協同式
cooperative
)以及
先佔式
preemptive
)。 Linux
所實作的是先佔式多任務機制,在此多任務機制中,排班器會決定何時可以中止一個行
程的運行,好讓不同的行程得以繼續運行。我們會把「暫停一個運行中的行程而讓另一
個行程繼續運行」的行為稱為搶先佔用或簡稱
先佔
preemption
)。在排班器先佔一個行
程之前,該行程所能運行的時間長短,稱為處理器的
時段
timeslice
);之所以稱為時
段,是因為排班器會把處理器的每個時間片段(slice)分配給每個可運行的行程。
反過來說,在協同多任務機制中,一個行程不會中止運行,除非該行程自願這麼做。我
們把「一個行程自願暫停自己」的行為,稱為
讓出
yielding
CPU。理想上,行程會經
常讓出 CPU,但是作業系統並不會強迫行程這麼做。一個粗略或不完整的程式可能會執
行比較久的時間,使得多任務機制失去效用,或甚至是拖累整個系統。由於此做法有缺
點,所以現代的作業系統幾乎普遍地採用先佔式多任務的做法;Linux 也不例外。
這些年來 Linux 的行程排班器已有所改變。當前的行程 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

AGILE學習手冊 | SCRUM、XP、精實和看板方法

AGILE學習手冊 | SCRUM、XP、精實和看板方法

Andrew Stellman, Jennifer Greene
管理Kubernetes

管理Kubernetes

Brendan Burns, Craig Tracey
算法技术手册(原书第2 版)

算法技术手册(原书第2 版)

George T.Heineman, Gary Pollice, Stanley Selkow

Publisher Resources

ISBN: 9789862769812