Sei sulla pagina 1di 6

David L.

Levine Real-Time Operating Systems/Linux

Overview
Real-Time Operating Systems/Linux  Motivation and context

 The role of the OS


David L. Levine
Washington University, St. Louis
levine@cs.wustl.edu  Limitations of conventions OS’s

26 April 2000  Real-time OS’s (RTOS’s)

http://www.cs.wustl.edu/˜levine/courses/cs422/rtos.ps.gz  Performance comparisons of conventional and RT OS’s


Copyright c 1997-2000 Dept. of Computer Science, Washington University 1

David L. Levine Real-Time Operating Systems/Linux David L. Levine Real-Time Operating Systems/Linux

Motivation for OS and Middleware What is the OS Role?


 Provides services used by applications (and middleware)
 OS Role
– Reuse at a fundamental level
APPLICATIONS – OS provides resource – The services are difficult to write, esp. for correctness, efficiency,
COMMON EVENT Cons Cons management and abstractions
MIDDLEWARE CHANNEL portability
SERVICES Cons – Middleware provides
higher-level building blocks  Resource management
DISTRIBUTION
MIDDLEWARE – Hardware resource (CPU, memory, peripheral device) control and
 Reuse
INFRASTRUCTURE insulation
MIDDLEWARE – Buy vs. build – Software resource (I/O handle, synchronization primitive, communication
OPERATING – The lower the layer, the more port) control
SYSTEMS & difficult and error-prone the
PROTOCOLS  Features to support distribution (concurrency)
code. (And the lowest layer is
HARDWARE DEVICES
hardware dependent.) – synchronization
– communication


Copyright c 1997-2000 Dept. of Computer Science, Washington University 2
Copyright c 1997-2000 Dept. of Computer Science, Washington University 3
David L. Levine Real-Time Operating Systems/Linux David L. Levine Real-Time Operating Systems/Linux

OS Limitations RTOS Capabilities


 Does the concurrency support scale?  Prioritized resource access
– Do 1000 processors give 1000x speedup?  Scheduling based on priority (or timeline)
 Does the OS allow fair sharing of resources?  Predictable operation
– Should all sharing be fair?  Very small size (under 1 Kb to a few hundred Kb)
 Can the OS footprint be minimized? – Compare to 1.5 Mb of Linux 2.2.12 (Red Hat 6.1)
 Does the OS provide standard interfaces?  High-level language (C++, Java) support


Copyright c 1997-2000 Dept. of Computer Science, Washington University 4
Copyright c 1997-2000 Dept. of Computer Science, Washington University 5

David L. Levine Real-Time Operating Systems/Linux David L. Levine Real-Time Operating Systems/Linux

The RTOS Market Performance Experiment


 Leader is VxWorks by Wind River [P0 ] [P1 ] [Pn ]  One 20 Hz high-priority
Servants

SCHEDULER
RUNTIME
client
 Number 2 was pSOS by Integrated Systems ... Object Adapter
[P ] [P ] [P ]

 1..n 10 Hz low-priority
0 1 n
...
 POSIX: LynxOS, QNX Neutrino C0 C1 ... Cn
...
S0 S1
ORB Core
Sn clients
Requests
 Windows and Linux compatibility
[P] Priority – Increasing n
I/O SUBSYSTEM
– RT versions really aren’t Client Server increases load
– RT compatible versions are coming, e.g., Blue Cat Linux
 Server factory
implements
1100
0011
001
110 thread-per-connection
11
00
Pentium II
– Each connection links
http://www.cs.wustl.edu/
client with its servant
˜levine/research/RT-OS.ps.gz


Copyright c 1997-2000 Dept. of Computer Science, Washington University 6
Copyright c 1997-2000 Dept. of Computer Science, Washington University 7
David L. Levine Real-Time Operating Systems/Linux David L. Levine Real-Time Operating Systems/Linux

High-Priority Request Latency Results Performance is Maintained with Distribution


2000
 Synopsis of results Low Priority Clients Low Priority Clients
1600 High Priority Client 1600 High Priority Client
1800
– LynxOS provides 1400 1400

Latency per two-way request, microseconds

Latency per two-way request, microseconds


1600
consistently low and
1200 1200
predictable latency
Two-way Request Latency, usec

1400
Linux

1200
LynxOS
NT – VxWorks does not 1000 1000

Solaris
VxWorks scale on x86 800 800
1000
– Non-RTOS’s are not 600 600
800
predictable
400 400
600 – ORB (TAO) provides
400
low latency and avoids 200 200

priority inversion 0
0 5 10 15 20 25 30 35 40 45
0
0 5 10 15 20 25 30 35 40 45 50
200
 i.e., high priority Number of Low priority Clients Number of Low priority Clients

