Find White Papers
Home
About Us
List Your Papers
    
> Mentor Graphics > Using C++ Efficiently In Embedded Applications

Using C++ Efficiently In Embedded Applications

White Paper Published By: Mentor Graphics

Moving to C++ presents opportunities for higher programmer productivity. The requirements of embedded systems, however, demand that the adoption of C++ be carefully measured for the performance impact of run-time costs present in C++, but not in C. This talk suggests strategies for developers who are starting their acquaintance with C++.



Tags : 
c++, coding, developer, programming, programmer, mentor graphics, run-time costs, embedded systems

Mentor Graphics
Published:  Apr 03, 2009
Type:  White Paper
Length:  10 pages

Using C++ Efficiently
In
Embedded Applications
César A QuirozMentor Graphics, Embedded Software Division
Abstract. Moving to C++ presents opportunities for higher programmerproductivity. The requirements of embedded systems, however,demand that the adoption of C++ be carefully measured for theperformance impact of run-time costs present in C++, but not in C.This talk suggests strategies for developers who are starting theiracquaintance with C++.
This talk is aimed at embedded systems developers who are considering the adoption of C++[BS97] intheir projects. The material assumes professional acquaintance with embedded development, and with alanguage in the general class of ANSI/ISO C[C90]. On the other hand, not much knowledge of C++ ispresumed. This talk is meant, therefore, for engineers tackling their first embedded system developmentprojects in C++.There are good reasons for using C++ to implement an embedded system, for instance:. C++ compares favorably with C (the leading alternative) in matters of syntactic convenience, compile-time type-checking, memory allocation and initialization, and code reuse through derivation,. The newly approved Draft Standard for C++ ends a long period of uncertainty about the ultimate shapeof the language. Conforming implementations are gradually turning up. Within a couple of years, weshould find that most implementations are fully conforming.On the other hand, there are corresponding reasons for caution, too:. C++ (plus its libraries) is a larger, more complex, language than C (its libraries included). A developerwho has a good understanding of the consequences of employing this or that C feature may be misledwhen evaluating outwardly similar features in C++,. The long gestation period of the C++ standard has promoted a drift in implementation. The meaningof a C++ program (never mind its performance) does depend on what compiler it was meant for.I assume here that the decision of adopting C++ has been made already, and that the development team isevaluating which C++ features will be appropriate for the project at hand.
Feature Cost EvaluationIf we could give for sure advice of the form "Embedded developers should never use feature XYZ" thenthis talk would not be needed. Such generalities are normally obvious (obviously right or obviouslywrong), but unlikely to be correct enough to use in real situations.1Evaluating a "feature", whatever we mean by that , has to be always a qualified proposition. Using afeature may be a clear win for some projects, but not for others; it will depend on the cost of the featurerelative to the project's needs and constraints.This sort of evaluation is uncertain because it depends on how much the feature buys us, how much it takesaway from our budget, and (not the least) because different implementations cost differently.For instance, consider the implementation of potentially unaligned accesses on processors (like most RISCcpus) where unaligned access triggers an exception[PPC].An example could be this function:int fetch_from( void *p ){ return *(int *)p; // what if 'p' points to an odd address?}
where we may be requested to obtain an integer from a non-int-aligned address. This could be needed, forone case, if we had to extract information from a message format that had been designed withoutconsideration for this problem.The implementation could deal with this sort of access in a number of ways; two extreme ones are worthcomparing. One is pessimistic (and normally inefficient), the other optimistic (and sometimes fast).The implementation may decide that such accesses need to be performed by fetching bytes one at a time toensure correct alignment. In effect, the return statement would mutate into something like:{ int tmp;char *dst = (char *)&tmp;char *src = (char *)p;while (dst < (char *)&tmp + sizeof(int)) *dst++ = *src++;return tmp;}
This, although legal, is likely to be inefficient always, as it dooms aligned accesses to the same treatment.On the other hand, the implementation could be optimistic, in whose case the fetch through the argumentpointer would be implemented directly as a word load, betting that the pointer points to a well-alignedinteger. Because this implementation would trigger exceptions whenever it loses its bet, it would be part ofits duty to supply an exception handler to correct the trapped accesses transparently.Deciding between these two decisions isn't t... [download for more]

Browse Technology Topics

Data Center

Virtualization, Cloud Computing, Infrastructure, Design and Facilities, Power and Cooling, Green Computing  
    

Data Management

