1 real-time operating systems - qnx brett o’neill cse 8343 – group a6

30
1 Real-Time Real-Time Operating Operating Systems - QNX Systems - QNX Brett O’Neill Brett O’Neill CSE 8343 – Group A6 CSE 8343 – Group A6

Upload: willis-bridges

Post on 12-Jan-2016

221 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: 1 Real-Time Operating Systems - QNX Brett O’Neill CSE 8343 – Group A6

1

Real-Time Real-Time Operating Operating

Systems - QNXSystems - QNXBrett O’NeillBrett O’Neill

CSE 8343 – Group A6CSE 8343 – Group A6

Page 2: 1 Real-Time Operating Systems - QNX Brett O’Neill CSE 8343 – Group A6

2

OverviewOverview Real-Time Operating SystemsReal-Time Operating Systems

What is a real-time operating system?What is a real-time operating system? Who needs real-time systems?Who needs real-time systems?

QNXQNX What is QNX?What is QNX? MicrokernelMicrokernel

IPCIPC Process schedulingProcess scheduling

Process ManagerProcess Manager OverviewOverview Process Life CycleProcess Life Cycle

I/O NamespaceI/O Namespace File ManagerFile Manager Device ManagerDevice Manager

Page 3: 1 Real-Time Operating Systems - QNX Brett O’Neill CSE 8343 – Group A6

3

Real-Time Operating Real-Time Operating SystemsSystems

What is a real-time operating system?What is a real-time operating system?

From comp.realtime newsgroup faq:From comp.realtime newsgroup faq:

““A realtime system is one in which the A realtime system is one in which the correctness of the computations not only correctness of the computations not only depends upon the logical correctness of the depends upon the logical correctness of the computation but also upon the time at which computation but also upon the time at which the result is produced. If the timing the result is produced. If the timing constraints are not met, system failure is said constraints are not met, system failure is said to have occurred.”to have occurred.”

Page 4: 1 Real-Time Operating Systems - QNX Brett O’Neill CSE 8343 – Group A6

4

Real-Time Operating Real-Time Operating Systems (cont.)Systems (cont.)

The value of the computation depends on The value of the computation depends on the timeliness of the answer is provided.the timeliness of the answer is provided. Computations finished late have diminished Computations finished late have diminished

valuevalue Computations finished early have no extra Computations finished early have no extra

valuevalue Problems arise when resources are shared Problems arise when resources are shared

among several computations – real-time among several computations – real-time systems use schedules of activities so all systems use schedules of activities so all activities will be completed in timeactivities will be completed in time

Page 5: 1 Real-Time Operating Systems - QNX Brett O’Neill CSE 8343 – Group A6

5

Real-Time Operating Real-Time Operating Systems (cont.)Systems (cont.)

Hard Real-Time – A system constraint in which Hard Real-Time – A system constraint in which late computations have NO value, and the effects late computations have NO value, and the effects of late computations can be catastrophic. In of late computations can be catastrophic. In hard real-time systems, activities MUST be hard real-time systems, activities MUST be completed on time.completed on time.

Soft Real-Time – Late computations have some Soft Real-Time – Late computations have some value, albeit diminished. Soft real-time systems value, albeit diminished. Soft real-time systems can tolerate some late computations, as long as can tolerate some late computations, as long as the value has not diminished to zero. the value has not diminished to zero. Meta requirements such as a stochastic model of the Meta requirements such as a stochastic model of the

acceptable frequency of late computations are often acceptable frequency of late computations are often usedused

Page 6: 1 Real-Time Operating Systems - QNX Brett O’Neill CSE 8343 – Group A6

6

Real-Time Operating Real-Time Operating Systems (cont.)Systems (cont.)

Real-Time Systems have different Real-Time Systems have different types of activities:types of activities: Those that can be scheduledThose that can be scheduled Those that cannot be scheduledThose that cannot be scheduled Non real-time activitiesNon real-time activities

Page 7: 1 Real-Time Operating Systems - QNX Brett O’Neill CSE 8343 – Group A6

7

Real-Time Operating Real-Time Operating Systems (cont.)Systems (cont.)

Who needs real-time systems?Who needs real-time systems? Mission-critical environments requiring hard Mission-critical environments requiring hard

real-time, where timely performance failures real-time, where timely performance failures can result in harm to people or propertycan result in harm to people or property