0 client always has


0 1 2 5 10 15 20 25 30 35 40 45 50 Server and Client on Same CPU Server and Client on Different CPUs
Low Priority Clients lowest latency

Copyright c 1997-2000 Dept. of Computer Science, Washington University 8


Copyright c 1997-2000 Dept. of Computer Science, Washington University 9

David L. Levine Real-Time Operating Systems/Linux David L. Levine Real-Time Operating Systems/Linux

Do We Need to Use an RTOS? Linux Support for Real-Time

 Depends on application, but in general, probably not  POSIX.1 IPC, threads, scheduling, synchronization, etc.

 However, RTOS’s are often used as lightweight OS’s  Both Process (sched_) and thread (pthread_) scheduling

 We can use middleware for services, and use any suitable OS  Scheduling modes:
– SCHED_FIFO (run-to-completion/block)
– SCHED_RR (round-robin, with time quantum)
– SCHED_OTHER (time sharing, dynamic based on nice setting and
block time)
 Priority levels
– 1 to 99 for SCHED_FIFO and SCHED_RR
– 0 for SCHED_OTHER

Copyright c 1997-2000 Dept. of Computer Science, Washington University 10


Copyright c 1997-2000 Dept. of Computer Science, Washington University 11
David L. Levine Real-Time Operating Systems/Linux David L. Levine Real-Time Operating Systems/Linux

Linux Threads Linux 2.0 Kernel Source Structure


 User threads are implemented as processes
modules arch kernel mm ipc  Features
– _clone system call forks a process, but allows sharing of process alpha, i386, m68k,
ID, memory, file descriptors, file system info, and signal handlers. mips, ppc, sparc – Separation of
– Process fork time: 110 sec on 450 MHz Pentium II fs drivers net
concerns/encapsulation
– Configuration
 Thread context switch does not invalidate page tables. (Kernel checks ext2 block core support
autofs net ipv4
for whether the context switch is within the same process.) – Modular (except for
hpfs pci scsi ethernet
unix
 Thread context switch: 1) restore registers and TSS base, then 2) msdos Alphas)
proc ... ...
jump to thread’s IP nfs

 Thread context switch time: 1.2 sec on 450 MHz Pentium II


...

 Signal handling is slightly different between threads and processes. Docume


scripts
init
 Kernel threads introduced in Linux 2.2, full support in 2.3/2.4 lib
include

Copyright c 1997-2000 Dept. of Computer Science, Washington University 12


Copyright c 1997-2000 Dept. of Computer Science, Washington University 13
Real-Time Operatin

Dept. of Computer Science, Washington University


9079 bytes 2000-04-02
6360 bytes 1999-12-08
2861 bytes 2000-01-26
3474 bytes 2000-03-13
13411 bytes 2000-04-02
18190 bytes 2000-04-02
737 bytes 1999-08-23
4006 bytes 2000-02-10
5856 bytes 2000-04-02
13800 bytes 2000-04-07
22498 bytes 2000-03-11
2366 bytes 2000-04-11
6554 bytes 2000-03-15
11693 bytes 2000-03-10
3588 bytes 2000-03-21
7160 bytes 2000-02-29
27178 bytes 2000-03-27
25200 bytes 2000-03-23
5954 bytes 2000-03-05
27206 bytes 2000-03-19
31983 bytes 2000-03-23
12220 bytes 1999-10-17
20898 bytes 2000-02-10
4073 bytes 2000-01-11
Linux 2.3.99 Kernel Directory

David L. Levine Real-Time Operating Systems/Linux

Linux Kernel Runtime Structure

Visible through /proc filesystem


1/ 257/ 318/ 400/ cmdline mounts
1476/ 269/ 337/ 402/ cpuinfo net/
1478/ 278/ 338/ 414/ devices pci
1479/ 292/ 341/ 5/ dma scsi/
193/ 3/ 342/ 558/ filesystems self@
2/ 303/ 356/ 559/ interrupts stat
202/ 310/ 357/ 576/ ioports sys/
213/ 311/ 375/ 577/ kcore uptime
exec_domain.c

224/ 312/ 376/ 579/ kmsg version


capability.c

Copyright c 1997-2000

2262/ 313/ 394/ 580/ loadavg


resource.c

softirq.c

235/ 314/ 396/ 6/ locks


itimer.c

module.c

printk.c
ptrace.c

signal.c

sysctl.c

246/ 315/ 398/ 67/ meminfo


ksyms.c

panic.c

sched.c

timer.c
uid16.c
David L. Levine
acct.c

exit.c
fork.c
info.c

kmod.c

time.c

2487/ 317/ 4/ 7/ misc


dma.c

