Sie sind auf Seite 1von 5

Operating System

Chapter 1 Introduction
1.1 What operating System Do
A computer system can be divided roughly into four components
1. hardware
2. operating system
3. application program
4. users
Hardware: CPU, memory, I/O device
Operating system provides an environment for other programs

User view:
PC is designed for ease of use, with some attention paid to performance
and none
paid to resource utilization

Resource utilization: how various hardware and software resources are


Mainframe is designed to maximize resource utilization

Workstation compromise usability and resource utilization

Some embedded systems are not designed with user views.

System View:
Resource allocator: CPU time, memory space, file-storage space, I/O

Control program: control I/O devices and user programs preventing

errors and improper use

middleware: a set of software frameworks that provide additional services to

application developers

operating systems usually refers to the kernel (or including system programs)

1.2 Computer-System Organization

A modern general-purpose computer system consists of
one or more CPUs

a number of device controllers connected through a common bus that

provides access
to shared memory

CPU and the device controllers can execute in parallel competing for
memory cycles

To ensure orderly access to the shared memory, a memory controller

synchronizes access to the memory

When startup or reboot, bootstrap program initialize CPU registers,

device controllers, memory contents, etc.
and load the operating system and execute it.

bootstrap program typically stored in read-only memory (ROM) or

eletrically erasable programmable read-only memory (EEPROM)
, known as "firmware"
Once the kernel is loading and executing, some services are provided
outside of the kernel
system programs that are loaded into memory at boot time to become
system processes or system daemons

The occurrence of an event is usually signaled by an interrupt from

either the hardware or the software
(interrupt request)hardware trigger an interrupt by sending a
signal to the CPU by way of the system bus
software trigger an interrupt by executing a system call (also
called monitor call)

Interrupts are similar to signals, the difference being that signals

are used for IPC, mediated by the kernel
(possibly via system calls) and handled by processes, while interrupts
are mediated by the processor and handled by the kernel.
The kernel may pass an interrupt as a signal to the process that caused

interrupt vector: addresses of the interrupt service routines for the

various devices

The CPU can only load instructions only from memory, so any programs to run
must be stored there
main memory (random-access memory, RAM) - implemented in a semiconductor
technology called dynamic random-access memory (DRAM)

smartphones store their factory-installed program in EEPROM

von Neumann architecture

fetch an instruction from memory and stores that instruction in the
instruction registers
The instructoin is decoded and may cause operands to be fetched from
memory and store in
some internal registers
the result is store back to memory

secondary storage: typically magnetic disk

solid-state disks: have several variant

ex1: RAM + magnestic disk
ex2: flash memory

Depending on the I/O controller, more than one devices can be attached

A device controller maintains some local buffer storage and a set of special-
purpose registers
typically, operating system has a device driver for each device controller

interrupt-driven I/O is fine for moving small amounts of data

large data use direct memory access (DMA)

1.3 Computer-System Architecture

graceful degradation, fault tolerant
asymmetric multiprocessing: boss-worker relationship
symmetric multiprocessing (SMP)

uniform memory access (UMA)

non-uniform memory access (NUMA)

blade servers

clustered systems: typically linked by LAN, loosely coupled

provide high-availability services: service will continue even if one or more
systems in the cluster fail

asymmetric clustering: hot-standby modern

symmetric clustering

distributed lock manager (DLM)

storage area networks (SANs)

1.4 Operating System Structure

Multiprogramming: The operating system keeps several jobs in memory
simultaneously. Since, in general, main memory
is too small to accommodate all jobs, the jobs are kept initially on the disk
in the job pool. This pool consists of
all processes residing on disk awaiting allocation of main memory. => CPU
switches job when the job is waiting for
some operation, e.g. I/O operation.

Time sharing (or Multitasking) is a logical extension of multiprogramming:

switch jobs so frequently so the response time
for the users is short enough

A program loaded into memory and executing is call a process

job scheduling: select jobs from job pool if no enough memory for them all

Having several programs in memory requires memory management.

CPU scheduling: choose which job to run first.

swapping and virtual memory can be used to achieve reasonable response time

virtual memory techniques: allow the execution of a process that is not

completely in memory

virtual memory abstracts main memory into a large, uniform array of storage,
separation logical memory as
viewed by the user from physical memory.

file system relies on disk management

job synchronization and communication: ensure orderly execution, prevent dead


1.5 Operating-System Operations

A trap (or execution) is a software-generated interrupt caused either by an
error (e.g. division by zero or invalid memory access)
or by specific request from a user program that an operating system service
be performed.

A well-designed operating system should prevent an incorrect program cannot

cause other programs to execute incorrectly.
hardware support to allow to differentiate various modes of execution, e.g.
operating system code and user defined code.

user mode vs kernel model(supervisor mode, system mode, privileged mode)

mode bit is added to the hardware of the computer to indicate the current
mode: kernel(0), user(1) -- other methods also possible

privileged instructions: some of the machine instructions that my cause harm,

only allowed to be executed in kernel mode

virtual machine manager (VMM): more privileged than users and less than

trap instruction or syscall in MIPS to invoke system call

When a system call is executed, it is typically treated by the hardware as a

software interrupt. Control passes through
the interrupt vector to a service routine in the operating system, and the
mode bit is set to kernel mode.

MS-DOS is written for 8088 architecture, which has no mode bit

when a program error occurs, operating system stop it abnormally. An

appropriate error message is given and the memory of the program
may be dumped

timer: to disable a user to program to get stuck and not return to OS,
usually implemented by a fixed-rate clock and a counter

1.6 Process Management

A single-threaded process has one program counter specifying the next
instruction to execute
A multithreaded process has multiple program counters, each pointing to the
next instruction to execute for a given thread

1.7 Memory Management

The central processor reads instructions from main memory during the
instruction-fetch cycle and both reads and writes
data from main memory during the data-fetch cycle.

1.8 Disk Management

Free-space management
Storage allocation
Disk scheduling

cache management: cache size, replacement policy affects performance
cache coherency: generally a hardware issue

I/O subsystem
A memory-management component that includes buffering, caching, and
A general device-driver interface
Drivers for specific hardware devices

1.9 Protection and Security

1.10 Kernel Data Structures

List, Stack, Queue, Hash
Bitmaps can be used to indicate available disk blocks

1.11 Computing Environments

network computers
metropolitan-area network (MAN)
personal-area network (PAN)
network operating system
discovery protocol to support P2P broadcasting strategy
Skype use VoIP, hybrid P2P

Public cloud, private cloud, hybrid cloud

Software as a service (SaaS), Platform as a service (PaaS), Infrastructure as
a service (IaaS)

Application-specific integrated circuits (ASICs)

Real-time operating system

1.12 Open-Source Operating Systems

Chapter 2 System Structures

2.1 Operating-System Services
User interface(UI)
command-line interface (CLI)
batch interface
graphical user interface (GUI)
Program execution
I/O operations
File-system manipulation
Error detection
Resource allocation
Protection and security

2.3 System calls

2.4 Type of System Calls
Process control
file manipulation
device manipulation
information maintenance