Quality/Timeliness of service guarantee Quality/Timeliness of service guarantee environments, particularly when failure to environments, particularly when failure to meet guarantees can result in financial meet guarantees can result in financial penaltiespenalties

Consumer devices that demand reliability –Consumer devices that demand reliability –ie. live video stream players in which failure ie. live video stream players in which failure to deliver content results in dropped frame to deliver content results in dropped frame ratesrates

Page 8: 1 Real-Time Operating Systems - QNX Brett O’Neill CSE 8343 – Group A6

8

QNXQNX

What is QNX?What is QNX? A commercial real-time operating A commercial real-time operating

system developed by QNX Software system developed by QNX Software Systems Ltd. of Canada (QSSL)Systems Ltd. of Canada (QSSL)

Runs on X86 machines and clones: Runs on X86 machines and clones: AMD, Nat Semiconductor, Cyrix, SGS AMD, Nat Semiconductor, Cyrix, SGS SemiconductorSemiconductor

Provides multitasking, priority-driven Provides multitasking, priority-driven preemptive scheduling and fast preemptive scheduling and fast context switchingcontext switching

Page 9: 1 Real-Time Operating Systems - QNX Brett O’Neill CSE 8343 – Group A6

9

QNX - MicrokernelQNX - Microkernel

““Bare bones” QNX consists only of a Bare bones” QNX consists only of a small kernel in charge of managing small kernel in charge of managing cooperating processescooperating processes

Page 10: 1 Real-Time Operating Systems - QNX Brett O’Neill CSE 8343 – Group A6

10

QNX - MicrokernelQNX - Microkernel

The microkernel has 4 main The microkernel has 4 main functions:functions: Routing messages between processesRouting messages between processes Low-level network communicationLow-level network communication Process schedulingProcess scheduling First-level interrupt handlingFirst-level interrupt handling

Page 11: 1 Real-Time Operating Systems - QNX Brett O’Neill CSE 8343 – Group A6

11

QNX - MicrokernelQNX - Microkernel

Message-based Inter-process Message-based Inter-process CommunicationCommunication A message is a packet of bytes synchronously A message is a packet of bytes synchronously

transferred from one process to anothertransferred from one process to another QNX does not attach meaning to the context of the QNX does not attach meaning to the context of the

message – the data in the message only has meaning to message – the data in the message only has meaning to the sender and the receiverthe sender and the receiver

C language functions Send(), Receive(), and Reply() are C language functions Send(), Receive(), and Reply() are usedused

Page 12: 1 Real-Time Operating Systems - QNX Brett O’Neill CSE 8343 – Group A6

12

QNX - MicrokernelQNX - Microkernel

Message passing synchronizes the Message passing synchronizes the execution of several cooperating execution of several cooperating processes. If Process A issues a Send() processes. If Process A issues a Send() request, it cannot resume execution until request, it cannot resume execution until Process B replies. And once Process B has Process B replies. And once Process B has issued its Receive() request, it cannot issued its Receive() request, it cannot continue execution until it receives continue execution until it receives another message.another message.

Processes that are not allowed to continue Processes that are not allowed to continue execution are blocked. execution are blocked.

Page 13: 1 Real-Time Operating Systems - QNX Brett O’Neill CSE 8343 – Group A6

13

QNX - MicrokernelQNX - Microkernel

Proxy-based Inter-process Proxy-based Inter-process CommunicationCommunication A proxy is a non-blocking message used for event notification A proxy is a non-blocking message used for event notification

in which the sending process does not need to interact with in which the sending process does not need to interact with the recipientthe recipient

Proxies are used when:Proxies are used when: A process wants to notify another process of an event, but does A process wants to notify another process of an event, but does

not want to risk sending a blocking messagenot want to risk sending a blocking message A process wants to send data to another process but does not need A process wants to send data to another process but does not need

acknowledgment of deliveryacknowledgment of delivery An interrupt handler wants to tell a process that some data is An interrupt handler wants to tell a process that some data is

available available Proxies can queue up to 65,535 messages for delivery. They Proxies can queue up to 65,535 messages for delivery. They

can be triggered more than once, sending a message for each can be triggered more than once, sending a message for each triggertrigger

Page 14: 1 Real-Time Operating Systems - QNX Brett O’Neill CSE 8343 – Group A6

14

