Presentation is loading. Please wait.

Presentation is loading. Please wait.

Using POSIX to Maximize Code Portability in Embedded Systems Peter van der Veen QNX Software Systems.

Similar presentations


Presentation on theme: "Using POSIX to Maximize Code Portability in Embedded Systems Peter van der Veen QNX Software Systems."— Presentation transcript:

1 Using POSIX to Maximize Code Portability in Embedded Systems Peter van der Veen QNX Software Systems

2 2 All content copyright QNX Software Systems. POSIX® /pahz-icks/  POSIX, pronounced pahz-icks as in positive, not poh-six, or other variations  POSIX is a registered trademark of the IEEE ► Licensed through certification  An acronym for Portable Operating System Interface  POSIX is a family of standards developed by the Portable Applications Standards Committee (PASC) of the IEEE Computer Society

3 3 All content copyright QNX Software Systems. What Is POSIX?  It’s about portability ► Both programmers and application source code ► Portability of the OS kernel itself and/or application binary code are not objectives  POSIX is a set of books specifying APIs ► It is neither a piece of code ► Nor an operating system ► It is a rich, proven API

4 4 All content copyright QNX Software Systems. What Is an API?  Application Program Interface  Written contract between system developers and application developers  It is not a piece of code, it is a piece of paper defining what the two sets of developers are guaranteed to receive and are in turn responsible for providing

5 5 All content copyright QNX Software Systems. The Need for Standard APIs  Standardized “square” peg in the round hole ►“Bits where change is not interesting” ►Where the benefits of commonality outweigh the value of differences ►Where we can achieve economies of scale, including interoperability Standardized functionality Private product specific functionality

6 6 All content copyright QNX Software Systems. Scalable API Portability POSIX APIs support portability across a range of devices

7 7 All content copyright QNX Software Systems. POSIX , 2004 Edition  Approved December 6, 2001  2004 edition incorporates two Technical Corrigenda  Developed by the Austin Group (see later)  Supersedes all the major POSIX standards except (realtime profiles) and (Ada bindings)  A combined system interfaces (including all realtime POSIX) and utilities specification as a single 4000 page standard  The core of DoD’s mandated Joint Technical Architecture (JTA) OS Services, replacing and its amendments  Technically identical to the Base specifications of the Single UNIX Specification and ISO 9945

8 8 All content copyright QNX Software Systems. The Common Base Specifications Rationale System Interfaces Definitions Commands IEEE Std , ISO/IEC 9945 The Open Group Base Specifications Issue 6 The Core of the Single UNIX Specification v3

9 9 All content copyright QNX Software Systems. The Austin Group  The Austin Group combines the formal standards process of the IEEE and ISO, with the industry standards of The Open Group and the community at large  Electronic participation  Participation in the group is free (www.opengroup.org/austin)www.opengroup.org/austin  The final standard in HTML is available for free download from the World Wide Web (www.unix.org/version3)www.unix.org/version3

10 10 All content copyright QNX Software Systems. POSIX  Approved December 10, 2003  A set of POSIX realtime profiles  Supersedes POSIX updated to address ► (which includes all of realtime POSIX) ► Profiles of all series standards (Ada bindings to POSIX) ► Field experience with ► Input from the Linux, realtime and/or embedded Linux, and traditional RTOS communities

11 11 All content copyright QNX Software Systems. POSIX-RT Profile 51 Units of Functionality - POSIX-RT Profile 52 Units of Functionality - POSIX-RT Profile 54 Units of Functionality - POSIX-RT Profile 53 Units of Functionality - Profile 54: Base Multi- process, Threads, File System Profile 53: Multi-process, Threads; File System Profile 52: Single Process, Threads, File System Profile 51: Single Process, Threads; No File System Portable Operating System Interface IEEE Standard POSIX Allows Portability of Applications POSIX Profiles

12 12 All content copyright QNX Software Systems. POSIX  POSIX is a subprofile standard of ► It allows diverse realtime operating systems “clothed” with a runtime library to comply ► This standardizes the application-to-RTOS API, allowing considerable application code portability between different RTOS offerings, which portability had not been possible in the past ► RTOS+wrapper offerings can be compared and competed directly ► There are currently four profiles

13 Using POSIX in Embedded Systems

14 14 All content copyright QNX Software Systems. Today’s Environment  Typical company has multiple product lines and limited interoperability  Vendors are locked into a single OS solution or  Applications need to be recoded or ported to deploy on different product lines ► Takes time, adds costs ► Increases delays to product deployment Product Line C OS 3 Application Product Line A OS 1 Application Product Line B OS 2 Application Recoding

15 15 All content copyright QNX Software Systems. Standards & Portability  Standard APIs preserve software investments  Portability lowers time, cost, and risk associated with integrating new technology across product lines  Common standard maximizes application base for development environments  Developers familiar with standard become productive more quickly

