Upload
others
View
2
Download
0
Embed Size (px)
Citation preview
CSE 237ACSE 237A Middleware and Operating Systems
Tajana Simunic RosingDepartment of Computer Science and EngineeringUniversity of California, San Diego.
1
Soft are componentsSoftware componentsStandard softwareStandard software
e.g. MPEGx, databasesMiddlMiddlewareOperating systems
schedulers
2TSR
Middle areMiddlewareBetween applications and OSBetween applications and OSProvides a set of higher-level capabilities and interfacesinterfacesCustomizable, composeable frameworksTypes of services:yp
component – independent of other servicesE.g. communication, information, computation
integrated setsintegrated setse.g. distributed computation environment
integration frameworks
3TSR
Tailor to specific domain: e.g. transaction processing
Integrated setsIntegrated setsA t f i th t t k i ifi tA set of services that take significant advantage of each otherExample: Distributed Computing Environment (DCE)
Provides key distributed technologies – RPC, DNS, distributed file system, time synch,
t k it d th d inetwork security and threads serviceFrom Open SW Foundation, supported by
lti l hit t d j SW d4TSR
multiple architectures and major SW vendors
DCEDCE
5TSR
I t ti f k iddlIntegration frameworks middleware
I t ti i t t il d tIntegration environments tailored to specific domainExamples:
Workgroup frameworkTransaction processing frameworkNetwork management frameworkDistributed object computing (e.g. CORBA, E-SPEAK, JINI, message passing)
6TSR
Distrib ted Object Comp tingDistributed Object ComputingAdvantages:Advantages:
SW reusability, more abstract programming, easier coordination among services
Issues:Issues:latency, partial failure, synchronization, complexity
Techniques:Message passing (object knows about network)Argument/Return Passing – like RPC
network data = args + return result + namesSerialzing and sending
network data = obj code + obj state + synch infoShared memory
7TSR
network data = data touched + synch info
SW for access to remote objectsSW for access to remote objectsCORBA (Common Object Request Broker Architecture).Information sent to Object Request Broker (ORB) via local stubInformation sent to Object Request Broker (ORB) via local stub. ORB determines location to be accessed and sends information via the IIOP I/O protocol.
8TSRAccess times not predictable.OBJ management architecture
Real time CORBAReal-time CORBAEnd-to-end predictability of timeliness in a
fixed priority system.respecting thread priorities between client p g p
and server for resolving resource contention,bounding the latencies of operationbounding the latencies of operation
invocations.RT CORBA includes provisions forRT-CORBA includes provisions for
bounding the time during which priority inversion due to competing resource access
9TSR
inversion due to competing resource access may occur.
Message passing interfaceMessage passing interface
Message passing interface (MPI): alternative to CORBAMPI/RT l ti i f MPI [MPI/RTMPI/RT: a real-time version of MPI [MPI/RT forum, 2001].MPI RT does not cover issues such as threadMPI-RT does not cover issues such as thread creation and termination.MPI/RT is conceived as a layer between theMPI/RT is conceived as a layer between the operating system and non real-time MPI.
10TSR
Soft are componentsSoftware componentsStandard softwareStandard software
e.g. MPEGx, databasesMiddlMiddlewareOperating systems
Focus on RTOS
11TSR
Real-time operating systemsReal-time operating systems
Th k i tThree key requirements1. Predictable OS timing behavior
upper bound on the execution time of OS servicesupper bound on the execution time of OS servicesshort times during which interrupts are disabled,contiguous files to avoid unpredictable head movementsmovements
2. OS must be fast 3. OS must manage the timing and scheduling
OS possibly has to be aware of task deadlines;OS possibly has to be aware of task deadlines;(unless scheduling is done off-line).OS must provide precise time services with high resolution
12TSR
resolution.
RTOS-KernelsRTOS-KernelsDistinction between real-time kernels and modified kernels of standard OSeskernels of standard OSes.
Distinction betweenl d RTOS f ifi d igeneral and RTOSes for specific domains,
standard APIs (e.g. POSIX RT-Extension of Unix) or proprietary APIs
13TSR
or proprietary APIs.
Ho to organi e m ltiple tasks?How to organize multiple tasks?C clic e ec ti e (Static table dri en sched ling)Cyclic executive (Static table driven scheduling)
static schedulability analysisresulting schedule or table used at run timeg
Event-driven non-preemptivetasks are represented by functions that are handlers for eventsnext event processed after function for previous event finishes
Static and dynamic priority preemptive schedulingstatic schedulability analysisstatic schedulability analysisat run time tasks are executed “highest priority first”Rate monotonic, deadline monotonic, earliest deadline first, least l k
14TSR
slack
RTOS Organization: gCyclic Executive
Application Application Application
I/O S i
pp pp pp
Kernel Mode
Device Drivers
Network Drivers
I/O Services
TCP/IPTCP/IP Stack
15TSR
Hardware
RTOS Organization: gMonolithic Kernel
Application Application Application
User Mode(protected)
Kernel ModeFilesystems I/O Managers Graphics
SubsystemDevice Drivers
Network Drivers
SubsystemGraphics Drivers Other….
16TSR HardwareHardware Interface Layer
RTOS Organization: gMicrokernel
Network Drivers H
a
Network Manager
ard
Graphics Drivers
Application
ApplicationPhoton
Device Drivers
war
Fil t
Application
Fil t
Device Manager
User Mode(protected)
eFilesystem Manager
Filesystem Drivers
17TSRKernel Mode Kernel (tiny)
Types of RTOS Kernelsyp1. Fast proprietary kernels
designed to be fast, rather than predictableInadequate for complex systemsInadequate for complex systemsExamples include
QNX, PDOS, VCOS, VTRX32, VxWORKS.
18TSR
E ample V WorksExample: VxWorks
19TSR© Windriver
V Works Config rationVxWorks Configuration
_ds.
rnad
o2/to
rnad
o_2_
men
t_to
ols/
ide/
tor
/pro
duct
s/de
velo
pmw
w.w
indr
iver
.com
/
20TSR © Windriver
http
://w
w
Types of RTOS KernelsTypes of RTOS Kernels2. Standard OS with real-time extensions
RT k l i ll RT t kRT-kernel running all RT-tasks.Standard-OS executed as one task.
+ Crash of standard-OS does not affect RT-tasks;- RT-tasks cannot use Standard-OS services;
21TSR
less comfortable than expected
E ample RT LinExample: RT-LinuxInit Bash Mozilla
scheduler
RT-Task RT-TaskLinux-Kernel
driver
RT-Linux RT-Schedulerinterrupts
interrupts
Hardware
RT Linuxinterrupts
interruptsI/O
22TSR
Hardware
E ample Posi 1 b RTExample: Posix 1.b RTStandard scheduler can be replaced by POSIXStandard scheduler can be replaced by POSIX scheduler implementing priorities for RT tasks
S i l RT &Init Bash MozillaRT-Task RT-Task
Special RT & standard OS calls available
Linux KernelPOSIX 1.b scheduler
calls available.Easy programmingLinux-Kernel
driver
/O
programming, no guarantee for meeting
23TSRHardware
I/O, interrupts g
deadline
Types of RTOS KernelsTypes of RTOS Kernels3. Research systems
Research issueslow overhead memory protection,low overhead memory protection,temporal protection of computing resources RTOSes for on-chip multiprocessorssupport for continuous mediaquality of service (QoS) control.
24TSR
Kernel e amplesKernel examplesS ll k lSmall kernels
PALOS, TinyOSMedium size
uCos II, eCosLarger
RT Linux, WinCERT Linux, WinCE
25TSR
E ample I PALOSExample I: PALOSStructure – PALOS Core, Drivers, Managers, and user defined TasksPALOS Core
Task control: slowing, stopping, resumingPeriodic and aperiodic handling and schedulingInter-task Communication via event queuesEvent-driven tasks: task routine processes events stored in event queues p q
DriversProcessor-specific: UART, SPI, Timers.. Platform-specific: Radio, LEDs, Sensors
Small FootprintSmall Footprint Core (compiled for ATMega128L) Code Size: 956 Bytes , Mem Size: 548 BytesTypical( 3 drivers, 3 user tasks) Code Size: 8 Kbytes, Mem Size: 1.3 Kbytes
Task 1
PALOSCore TA
SK 1
K 2
TASK
5
TASK
N
K 3
TASK 4 Task 2 Task 3
PALOS
26TSR Drivers (Hardware Abstraction Layer)
Manager
T
TAS
TAS
Task 3 Event Q
PALOSCore
Execution control in PALOSExecution control in PALOSEach task has a task counterCounters initialized to:
0: normal>>:0 slowdown-1: stop>=0: restart
D t d
TASK 1
TASK 2
Task Routine
Event Q
Task Routine
Event QMain
Control Decremented 1) every iteration
(relative timing) 2) by timer interrupts
PALOSTaskTable
TASK 3
Event Q
Task Routine
Event Q
ControlLoop
2) by timer interrupts (exact timing)
If counter = 0, call taks; reset counter to
TASK NTask Routine
Event Q
27TSR
reset counter to initialization value
E ent Handlers in PALOSEvent Handlers in PALOS
Periodic or Handler 1
Handler 2
Handler 3
aperiodic events can be scheduled using Delta Q andTask 2
Task 1
TimerTask using Delta Q and
Timer InterruptWhen event expires Expired Event Q
Task
appropriate event handler is called
Delta Q
Timer PALOS
28TSR
TimerInterrupt
PALOSCore
Example II: TinyOSExample II: TinyOSSystem composed of
scheduler, graph of components, execution contextComponent modelComponent model
Basically FSMsFour interrelated parts of implementation
Encapsulated fixed-size frame (storage)A set of command & event handlersA b dl f i l t k ( t ti )A bundle of simple tasks (computation)
Modular interfaceCommands it uses and acceptsEvents it signals and handles
Tasks, commands, and event handlersExecute in context of the frame & operate on its stateCommands are non-blocking requests to lower level componentsEvent handlers deal with hardware eventsTasks perform primary work, but can be preempted by p p y p p yevents
Scheduling and storage modelShared stack, static framesEvents prempt tasks, tasks do notEvents can signal events or call commands
Messaging Component
Internal StateInternal Tasks
29TSR
Events can signal events or call commandsCommands don’t signal eventsEither can post tasks
Commands Events
Tin OS O er ieTinyOS OverviewStylized programming model with extensive static informationy p g g
Compile time memory allocationEasy migration across h/w -s/w boundarySmall Software Footprint - 3.4 KB T l l h d li t tTwo level scheduling structure
Preemptive scheduling of event handlersNon-preemptive FIFO scheduling of tasksBounded size scheduling data structureBounded size scheduling data structure
Rich and Efficient Concurrency SupportEvents propagate across many componentsTasks provide internal concurrency
C fPower Consumption on Rene PlatformTransmission Cost: 1 µJ/bitInactive State: 5 µAPeak Load: 20 mA
30TSR
Peak Load: 20 mAEfficient Modularity - events propagate through stack <40 µS
Complete Tin OS ApplicationComplete TinyOS Application
31TSR Ref: from Hill, Szewczyk et. al., ASPLOS 2000
E ample III COS IIExample III: µCOS-IIPortable ROMable scalable preemptivePortable, ROMable, scalable, preemptive, multitasking RTOSServicesServices
Semaphores, event flags, mailboxes, message queues, task management, fixed-size memory block management time managementmanagement, time management
Source freely available for academic non-commercial usage for many platformsg y p
Value added products such as GUI, TCP/IP stack etc.
32TSR
E ample IV eCosExample IV: eCosEmbedded, Configurable OS, Open-sourceSeveral scheduling options
bit-map scheduler, lottery scheduler, multi-level schedulerThree-level processingThree-level processing
Hardware interrupt (ISR), software interrupt (DSR), threadsInter-thread communication
Mutex, semaphores, condition variables, flags, message boxPortable - Hardware Abstraction Layer (HAL)Based on configurable componentsBased on configurable components
Package based configuration toolKernel size from 32 KB to 32 MB
33TSR
Implements ITRON standard for embedded systemsOS-neutral POSIX compliant EL/IX API
E ample V Real time LinExample V: Real-time LinuxMicrocontroller (no MMU) OSes:( )
uClinux - small-footprint Linux (< 512KB kernel) with full TCP/IP
Q S t i f d ktQoS extensions for desktop:Linux-SRT and QLinux
soft real-time kernel extensiontarget: media applications
Embedded PCRTLi RTAIRTLinux, RTAI
hard real time OSE.g. RTLinux has Linux kernel as the lowest priority task in a RTOS
34TSR
fully compatible with GNU/LinuxHardHat Linux
E ample VI WinCEExample VI: WinCEApplications
Embedded shellRemote connectivity
Applications
Win32 APIs
WinCE shell servicesy
Kernellibrary GWES Device
managerFile
manager IrDA TCP/IP
OEM h d
OALbootload drivers Device
driversFile
driversNetworkdrivers
35TSR
OEM hardware
Virt al memorVirtual memoryWinCE ses irt al memorWinCE uses virtual memory.Code can be paged from ROM, etc.Wi CE t fl t 32 bit i t l ddWinCE suports a flat 32-bit virtual address space.Vi t l dd bVirtual address may be:
Statically mapped (kernel-mode code).Dynamically mapped (user mode and some kernelDynamically mapped (user-mode and some kernel-mode code).
Address space: bottom half user, top kernel
36TSR
p , p
Dri er str ct reDriver structureDriver = DLL with particular interface pointsDriver = DLL with particular interface points.Hosted by a device manager process space H dl i t t b d di t d IST th dHandle interrupts by dedicated IST thread.Synchronize driver and application via critical
ti d MUTEXsections and MUTEXes.
37TSR
De ice managerDevice managerAlways running user level processAlways-running user-level process.Contains the I/O Resource Manager.Loads the registry enumerator DLL which in turnLoads the registry enumerator DLL which in turn loads drivers.
RegEnum scans registry, loads bus drivers.Bus driver scans bus, locates devices.Searches registry for device information.Loads appropriate driversLoads appropriate drivers.Sends notification that interface is available.
Provides power notification callbacks.
38TSR
Provides power notification callbacks.
Interr pt handlingInterrupt handlingInterrupt service routine (ISR):Interrupt service routine (ISR):
Kernel mode service.May be static or installable.
Interrupt service thread (IST):Interrupt service thread (IST):User mode thread.
IST processing
ISR ISR
ISR ISR
ISH Set event Enable ID
39TSR
All higherenabled
All enabledExcept ID All enableddevice
Kernel sched lerKernel schedulerTwo styles of preemptive multitaskingTwo styles of preemptive multitasking.
Thread runs until end of quantum.Thread runs until higher priority thread is ready to run.g p y y
Round-robin within priority level.Quantum is defined by OEM and application.yPriority inheritance to control priority inversion.256 total priorities.
Top 248 can be protected by the OEM.
40TSR
S mmarSummarySWSW
MPEG decode etc.Middleweare
E.g DCE, CORBARTOS
E.g TinyOS, eCos, RT-Linux, WinCEE.g TinyOS, eCos, RT Linux, WinCE
41TSR
Sources and References
Peter Marwedel, “Embedded Systems D i ” 2004Design,” 2004.Wayne Wolf, “Computers as Components,” Morgan Kaufmann, 2001. Nikil Dutt @ UCI@Mani Srivastava @ UCLA
42TSR