QNX - MicrokernelQNX - Microkernel

Signal-based Inter-process Signal-based Inter-process CommunicationCommunication Signals are a method of asynchronous communicationSignals are a method of asynchronous communication QNX supports POSIX-compliant signals, UNIX signals, and QNX supports POSIX-compliant signals, UNIX signals, and

QNX-specific signalsQNX-specific signals

Network Inter-process Network Inter-process CommunicationCommunication Applications can communicate over a network Applications can communicate over a network

transparently. QNX treats all processes the same, whether transparently. QNX treats all processes the same, whether they are local or remotethey are local or remote

Virtual circuits are used – these are paths provided by the Virtual circuits are used – these are paths provided by the Network Manager to transmit messages, proxies and signalsNetwork Manager to transmit messages, proxies and signals

Page 15: 1 Real-Time Operating Systems - QNX Brett O’Neill CSE 8343 – Group A6

15

QNX - MicrokernelQNX - Microkernel

Virtual Circuits:Virtual Circuits: The sending process is responsible for setting up a The sending process is responsible for setting up a

VC between itself and the receiving process. VC between itself and the receiving process. Upon creation, the VC is given the ability to handle Upon creation, the VC is given the ability to handle

messages up to a specified size limit. If a message messages up to a specified size limit. If a message larger than the size limit is sent, the VC adjusts on larger than the size limit is sent, the VC adjusts on the fly.the fly.

Two processes can communicate via multiple VC’s, Two processes can communicate via multiple VC’s, combined into one logical VC.combined into one logical VC.

Upon process termination, VC’s are automatically Upon process termination, VC’s are automatically released.released.

Virtual proxies are also possibleVirtual proxies are also possible

Page 16: 1 Real-Time Operating Systems - QNX Brett O’Neill CSE 8343 – Group A6

16

QNX - MicrokernelQNX - Microkernel

Process SchedulingProcess Scheduling The microkernel’s scheduler makes scheduling The microkernel’s scheduler makes scheduling

decisions at three points:decisions at three points: When a process becomes unblockedWhen a process becomes unblocked When the time quantum for a running process expiresWhen the time quantum for a running process expires When a running process is preemptedWhen a running process is preempted

Every QNX process is assigned a priority. The Every QNX process is assigned a priority. The scheduler selects the process with the highest scheduler selects the process with the highest priority from the ready pool to run next.priority from the ready pool to run next.

Priorities range from 0 (lowest) to 31 (highest). Priorities range from 0 (lowest) to 31 (highest). Processes receive initial priorities from their parent Processes receive initial priorities from their parent processes. The default value is 10.processes. The default value is 10.

Page 17: 1 Real-Time Operating Systems - QNX Brett O’Neill CSE 8343 – Group A6

17

QNX - MicrokernelQNX - Microkernel QNX has 3 scheduling QNX has 3 scheduling

algorithms. These algorithms. These algorithms are of course algorithms are of course only used when 2 or only used when 2 or more processes that more processes that share the same priority share the same priority are in ready status. If a are in ready status. If a higher-priority process higher-priority process becomes available, it becomes available, it immediately preempts all immediately preempts all lower-priority processes:lower-priority processes: FIFO Scheduling – A FIFO Scheduling – A

process continues to process continues to execute until it a) execute until it a) voluntarily relinquishes voluntarily relinquishes control or b) is preempted control or b) is preempted by a higher-priority by a higher-priority processprocess

Page 18: 1 Real-Time Operating Systems - QNX Brett O’Neill CSE 8343 – Group A6

18

QNX - MicrokernelQNX - Microkernel

Round-Robin Scheduling – A process Round-Robin Scheduling – A process continues to execute until it a) continues to execute until it a) voluntarily relinquishes control, b) is voluntarily relinquishes control, b) is preempted by a higher-priority process, preempted by a higher-priority process, or c) consumes its time slice. A QNX or c) consumes its time slice. A QNX time slice is 50 millisecondstime slice is 50 milliseconds

Page 19: 1 Real-Time Operating Systems - QNX Brett O’Neill CSE 8343 – Group A6

19

QNX - MicrokernelQNX - Microkernel