Application Integration, Analytical Applications, Business Intelligence, Configuration Management, Database Development, Data Integration, Data Mining, Data Protection, Data Quality, Data Replication, Database Security, EDI, SOAP, Service Oriented Architecture, Web Service Management, Data Warehousing  
    

Enterprise Applications

Application Integration, Application Performance Management, Best Practices, Business Activity Monitoring, Business Analytics, Business Integration, Business Intelligence, Business Management, Business Metrics, Business Process Automation, Business Process Management, Call Center Management, Call Center Software, Change Management, Corporate Governance, Customer Interaction Service, Customer Relationship Management, Customer Satisfaction, Customer Service, EBusiness, Enterprise Resource Planning, Enterprise Software, EProcurement, Extranets, Groupware Workflow, HIPAA Compliance, IP Faxing, IT Spending, Marketing Automation, Performance Testing, Product Lifecycle Management, Project Management, Return On Investment, Risk Management, Sales & Marketing Software, Sales Automation, Server Virtualization, Simulation Software, Supply Chain Management, System Management Software, Total Cost of Ownership, Video Conferencing, Voice Recognition, Voice Over IP, Workforce Management, Incentive Compensation, Spend Management, Manufacturing Execution Systems, International Computing  

Human Resource Technology

Human Resources Services, Payroll Software, Time and Attendance Software, Workforce Management Software, Financial Management, Employee Monitoring Software, Employee Training Software, Recruiting Software/Services, Employee Performance Management, ELearning, Benefits Management, Expense Management  
    

IT Career Advancement

Cisco Certification, Microsoft Certification, Linux Certification, Network Security Certification, Software Development Certification  

IT Management

Employee Performance, ITIL, Productivity, Project Management, Software Compliance, Sarbanes Oxley Compliance, Service Management, Desktop Management  
    

Knowledge Management

Collaboration, Collaborative Commerce, Contact Management, Content Delivery, Content Integration, Content Management System, Corporate Portals, Customer Experience Management, Document Management, Information Management, Intranets, Messaging, Records Management, Search And Retrieval, Search Engines, Secure Content Management, SLA  

Networking

Active Directory, Bandwidth Management, Convergence, Distributed Computing, Ethernet Networking, Fibre Channel, Gigabit Networking, Governance, Grid Computing, Infrastructure, Internetworking Hardware, Interoperability, IP Networks, IP Telephony, Local Area Networking, Load Balancing, Migration, Monitoring, Network Architecture, Network Management, Network Performance, Network Performance Management, Network Provisioning, Network Security, OLAP, Optical Networking, Quality Of Service, Remote Access, Remote Network Management, Server Hardware, Servers, Small Business Networks, TCP/IP Protocol, Test And Measurement, Traffic Management, Tunneling, Utility Computing, VPN, Wide Area Networks, Green Computing, Cloud Computing, Power and Cooling, Data Center Design and Management, Colocation and Web Hosting  
    

Platforms

AS/400, Domino, Linux, Microsoft Exchange, Oracle, PeopleSoft, SAP, Siebel, Solaris, Tivoli, Unix, Web Sphere, Windows, Windows Server  

Security

Access Control, Anti Spam, Anti Spyware, Anti Virus, Application Security, Auditing, Authentication, Biometrics, Business Continuity, Compliance, DDoS, Disaster Recovery, Email Security, Encryption, Firewalls, Hacker Detection, High Availability, Identity Management, Internet Security, Intrusion Detection, Intrusion Prevention, IPSec, Network Security Appliance, Password Management, Patch Management, Phishing, PKI, Policy Based Management, Security Management, Security Policies, Single Sign On, SSL, Secure Instant Messaging, Web Service Security, PCI Compliance, Vulnerability Management  
    

Software Development

.NET, C++, Database Development, Java, Middleware, Open Source, Software Outsourcing, Quality Assurance, Scripting, SOAP, Software Testing, Visual Basic, Web Development, Web Services, Web Service Security, XML  

Storage

Backup And Recovery, Blade Servers, Clustering, IP Storage, ISCSI, Network Attached Storage, RAID, Storage Area Networks, Storage Management, Storage Virtualization, Email Archiving, Data Deduplication  
    

Wireless

802.11, Bluetooth, CDMA, GPS, Mobile Computing, Mobile Data Systems, Mobile Workers, PDA, RFID, Smart Phones, WiFi, Wireless Application Software, Wireless Communications, Wireless Hardware, Wireless Infrastructure, Wireless Messaging, Wireless Phones, Wireless Security, Wireless Service Providers, WLAN  
Search