Download EE-EmbeddedOperatingSystems-II

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Unix security wikipedia , lookup

PaX wikipedia , lookup

Next-Generation Secure Computing Base wikipedia , lookup

Mobile security wikipedia , lookup

Security-focused operating system wikipedia , lookup

Address space layout randomization wikipedia , lookup

Transcript
Embedded Operating Systems - II
馮立琪
[email protected]
http://os.csie.cgu.edu.tw
長庚大學資訊工程系
計算機系統實驗室
Agenda









A Brief History of Operating Systems
Defining an RTOS
Defining a Task
Task States and Scheduling
Typical Task Operations
The Scheduler
Objects
Services
Introduction Android System
計算機系統實驗室
2
A Brief History of Operating
Systems

In the early days, developers created
software applications that included lowlevel machine code



To initialize and interact with the hardware
Result in no-portable, bug-prone
applications
Operating systems thus provide the
basic software foundation

Facilitate the abstraction of the underlying
hardware from the application code
計算機系統實驗室
3
A Brief History of Operating
Systems (Cont.)

General-purpose operating systems (GPOS)

UNIX



Microsoft Windows


In the 60s and 70s, multi-user access to expensive
mid-sized and mainframe computing system
Eventually, ported to all types of machines
Drive the personal-computing era
Real-time operating systems

For post-PC, embedded-computing era

Android, eCos, ThreadX, VxWork, uClinux…
計算機系統實驗室
4
GPOSes vs. RTOSes

GPOSes



typically require a lot more memory
are not well suited to real-time embedded devices
with limited memory and high performance
requirements
RTOSes


Reliable, compact, scalable, and perform well in
real-time embedded systems
Can be easily tailored to use only those
components required for a particular applications
計算機系統實驗室
5
Defining an RTOS

RTOS is a program that




Schedules execution in a timely manner
Manage system resources
Provide a consistent foundation for
developing application code
A good RTOS should be scalable

To meeting different requirements for
different applications
計算機系統實驗室
6
Defining an RTOS (Cont.)

In some applications, an RTOS comprises only
a kernel


The core supervisory software that provides minimal
logic, scheduling, and resource-management
algorithms.
An RTOS can be a combination of various
modules

Kernel, File system, Networking protocol stacks,
Other components required for a particular
application
計算機系統實驗室
7
High-Level View of an RTOS
計算機系統實驗室
8
RTOS Kernel

Most RTOS kernels contain the following components
 Scheduler


Objects


Algorithms that determine which task executes
 Round-robin, preemptive scheduling
Special kernel construct that helps developer create
applications
 Tasks, semaphores, and message queues
Services


計算機系統實驗室
Operations that the kernel performs on an object
Generally operations such as timing, interrupt handling,
and resource management
9
The Scheduler



At the heart of every kernel
Provides the algorithms to determine which
task executes when
Related topics




Schedulable entities
Multitasking
Context switching
Scheduling algorithms
計算機系統實驗室
10
Schedulable Entities


A kernel object that can compete for
execution time on a system
Task

An independent thread of execution that
contains a sequence of independently
schedulable instructions
計算機系統實驗室
11
Multitasking


The ability of the OS to handle multiple
activities within set deadlines
Many threads of execution appear to be
running concurrently

However, they are actually interleaved
executions sequentially
計算機系統實驗室
12
Multitasking Using a Context
Switch
計算機系統實驗室
13
The Context Switch

Each task has its own context



Context switch


the state of the CPU registers required for tasks’
running
When a task running, its context is highly dynamic
Occurred when a scheduler switches from one
task to another
TCB: Task Control Block


A data structure used by the kernel to maintain
task-specific information
The dynamic context of a task is stored in its TCB
計算機系統實驗室
14
Defining a Task

Task



An independent thread of execution
Compete with other concurrent tasks for
processor execution time
An application can be decomposed into
multiple concurrent tasks
計算機系統實驗室
15
Task

Defined by its set of parameters and
supporting data structures






Associated name
Unique ID
Priority
Task control block
Stack
Task routine
計算機系統實驗室
16
Task States and Scheduling

Ready state


Blocked state




The task is ready to run but cannot because a
higher priority task is executing
Request a resource but is not yet available
Request to wait until some event occurs
Delay itself for some duration
Running state

The task is currently the highest priority task and
is running
計算機系統實驗室
17
A Typical Finite State Machine for
Task Execution States
計算機系統實驗室
18
Typical Task Operations

Kernel must provide task-management
services

The actions that a kernel performs to
support task


Create and maintain the TCB and task stacks
The API that a kernel provides for
developer to manipulate tasks



計算機系統實驗室
Create and delete tasks
Control task scheduling
Obtain task information
19
Scheduling Algorithms


Also called scheduling policy
Two common scheduling algorithms



Preemptive priority-based scheduling
Round-robin scheduling
Developers can create and define their
own scheduling algorithms
計算機系統實驗室
20
Preemptive Priority-Based
Scheduling



Most real-time kernels use preemptive
priority-based scheduling by default
Real-time kernel generally support 256
priority levels
Priority assignment