Adaptive Scheduling – If a process Adaptive Scheduling – If a process consumes its time slice entirely, its consumes its time slice entirely, its priority is reduced by 1. This is called priority is reduced by 1. This is called priority decay. Processes only decay priority decay. Processes only decay once; if a process consumes more than once; if a process consumes more than one time slice, total reduction is only 1. one time slice, total reduction is only 1. If a process blocks, it immediately If a process blocks, it immediately regains its original priority.regains its original priority.

Page 20: 1 Real-Time Operating Systems - QNX Brett O’Neill CSE 8343 – Group A6

20

QNX – Process ManagerQNX – Process Manager

OverviewOverview The process manager works with the microkernel The process manager works with the microkernel

to provide operating system services. It shares the to provide operating system services. It shares the same address space as the process manager, but same address space as the process manager, but runs as a unique process, scheduled by the runs as a unique process, scheduled by the microkernel. It uses the same types of IPC’s as all microkernel. It uses the same types of IPC’s as all other QNX processes.other QNX processes.

The process manager is responsible for creating The process manager is responsible for creating new processes using C functions:new processes using C functions: Fork()Fork() Exec()Exec() Spawn()Spawn()

Page 21: 1 Real-Time Operating Systems - QNX Brett O’Neill CSE 8343 – Group A6

21

QNX – Process ManagerQNX – Process Manager

Process Life CycleProcess Life Cycle Each process goes through 4 stages in its Each process goes through 4 stages in its

lifetime:lifetime: Creation – A unique process ID is created, and Creation – A unique process ID is created, and

basic information is defined for the process’ basic information is defined for the process’ environment.environment.

Loading – Loader code in the process manager Loading – Loader code in the process manager creates a loader thread that runs under the creates a loader thread that runs under the process ID of the new process.process ID of the new process.

Execution – The process is in direct competition Execution – The process is in direct competition with other processes for execution time.with other processes for execution time.

Termination – A signal causes process termination, Termination – A signal causes process termination, or the process invokes an Exit() function.or the process invokes an Exit() function.

Page 22: 1 Real-Time Operating Systems - QNX Brett O’Neill CSE 8343 – Group A6

22

QNX – Process ManagerQNX – Process Manager

Process Life CycleProcess Life Cycle Processes are always in one of the following states:Processes are always in one of the following states:

READY – capable of being executedREADY – capable of being executed BLOCKED – the process is in one of these states:BLOCKED – the process is in one of these states:

SEND SEND RECEIVERECEIVE REPLYREPLY SIGNALSIGNAL SEMAPHORESEMAPHORE

HELD – the process has received a hold signalHELD – the process has received a hold signal WAIT – a child process has requested that the parent process WAIT – a child process has requested that the parent process

waitwait DEAD – the process has terminated but its parent is still DEAD – the process has terminated but its parent is still

runningrunning

Page 23: 1 Real-Time Operating Systems - QNX Brett O’Neill CSE 8343 – Group A6

23

QNX – I/O NamespaceQNX – I/O Namespace

I/O resources are not built into the I/O resources are not built into the microkernel as in most operating systems. microkernel as in most operating systems. They are started dynamically while the They are started dynamically while the system is running. Pathname space is not system is running. Pathname space is not built into the file system.built into the file system.

Pathname space is divided into regions of Pathname space is divided into regions of authority. Any processes that required I/O authority. Any processes that required I/O must register a prefix with the process must register a prefix with the process manager defining the portion of namespace it manager defining the portion of namespace it wants to administer. These prefixes are part wants to administer. These prefixes are part of a prefix tree maintained on the computer.of a prefix tree maintained on the computer.

Page 24: 1 Real-Time Operating Systems - QNX Brett O’Neill CSE 8343 – Group A6

24

QNX – I/O NamespaceQNX – I/O Namespace

When a process opens a file, the file’s When a process opens a file, the file’s pathname is compared to the prefix tree to pathname is compared to the prefix tree to direct the Open() function to the correct I/O direct the Open() function to the correct I/O resource manager.resource manager.

When an I/O resource is opened, the Open() When an I/O resource is opened, the Open() function returns an integer called the file function returns an integer called the file descriptor. All further I/O requests are descriptor. All further I/O requests are directed by the file descriptor to the correct directed by the file descriptor to the correct file manager.file manager.

The file descriptor namespace is completely The file descriptor namespace is completely local to each process. local to each process.

Page 25: 1 Real-Time Operating Systems - QNX Brett O’Neill CSE 8343 – Group A6

25

