Operating Systems Concepts For Soc Design
Operating Systems Concepts For Soc Design
Operating Systems Concepts For Soc Design
Chi-Sheng Shih
http://www.csie.ntu.edu.tw/~cshih
Outline
What’s an Operating Systems?
Operating Systems Services
General Operating System Structure
Operating Systems for embedded systems,
real-time systems.
Note: Parts of the materials are supplied courtesy of Prof. Chih-Wen Hsueh. Please
do not distribute the materials without further permission.
What Operating Systems Have You Ever
used?
Courtesy of http://www.wst.nu/statistics/operatingsystems.htm
What is an Operating System?
A program that acts as an intermediary
between a user of a computer and the
computer hardware.
Operating system goals:
Execute user programs and make solving
user problems easier.
Make the computer system convenient to
use.
Use the computer hardware in an
efficient manner.
Computer System Structure
Computer system can be divided into four
components
Hardware – provides basic computing resources
CPU, memory, I/O devices
Operating system
Controls and coordinates use of hardware among various
applications and users
Application programs – define the ways in which the
system resources are used to solve the computing
problems of the users
Word processors, compilers, web browsers, database
systems, video games
Users
People, machines, other computers
Four Components of
a Computer System
Operating System Definition
OS is a resource allocator
Manages all resources
Decides between conflicting requests
for efficient and fair resource use
OS is a control program
Controls execution of programs to
prevent errors and improper use of the
computer
Operating System Definition
(cont.)
No universally accepted definition
“Everything a vendor ships when you
order an operating system” is good
approximation
But varies wildly
“The one program running at all times
on the computer” is the kernel.
Everything else is either a system
program (ships with the operating
system) or an application program
作業系統特徵遷移示意圖
1950 1960 1970 1980 1990 2000
大型電腦 MULTICS
無軟體 編譯器 分時 多使用者 分散式系統
批次 多處理器
常駐監控常式 網路 容錯
UNIX
迷你電腦
無軟體 編譯器
分時 多使用者 多處理器
常駐監控常式 網路 容錯
叢集
UNIX
個人電腦
無軟體 編譯器
交談式 多處理器
多使用者
網路
UNIX
手持式電腦
編譯器 無軟體
交談式
網路
Computer Startup
bootstrap program is loaded at power-up
or reboot
Typically stored in ROM or EPROM, generally
known as firmware
Initializates all aspects of system
Loads operating system kernel and starts
execution
Computer System Organization
Computer-system operation
One or more CPUs, device controllers connect through
common bus providing access to shared memory
Concurrent execution of CPUs and devices competing
for memory cycles
How a Modern Computer
System Works?
instruction
execution
Cache
cycle
interrupt
data
DMA memory
device
(*M)
Operating Systems Services
Objectives
To describe the services an operating
system provides to users, processes, and
other systems
To discuss the various ways of structuring
an operating system
To explain how operating systems are
installed and customized and how they
boot
Operating System Services
One set of operating-system services provides
functions that are helpful to the user:
User interface - Almost all operating systems have a user interface (UI)
Varies between Command-Line (CLI), Graphics User Interface (GUI),
Batch
Program execution - The system must be able to load a program into
memory and to run that program, end execution, either normally or
abnormally (indicating error)
I/O operations - A running program may require I/O, which may
involve a file or an I/O device.
File-system manipulation - The file system is of particular interest.
Obviously, programs need to read and write files and directories,
create and delete them, search them, list file Information, permission
management.
Operating System Services (Cont.)
One set of operating-system services provides
functions that are helpful to the user (Cont):
Communications – Processes may exchange information, on
the same computer or between computers over a network
Communications may be via shared memory or through message
passing (packets moved by the OS)
Error detection – OS needs to be constantly aware of possible
errors
May occur in the CPU and memory hardware, in I/O devices, in
user program
For each type of error, OS should take the appropriate action to
ensure correct and consistent computing
Debugging facilities can greatly enhance the user’s and
programmer’s abilities to efficiently use the system
Operating System Services (Cont.)
Another set of OS functions exists for ensuring the efficient
operation of the system itself via resource sharing
Resource allocation - When multiple users or multiple jobs
running concurrently, resources must be allocated to each of
them
Many types of resources - Some (such as CPU cycles,mainmemory,
and file storage) may have special allocation code, others (such as
I/O devices) may have general request and release code.
Accounting - To keep track of which users use how much and
what kinds of computer resources
Protection and security - The owners of information stored in a
multiuser or networked computer system may want to control use
of that information, concurrent processes should not interfere with
each other
Protection involves ensuring that all access to system resources is
controlled
Security of the system from outsiders requires user authentication,
extends to defending external I/O devices from invalid access
attempts
If a system is to be protected and secure, precautions must be
instituted throughout it. A chain is only as strong as its weakest link.
User Operating System Interface - GUI
Hard Deadline:
Time to press the brake
Time to light up the engine
Soft Deadline:
Time to display the MPEG frame
Time to hand off the wireless connection
Firm Deadline
Time to take a shot
Real-Time scheduling algorithms
We use real-time scheduling algorithms every
day.
Dynamic priority scheduling algorithms
How do you plan your days to do the homework and exams?
Earliest Deadline First algorithm [Liu and Layland 1973]
Static priority scheduling algorithms
Do you prioritize your works?
Rate-Monotonic algorithm [Liu and Layland 1973]
The algorithms should schedule the tasks to
meeting the requirements.
Real-time Systems
The distinction between systems can obviously
become fuzzy.
At one end of the software spectrum are non-real-time
systems where all deadlines can be missed.
At the other end are hard real-time systems where
every deadline must be met.
Operating Systems
Embedded Systems Real-Time Systems
A/ROSE Nucleus
Inferno (distributed OS originally from On Time
Bell Labs)
ROM-DOS OS-9 by Microware
Embedded Linux OSEK
Rockbox (Free Software operating Phoenix-RTOS
system for music player devices)
Minix version 3
QNX
Windows XP Embedded RTAI
Windows CE RTEMS
.NET Micro Framework RTKE by Philips
Operating System Embedded (OSE) RTLinux
Real-Time Systems Salvo
ChorusOS ThreadX
eCos TRON (also ITRON, BTRON,
embOS (Segger) CTRON, MTRON, etc.)
FreeRTOS µCLinux
Inferno (distributed OS originally VRTX
from Bell Labs) VxWorks by Wind River Systems
INTEGRITY XMK (eXtreme Minimal Kernel)
LUnix written in 6502 Xenomai
LynxOS and many more
MenuetOS
MontaVista Linux
What Is eCos ?
Stands for “Embedded Configurable Operating
System”
Developed and maintained by RedHat.
eCos features:
Not Linux-based
Minimum footprint: about 50KB
Single address space
Real-time support
Support ROMFS, RAMFS and JFFS2
SMP support
eCos History
1996 Cygnus started eCos project.
1998 eCos 1.1 released (first public release.)
1999 Red Hat acquired Cygnus Solutions.
2000 eCos 1.3.1 released under Red Hat eCos
Public License.
2000 Red Hat announce the availability of
Redboot
2002 eCos 2.0-alpha released under GPL+
exception.
2002 original members of eCos team formed
eCosCentric Limited in Cambridge.
eCos History
2002 Red Hat announced their withdrawal
from RTOS market, laid off entire eCos
team.
2003 eCos 2.0-final was released.
2003 eCosCentric announced eCosPro
Developer‘s Kit.
2004 Red Hat announce intention to
assign copy right of the portions of the
original source base to FSF.
eCos Architecture
Applications
Libraries Compatibility
Math C POSIX µITRON
RedBoot
RedBoot Hardware Abstract Layer (HAL) Device Drivers
ROM
ROM interrupt exception flas seria networkin
monitor
monitor vectors
s s h l g
Target Hardware
eCos Core Component
z HAL: a software layer that gives general access
to the hardware.
z Kernel: interrupt and exception handling, thread
and synchronization support, scheduler
implementation, timer, counter and alarm.
z ISO C and Math libraries: Standard compatibility
with function calls
z Device driver: Serial, Ethernet, Flash ROM etc.
z GDB support: provides target software for
communicating with a GDB host.
Kernel Benchmark
Timing benchmarks generated on the Model 4205
MPC7455/57 processor board running at 600 MHz
and configured with a 2 Mbyte L3 cache:
Operating Security
Commands
POSIX.2c IEEE 1003.2c
Installing eCos
Under cygwin bash shell:
wget --passive-ftp ftp://ecos.sourceware.org/pub/ecos/ecos-install.tcl
Select GNU tools for target
Architecture TARGET
ARM (including StrongARM, XScale) arm-elf
Intel x86 i386-elf
MIPS32 mipsisa32-elf
PowerPC powerpc-eabi
Renesas SuperH sh-elf
History of µC/OS
Started by Jean Labrosse in
early 1990’s
The first paper for µC/OS II was
published on Embedded Systems
Programming (ESP) in May and
June 1992.
25,000 copies has been sold for
the first and second edition.
Source codes are freely available.
Advantages and Disadvantages of
Real-Time Kernels
A real-time kernel (RTOS) allows real-time applications to be designed and
expanded easily.
Functions can be added without requiring major changes to the software.
The use of RTOS simplifies the design process by splitting the application
code into separate tasks.
Interrupt latency +
Interrupt response
Int. latency + Save CPU’
CPU’s context Int. latency + Save CPU’
CPU’s context Save CPU’
CPU’s context +
(Time)
Kernel ISR entry function
Longest task +
Task response Find highest priority task +
Background Find highest priority task +
(Time) Context switch
Context switch
Application code + Application code +
ROM size Application code
Kernel code Kernel code
z No virtual memory.
Applications
Linux, RTLinux, and RTAI
Linux RTLinux RTAI
Alpha, ARM, i386, MIPS, PowerPC, i386, PPC, ARM, Alpha, i386, MIPS, PPC, ARM,
Hardware Sparc,
Sparc, SuperH,
SuperH, Etrax,
Etrax, m68k, PA-
PA-RISC MIPS m68k-
m68k-nommu
UNIX-
UNIX-processes &
Processes Pthreads Lightweight processes
Pthreads
Priorities
(0-
(0-100) (0-
(0-1,000,000) 0x3fffFfff-
0x3fffFfff-0)
lower - higher