Presentation is loading. Please wait.

Presentation is loading. Please wait.

Using POSIX to Maximize Code Portability in Embedded Systems

Similar presentations


Presentation on theme: "Using POSIX to Maximize Code Portability in Embedded Systems"— Presentation transcript:

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

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 All content copyright QNX Software Systems.

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 All content copyright QNX Software Systems.

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 All content copyright QNX Software Systems.

5 The Need for Standard APIs
Standardized functionality 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 There are substantial benefits from having standardized products , look at the Size of the market for commodity products such as video recorder, dvd players, these have all benefited from standards Private product specific functionality All content copyright QNX Software Systems.

6 Scalable API Portability
POSIX APIs support portability across a range of devices Today the internet is the world’s largest embedded system Connectivity is key Access your data from anywhere anytime All content copyright QNX Software Systems.

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 All content copyright QNX Software Systems.

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

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) The final standard in HTML is available for free download from the World Wide Web (www.unix.org/version3) All content copyright QNX Software Systems.

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 All content copyright QNX Software Systems.

11 All content copyright QNX Software Systems.
POSIX Profiles 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 POSIX-RT Profile 52 Units of Functionality - POSIX-RT Profile 51 Units of Functionality - Profile 52: Single Process, Threads, File System Profile 51: Single Process, Threads; No File System Allows Portability of Applications Portable Operating System Interface IEEE Standard POSIX All content copyright QNX Software Systems.

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 All content copyright QNX Software Systems.

13 Using POSIX in Embedded Systems

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 Product Line B OS 2 Recoding In today’s software environment, companies typically have multiple product lines with limited code portability. Proprietary or non-standard APIs make it necessary to use one OS solution across product lines – even if the capabilities of the OS don’t meet the requirements of the system. Functionality may need to be cut back to meet deadlines and cost limitations. The alternative is to spend time recoding applications for use on next-generation platforms or different product lines – which takes time and money. All content copyright QNX Software Systems.

15 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 Using an RTOS that conforms to standard APIs can help to preserve software investments across product lines, which in turn can lower the time, cost, and risk of integrating new technology. A common standard maximizes the use of your application code. And finally, developers familiar with the standard can become productive immediately – removing the learning curve associated with any new OS platform. All content copyright QNX Software Systems.

16 POSIX Compliance OS Comparison

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

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

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

20 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 Because of the shared POSIX feature set, it’s fairly easy to port applications between Linux and QNX Neutrino. Linux developers benefit in that they can retain the programming model of their existing Linux APIs, thereby reusing existing development work. Companies can then make their OS choice based on the needs of their system – realtime performance, high reliability, scalability, hardware support, etc. All content copyright QNX Software Systems.

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 Steve to provide notes. All content copyright QNX Software Systems.

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

23 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” All content copyright QNX Software Systems.

24 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 All content copyright QNX Software Systems.

25 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 All content copyright QNX Software Systems.

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 All content copyright QNX Software Systems.

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? All content copyright QNX Software Systems.


Download ppt "Using POSIX to Maximize Code Portability in Embedded Systems"

Similar presentations


Ads by Google