Professional Documents
Culture Documents
3-1
補充
3-3
補充
• In a single-processor computer,
only one CPU to be shared by all programs
3-7
Chairperson Can Do More 補充
Chairperson is OS
3-8
What Is a System? 補充
• Five components
– Hardware User
– Software Procedure
Software
– Data System
– Procedure
Data Hardware
– User
3-9
Operating Systems
• Provide an environment
in which a user can execute programs
• Goals
– Make the computer system convenient to use
– Use the computer hardware (resources)
in an efficient manner
3-10
Operating Systems
• One kind of software that
controls the overall operation of a computer
– Unix
– Linux: Ubuntu, Redhat, ...
– Sun Solaris (Sun/Oracle machines)
– Apple Mac OS
– MS DOS, Microsoft Windows
3-11
Smartphone Operating Systems
• Apple iOS
• Windows Phone
• BlackBerry OS
• Nokia Symbian OS
• Google Android
3-12
Functions of Operating Systems
3-14
3.1 THE HISTORY OF
OPERATING SYSTEMS
3-15
History of Operating Systems
3-16
Evolution of Shared Computing (1)
• Batch processing (批次處理) (job queue)
– 它是先把工作及資料收集成一批,然後執行它們。
– 存在大量儲存設備中的工作,在一個工作佇列(job queue)中等待被執行。
• Time-sharing (one machine, many users) / Multitasking (one user, many tasks)
– Implemented by Multiprogramming (多重程式)
• Time is divided into intervals and then the execution of each job is restricted to only
one interval at a time.
• Shuffle jobs by dividing time into intervals
– Efficient than the sequential way
especially for jobs which must wait for peripheral devices
– Multitasking (多工) for a one-user system vs Time-sharing for multiple users
• Multiprocessor machines (load balancing)
– Sharing information and resources among different machines
– Load balancing, scaling
3-17
Evolution of Shared Computing (2)
• Networking
– 透多網路上多台機器來處理多個⼯作
• …
3-18
Figure 3.1 Batch processing
3-21
Types of Software
• Application software
– Performs specific tasks for users
(productivity, games, software development)
• System software
– Provides infrastructure for application software
– Consists of operating system
and utility software (公⽤軟體)
– Basis is not absolute,
e.g., Networking function was not utility before, but is now .
e.g., IE (Internet explorer), media player lawsuits.
3-22
Figure 3.3 Software classification
0-23
Figure 3.4 The user interface act as an
intermediary between users and the
operating system kernel
3-24
Operating System Components (1)
• User Interface: Portion of an OS to define the interface
between the OS and its users
– Communicates with users
– Types of user interface
• Text based (Shell;外殼)
– e.g., Borne shell, C shell, Korn shell in Unix; MS-DOS for Microsoft
Windows
• Graphical user interface (GUI)
– e.g., Windows 10, Mac
– Window manager
– Often called WIMP (Windows, Icons, Menus, and Pointers)
– In the sell with GUI, one crucial component is the window manager,
whose job is to manage the placement of a window on the screen,
and to record the applications that are executed for each opened
window
3-25
Operating System Components (2)
• Kernel (核⼼)
– Performs basic required functions
– Main components
• File manager (檔案管理者)
• Device drivers (裝置驅動程式)
• Memory manager (記憶體管理者)
• Scheduler (排程程式) and dispatcher (時段分配程式)
3-26
File Manager
• File manager: coordinate the use of the
machine’s mass storage facilities
– Directory (or Folder): A user-created bundle of files
and other directories (subdirectories)
– Directory Path: A sequence of directories within
directories
– File descriptor: Information needed to find and
manipulate the file, e.g., file name, extension, size,
updated date, permissions, attributes, …
3-27
Device driver
• Device drivers
– Communicate with the controllers (or at times,
directly with peripheral devices) to carry out
operations on the peripheral devices attached
to the machine
3-28
Memory Manager
• Memory Manager
– Allocates space in main memory
– What if the program is larger than the memory?
virtual memory (虛擬記憶體)
• create the illusion that
the machine has more memory than it actually does
by playing a “shell game”
in which blocks of data (pages) are shifted back and forth
between main memory and mass storage
• Paging: memory is grouped into pages
to facilitate the mapping and shuffling
3-29
Example of Paging
3-30
Getting it Started (Bootstrapping; 啟動)
3-31
Figure 3.5 The booting process
3-32
BIOS and Firmware
3-33
3.3 COORDINATING THE
MACHINE’S ACTIVITIES
3-34
Coordinating the Machine’s Activities
• An operating system
coordinates the execution of
application software,
utility software, and
units within the operating system itself.
3-35
Processes
• Process (程序):
The activity of executing a program
3-36
Process Administration
• Scheduler (排程程式):
– Adds new processes to the process table
• Ready state: The progress of the process can continue
• Waiting state: Its progress is currently delayed until some external
event occurs
– and removes completed processes from the process table
• Dispatcher (時段分配程式):
Controls the allocation of time slices to the processes
in the process table
– The end of a time slice is signaled by an interrupt.
3-37
Figure 3.6 Time-sharing between
process A and process B
• Ans.
– User interface: Communications with the machine’s environment
– File manager: Coordinates the use of the machine’s mass
storage
– Device drivers: Handle communication with the machine’s
peripheral devices
– Memory manager: Coordinates the use of the machine’s main
memory
– Scheduler: Coordinates the processes in the system.
– Dispatcher: Controls the assignment of processes to CPU time
3-39
3.4 HANDLING COMPETITION
AMONG PROCESSES
3-40
Handling Competition for Resources
• Flag (旗標) = set (1) or clear (0)
– 為控制⼀機器或其周邊(e.g., 印表機)的使⽤分配,
OS須⽤⼀個旗標(flag)隨時記錄此機器是否已被分配使⽤
– 先⽤test指令查flag狀態,若為clear,則⽤ set指令設定flag
不同程序可能會競爭兩個指令
– Test-and-set instruction: 結合test和set為單⼀指令
– Semaphore (信號): A properly implemented flag
• The railroad signals used to control access to sections of track.
• Removing deadlock
– Techniques that attack the 3rd condition fall into the category known
as deadlock detection and correction schemes
– Techniques that attack the first two conditions are known as deadlock
avoidance schemes
• Converting non-shareable resources into shareable ones
• Requiring each process to request all the resources at one time
3-42
Figure 3.7 A deadlock resulting from
competition for nonshareable railroad
intersections
3-43
Exercise
• Ans.
– (a) This guarantees that the non-shareable resource is not
required and allocated on a partial basis (condition 2)
– (b) This means that the non-shareable resource can be forcibly
retrieved (condition 3)
– (c) This makes the non-shareable resource shareable, which
removes the competition (condition 1)
3-44