Search the web
Sign In
New User? Sign Up
cheapthreads · cheap_threads
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Message search is now enhanced, find messages faster. Take it for a spin.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Messages 82 - 89 of 89   Newest  |  < Newer  |  Older >  |  Oldest
Messages: Show Message Summaries   (Group by Topic) Sort by Date v  
#82 From: Scott McKellar <mck9@...>
Date: Tue Aug 7, 2007 2:15 pm
Subject: Re: Is Embedded cheap threads MISRA C compliant
jm407a
Offline Offline
Send Email Send Email
 
Is Cheap Threads MISRA compliant?  In a word, no.

Since I had never even heard of MISRA before I saw your post, I
obviously have made no effort to comply with MISRA.  So I googled
a bit, found some MISRA rules at:

ftp://ftp.iar.se/WWWfiles/guides/MisraC.pdf

... and confirmed that Cheap Threads (including the embedded version)
is not compliant.

Most of the non-compliance consists of fairly superficial stylistic
differences.  In these respects Cheap Threads could be brought into
compliance through a lot of tedious but mostly mindless tinkering.

However one of the MISRA rules is that the software not use
non-constant function pointers.  I'm not sure exactly what MISRA
means by "non-constant", but if it means "not declared as const",
then Cheap Threads can never be compliant with MISRA.

Function pointers are an essential part of the client interface to
Cheap Threads.  They define how a thread is to behave, and how it is
to clean up after itself when it terminates.  They are treated as
constant in the sense that, once the function pointers are defined
for a given thread, they aren't changed.  However they can't possibly
be declared as const, because then they couldn't be assigned values.

Likewise, MISRA prohibits casts of pointer types.  While I'm not
sure if the Cheap Threads software itself casts any pointers, it
expects the client code to provide void pointers to thread-specific
data.  In order to use the thread-specific data, the client-defined
code for each thread would have to cast the void pointer back to the
appropriate type.  While it would be possible to avoid using this
feature, the resulting functionality would be extremely limited, or
require the use of ghastly and cumbersome workarounds to circumvent
MISRA's artificial restriction.

While Cheap Threads doesn't use all the same techniques that MISRA
mandates, it pretty much pursues the same goals, portability in
particular.  So far as I know, Cheap Threads makes no assumptions
about the platform, explicitly or implicitly, beyond the availability
of Standard C and certain standard library functions.

If you want to use Cheap Threads, I expect you'll need to spend a lot
of time bringing it into compliance, largely in cosmetic changes.
For example MISRA requires that built-in types be disguised by
typedefs such as INT_16 for int.  Since Cheap Threads doesn't care
how wide an int is, such a typedef would add nothing but obscurity.

In addition you'll need to get approval for exceptions for things like
the use of function pointers and void pointers.  I gather that MISRA
allows exceptions when they are defensible and documented, but I don't
know just how much you can get away with.

Thanks for your interest.  I wish I had better news for you.

Scott McKellar
http://home.swbell.net/mck9/ct/

--- jadhav_shubhangi <jadhav_shubhangi@...> wrote:

> Hi,
>
>      I want to use the Embedded version of cheap threads in our
> software and it's a requirement that all our software is MISRA C
> compliant.
>
>      Is Embedded cheap threads MISRA C compliant?
>
>
>
>

Messages 82 - 89 of 89   Newest  |  < Newer  |  Older >  |  Oldest
Advanced
Add to My Yahoo!      XML What's This?

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help