sys.c
pm.c


Copyright c 1997-2000 Dept. of Computer Science, Washington University 15
David L. Levine Real-Time Operating Systems/Linux David L. Levine Real-Time Operating Systems/Linux

Linux 2.0 Process Info Linux 2.0 System Processes

/proc$ ls self PID TTY STAT TIME COMMAND PID TTY STAT TIME COMMAND
cmdline environ fd/ mem stat status 1 ? S 0:08 init 246 ? S 0:00 inetd
cwd@ exe@ maps| root@ statm 2 ? SW 0:00 (kflushd) 257 ? S 0:00 lpd
3 ? SWN 0:00 (kswapd) 269 ? S 0:00 rpc.mountd
/proc$ cat self/status 4 ? SW 0:00 (nfsiod) 278 ? S 0:04 rpc.nfsd
Name: cat 5 ? SW 0:00 (nfsiod) 292 ? S 0:00 gpm -t ps/2
State: R (running) 6 ? SW 0:00 (nfsiod) 303 ? S 0:00 /usr/local/sbin/sshd
Pid: 2404 7 ? SW 0:00 (nfsiod) 310 1 S 0:00 /bin/login -- levine
PPid: 2398 67 ? S 0:00 kerneld 311 2 S 0:00 /sbin/mingetty tty2
Uid: 1046 1046 1046 1046 193 ? S 0:00 syslogd 312 3 S 0:00 /sbin/mingetty tty3
Gid: 1213 1213 1213 1213 202 ? S 0:00 klogd 313 4 S 0:00 /sbin/mingetty tty4
VmSize: 2056 kB VmStk: 8 kB SigBlk: 00000000 213 ? S 0:00 atd 314 5 S 0:00 /sbin/mingetty tty5
VmLck: 0 kB VmExe: 16 kB SigIgn: 00000000 224 ? S 0:00 crond 315 6 S 0:00 /sbin/mingetty tty6
VmRSS: 560 kB VmLib: 856 kB SigCgt: 00000000 235 ? S 0:00 portmap 317 ? S 0:05 update (bdflush)
VmData: 56 kB SigPnd: 00000000

Copyright c 1997-2000 Dept. of Computer Science, Washington University 16


Copyright c 1997-2000 Dept. of Computer Science, Washington University 17
Real-Time Operatin

244999 (pc=12005056c,va=120
Linux version 2.0.34 (root@linux00.amt.tay1.dec.com)

Dept. of Computer Science, Washington University


David L. Levine Real-Time Operating Systems/Linux

Linux System Info, continued


Linux_is_Great!

0 (pc=0,va=0)

/proc$ cat /proc/interrupts


MILO-0000

1: 60316 keyboard
1024.00
Linux System Info

4: 27127 + serial
497.02
EB164
Alpha

12: 269083 PS/2 Mouse


8192

127

N/A
EV5

16: 390908 3c905 Boomerang 100baseTx


40
0
0
0

0
0

19: 14555 aic7xxx


:
:
:
:

:
:

:
:

:
:

:
:
:

:
:
/proc$ cat /proc/version

system serial number


cycle frequency [Hz]
timer frequency [Hz]

kernel unaligned acc


phys. address bits
max. addr. space #

user unaligned acc


/proc$ cat cpuinfo

cpu serial number

page size [bytes]


system variation
system revision

platform string

Copyright c 1997-2000
cpu variation
cpu revision

system type
David L. Levine

cpu model

BogoMIPS


cpu


Copyright c 1997-2000 Dept. of Computer Science, Washington University 19
David L. Levine Real-Time Operating Systems/Linux David L. Levine Real-Time Operating Systems/Linux

Linux System Status RT Linux

/proc$ cat /proc/loadavg


 Victor Yodaiken’s RTLinux
0.00 0.00 0.00 2/56 2425 – Small real-time kernel runs Linux as (lowest priority) application
– Real-time and Linux tasks can communicate via queues and shared
/proc$ cat /proc/meminfo
memory (without using locks)
total: used: free: shared: buffers: cached:  Lynx’s BlueCat Linux
Mem: 262324224 111017984 151306240 63127552 18161664 55885824
Swap: 534634496 0 534634496 – Derivative of RedHat 6.1 (2.2.12-20 kernel) that provides binary
MemTotal: 256176 kB compatibility with LynxOS applications
MemFree: 147760 kB
MemShared: 61648 kB
Buffers: 17736 kB
Cached: 54576 kB
SwapTotal: 522104 kB
SwapFree: 522104 kB


Copyright c 1997-2000 Dept. of Computer Science, Washington University 20
Copyright c 1997-2000 Dept. of Computer Science, Washington University 21

Potrebbero piacerti anche