Static: assign priority to tasks when
created
Dynamic: priority can be changed
dynamically
計算機系統實驗室
21
Preemptive Priority-Based
Scheduling
計算機系統實驗室
22
Round-Robin Scheduling



Provide each task an equal share of the
CPU execution time
Pure RR (Round-Robin) scheduling cannot
satisfy real-time system requirements
Preemptive, priority-based scheduling can
be augmented with round-robin
scheduling

Equal allocation of CPU time for tasks of the
same priority
計算機系統實驗室
23
Android Introduction
馮立琪
[email protected]
http://os.csie.cgu.edu.tw
長庚大學資訊工程系
計算機系統實驗室
24
What is Android?

計算機系統實驗室
Android is a software stack
for mobile devices that
includes an operating system,
middleware and key
applications.
@2010 Mihail L. Sichitiu
25
What is Android




Android is not a single piece of hardware;
it's a complete, end-to-end software
platform that can be adapted to work on
any number of hardware configurations.
Everything is there, from the boot loader to
all the way up to the applications.
Based on the Linux kernel
Allows writing managed code in the Java
language
Developed by Google and later the Open
Handset Alliance (OHA)
計算機系統實驗室
26
OHA (Open Handset Alliance)

A business alliance consisting of 47 companies
to develop open standards for mobile devices
計算機系統實驗室
@2010 Mihail L. Sichitiu
27
Open Handset Alliance (OHA)
計算機系統實驗室
28
Android Architecture
Ref: http://developer.android.com/guide/basics/what-is-android.html
計算機系統實驗室
29
Android S/W Stack Application

Android provides a set of core applications:








Email Client
SMS Program
Calendar
Maps
Browser
Contacts
Etc
All applications are written using the Java language.
計算機系統實驗室
@2010 Mihail L. Sichitiu
30
Android S/W Stack –
App Framework

Enabling and simplifying the reuse of
components


Developers have full access to the same
framework APIs used by the core applications.
Users are allowed to replace components.
計算機系統實驗室
@2010 Mihail L. Sichitiu
31
Android S/W Stack - Libraries
Including a set of C/C++ libraries used by
components of the Android system
 Exposed to developers through the
Android application framework

計算機系統實驗室
@2010 Mihail L. Sichitiu
32
Libraries
•
•
•
•
•
Bionic, a super fast and small GPL-based standard C system library
(libc) optimized for embedded Linux-based devices
Surface Manager for composing window manager with off-screen
buffering 2D and 3D graphics hardware support or software
simulation
Media codecs offer support for major audio/video codecs
SQLite database
WebKit library for fast HTML rendering
計算機系統實驗室
33
Android S/W Stack - Runtime

Core Libraries


Providing most of the functionality available in the
core libraries of the Java language
APIs






Data Structures
Utilities
File Access
Network Access
Graphics
Etc
計算機系統實驗室
@2010 Mihail L. Sichitiu
34
Android S/W Stack – Runtime
(Cont)

Dalvik Virtual Machine

Providing environment on which every
Android application runs



Each Android application runs in its own
process, with its own instance of the Dalvik VM.
Dalvik has been written so that a device can
run multiple VMs efficiently.
Register-based virtual machine
計算機系統實驗室
@2010 Mihail L. Sichitiu
35
Android Runtime
Dalvik :
Dalvik VM is Google’s implementation of Java
 Optimized for mobile devices
 Key Dalvik differences:





Register-based versus stack-based VM
Dalvik runs .dex files
More efficient and compact implementation
Different set of Java libraries than SDK
計算機系統實驗室
36
Android S/W Stack – Linux
Kernel


Relying on Linux Kernel 2.6 for core system services

Memory and Process Management

Network Stack

Driver Model

Security
Providing an abstraction layer between the H/W and the rest of the S
/W stack
計算機系統實驗室
@2010 Mihail L. Sichitiu
37
Network Connectivity

Android supports wireless communications using:








GSM mobile-phone technology
3G
Edge
802.11 Wi-Fi networks
BlueTooth
HTTP : Android has org.apache.http package that has the core
interfaces and classes of the HTTP components.
HTTPS & SSL: Android provides javax.net.ssl package that has
all the classes and interfaces needed to implement and program
the Secure Socket abstraction based on the SSL protocol SSSLv3.0
or TLSv1.2.
XML : Most of Java's XML-related APIs are fully supported on
Android. Java's Simple API for XML (SAX) and the Document
Object Model (DOM) are both available on Android.
計算機系統實驗室
Ref: http://developer.android.com/reference/org/apache/http/package-summary.html
http://developer.android.com/reference/javax/net/ssl/package-summary.html
http://www.ibm.com/developerworks/opensource/library/x-android/index.html
38
Security and Permissions
Security Architecture:

A central design point of the Android security architecture is that no
application, by default, has permission to perform any operations
that would adversely impact other applications, the operating
system, or the user.


An application's process is a secure sandbox. It can't disrupt other
applications.
The permissions required by an application are declared statically in
that application, so they can be known up-front at install time and
will not change after that.
計算機系統實驗室
Ref: http://developer.android.com/guide/topics/security/security.html
39