16 POSIX Compliance OS Comparison

17 17 All content copyright QNX Software Systems. POSIX Feature Matrix Check for Advanced Realtime  b-93 Memory Protection  b-93 IPC Message Passing  b-93 Shared Memory  b-93 Semaphores  b-93 Realtime Signals   b-93 Hi Res. Clocks & Timers  Users & Groups  -  Files & Directories  Pipes  Processes POSIX PSE 54PSE 53PSE 52PSE 51Feature

18 18 All content copyright QNX Software Systems. POSIX Feature Matrix  ---POSIX2_SW_DEV  c-95 Thread Priority Protection  c-95 Thread Priority Inheritance  c-95 Thread Priority Scheduling  c-95 Thread Process Shared  c-95 Thread Attribute Stack Size  c-95 Thread Attribute Stack Address  c-95 Thread Safe Functions  c-95 Threads POSIX PSE 54PSE 53PSE 52PSE 51Feature

19 19 All content copyright QNX Software Systems. POSIX Profiles – OS Compliance -Configure, GCC, perl, … Best practices (development) PSE 51/PSE * Specification Base --  j-200x Advanced Realtime (Barriers, spin-locks, …) --  d-1999 Additional Realtime (Sporadic server scheduling, execution timers, …) -  Realtime Threads (.1c)  Realtime (.1b) RTOS xLinuxQNX NeutrinoPOSIX Standard * Newer versions of Linux kernel moving toward conformance with 2001 specification.

20 20 All content copyright QNX Software Systems. Linux-POSIX (Base) Portability  Application portability between Linux and POSIX Base (2003) can be easily accomplished ► Both Linux and new POSIX specification share large POSIX feature set  Linux developers can retain programming model and existing APIs while porting applications to POSIX, including embedded systems Bottom line:  Porting applications between Linux and POSIX Base implementations is relatively simple  Standard POSIX APIs are key

21 21 All content copyright QNX Software Systems. POSIX Summary  Standard interface increases software portability for all embedded systems  Some markets, such as military, moving toward using POSIX as their base specification  OS compliance/conformance a matter of degree ► Many RTOS offerings conform to PSE 51 or PSE 52, against the specification ► QNX Neutrino provides compliance with ► Linux moving toward with latest versions  Migration of legacy RTOS code to POSIX RTOS increases software portability

22 Examples Migration, portability in the presence of unspecified behavior, etc.

23 23 All content copyright QNX Software Systems. Unspecified/Implementation Specific Behavior  Task at-hand requires knowledge of unspecified behavior or of implementation-defined behavior ► For best performance ► To enable feature that is difficult to achieve with mandated interfaces  Codify ► Best practices ► Information about different implementations  Conditional compilation ► Appropriate macro definitions ► Appropriate configuration  E.g. Autoconf  May include “discovery”

24 24 All content copyright QNX Software Systems. Application Porting Example – Lynx Text Browser Untar the source: Go to the source directory. tar xz lynx2.8.4.tar.gz cd lynx2-8-4 Make a host directory: Go to the host directory. mkdir x86-pc-nto-qnx cd x86-pc-nto-qnx Configure the source: Make.../configure make Install the browser: Install. make install

25 25 All content copyright QNX Software Systems. Unspecified Behavior – Directory Scanning (disk usage – du) while (entry = readdir(dirp)) { struct stat stat; char path[PATH_MAX+1]; strcpy(path, pathname); strcat(path, entry->d_name); stat(path, &stat); if (S_ISDIR(stat.st_mode)) usage += du(path); #ifdef HAVE_SYMLINKS /* May be determined by Autoconf! */ else if (S_ISLNK) { lstat(path, &stat); if (S_ISDIR(stat.st_mode)) { char linkpath[PATH_MAX+1]; int chars; if ((chars = readlink(path, linkpath, PATH_MAX)) > 0) { linkpath[chars] = '\0'; usage += du(linkpath); } #endif }

26 26 All content copyright QNX Software Systems. Summary  POSIX is a scalable standard with many different levels of compliance and many optional feature sets  Program by contract ► Define a profile(s) that matches your needs and stick to it ► Select vendor implementations that match your profile  Follow best practices whenever possible ► Avoid unspecified or undefined behavior ► Code conditionally to abstract over differences

27 27 All content copyright QNX Software Systems. Thank You!  Learn more about POSIX Certification:  Download the QNX white paper “Using POSIX in Embedded Systems:  Get your free 30-day evaluation copy of QNX Momentics development suite v6.3: Questions?


Download ppt "Using POSIX to Maximize Code Portability in Embedded Systems Peter van der Veen QNX Software Systems."

Similar presentations


Ads by Google