QNX – File ManagerQNX – File Manager The File Manager provides a standardized means of The File Manager provides a standardized means of

storing and accessing data on disks. storing and accessing data on disks. In QNX, a file is an object that can be read from, In QNX, a file is an object that can be read from,

written to, or both. There are 6 types of files:written to, or both. There are 6 types of files: Regular – randomly accessible sequences of bytes with no Regular – randomly accessible sequences of bytes with no

predefined structurepredefined structure Directories – contain the information needed to locate regular Directories – contain the information needed to locate regular

files files Symbolic links – contain a pathname to a file or directory that Symbolic links – contain a pathname to a file or directory that

is to be accessed in place of the symbolic link fileis to be accessed in place of the symbolic link file Pipes and FIFO’s – I/O channels between cooperating processesPipes and FIFO’s – I/O channels between cooperating processes Block special – refer to devices; accessed in a manner that Block special – refer to devices; accessed in a manner that

hides the hardware characteristics of the device from hides the hardware characteristics of the device from applicationsapplications

Page 26: 1 Real-Time Operating Systems - QNX Brett O’Neill CSE 8343 – Group A6

26

QNX – File ManagerQNX – File Manager

The file manager maintains four times for The file manager maintains four times for each file: a) date of last access, b) date of each file: a) date of last access, b) date of last write, c) date of last modification, and last write, c) date of last modification, and d) date of creationd) date of creation

Access to files is controlled by bits called Access to files is controlled by bits called inodes. Inodes permit read, write and inodes. Inodes permit read, write and execute permissions by user, by group, execute permissions by user, by group, and by other specifications.and by other specifications.

Page 27: 1 Real-Time Operating Systems - QNX Brett O’Neill CSE 8343 – Group A6

27

QNX – File ManagerQNX – File Manager The file manager has several means of maintaining The file manager has several means of maintaining

high-performance disk accesses:high-performance disk accesses: Elevator seeking – outstanding I/O requests are ordered so Elevator seeking – outstanding I/O requests are ordered so

they can all be performed with one sweep of the disk head they can all be performed with one sweep of the disk head assembly, from lowest to highest disk address.assembly, from lowest to highest disk address.

Buffer cache – a buffer between the file manager and the Buffer cache – a buffer between the file manager and the disk driver, the buffer cache tries to store all file system disk driver, the buffer cache tries to store all file system blocks to minimize the number of times the file manager blocks to minimize the number of times the file manager needs to access the disk.needs to access the disk.

Multi-threading – the file manager is multi-threaded, Multi-threading – the file manager is multi-threaded, therefore it can manage several I/O requests simultaneously. therefore it can manage several I/O requests simultaneously. Several devices can be accessed in parallel, and I/O requests Several devices can be accessed in parallel, and I/O requests can be processed from the buffer cache while other I/O can be processed from the buffer cache while other I/O requests are accessing physical disks.requests are accessing physical disks.

Page 28: 1 Real-Time Operating Systems - QNX Brett O’Neill CSE 8343 – Group A6

28

QNX – File ManagerQNX – File Manager

Client-driven priority – when the file Client-driven priority – when the file manager receives a message, its priority is manager receives a message, its priority is set to that of the process that sent the set to that of the process that sent the message.message.

Temporary files – data blocks are kept in Temporary files – data blocks are kept in cache to avoid writing blocks to a physical cache to avoid writing blocks to a physical disk unless absolutely necessary.disk unless absolutely necessary.

Ramdisks – up to 8M of memory can be Ramdisks – up to 8M of memory can be used as a simulated disk. Data moves used as a simulated disk. Data moves directly from the ramdisk into application directly from the ramdisk into application buffers.buffers.

Page 29: 1 Real-Time Operating Systems - QNX Brett O’Neill CSE 8343 – Group A6

29

QNX – Device ManagerQNX – Device Manager

QNX’s device manager is an QNX’s device manager is an interface between processes and interface between processes and terminal devices. terminal devices.

Programs access terminal devices Programs access terminal devices using the C functions Read(), using the C functions Read(), Write(), Open() and Close().Write(), Open() and Close().

The device manager regulates the The device manager regulates the flow of data between applications flow of data between applications and devices. and devices.

Page 30: 1 Real-Time Operating Systems - QNX Brett O’Neill CSE 8343 – Group A6

30

Questions?Questions?