Reply by Ton Janssen November 1, 20042004-11-01
"Alain" <alain.boule@atermes.fr> wrote in message
news:d2753e91.0410290505.5e567a11@posting.google.com...
> "Ton Janssen" <djan@oce.nl> wrote in message
news:<1098167368.621217@news-ext.oce.nl>...
> > Hi, > > > > In my opinion, UML is very wel suited for embedded systems
specification,
> > design AND implementation. Sequence diagrams are a good help in
specifying
> > specific behaviour, although you need more diagrams (structure and > > behaviour) to completely specify the system. IMO the big advantage only > > starts if your systems's model is used to generate the actual code, > > otherwise you end up with a documentation tool. > > > > In an article by telelogic, www.telelogic.com, one can read: > "Structured Analysis and Structured Design (SASD) techniques have been > around for over twenty years, and usage in certain areas of systems and > software development, particularly system engineering in large aerospace > and defense projects, is still found today. > > The first generation of UML has had uptake for analysis and high-level > design and some degree of use for partial software generation, > but has not been seen as sufficiently complete to replace SASD in all > circumstances. > > For current practioners of Structured Analysis and Structured Design, > who have not been satisfied with the first generation of UML (1.x) due > to its lack of support for hierarchical architecture modeling, but who > want to be able to adopt the latest visual systems and software
development
> tool support, UML 2.0 provides the answer." > > Did you find that UML 1.x had shortcomings and do you consider that UML
2.0
> is satisfactory ?
In UML 2.0 'Ports' are introduced with required and provided interfaces. IMHO this is the biggest advantage of UML 2.0 compared to 1.x. Ports are a very strong concept when specifying composite objects, i.e. one that contains other objects in a containment relationship. In particular the structured class concept can be specialized to model active objects which have their own thread of control that communicate with other active objects, asynchronously, using message queues. These active objects address a key need of the embedded and real-time developer: the ability to model complex and concurrent objects in the problem domain such as interfaces and devices. Ports were introduced based on the ROOM concept of ports. The only reason I prefer ROOM above UML is the statediagram implementation. We compared UML state diagrams (Rhapsody) with ROOM state diagrams (Rose RealTime) and found that ROOM state diagrams correspend better to the actual program flow of the generated code. Compare the result of a piece of generated code when drawing a diagram with 3 states (A,B,C) and a choicepoint between A,B(true) and A,C(false). In the UML version there is code duplication, in the ROOM version, reading the diagram is reading the code. It is probably also a matter of taste; we used to ObjecTime in the late nineties. Cheers, Ton Janssen
Reply by Alain October 29, 20042004-10-29
"Ton Janssen" <djan@oce.nl> wrote in message news:<1098167368.621217@news-ext.oce.nl>...
> Hi, > > In my opinion, UML is very wel suited for embedded systems specification, > design AND implementation. Sequence diagrams are a good help in specifying > specific behaviour, although you need more diagrams (structure and > behaviour) to completely specify the system. IMO the big advantage only > starts if your systems's model is used to generate the actual code, > otherwise you end up with a documentation tool. >
In an article by telelogic, www.telelogic.com, one can read: "Structured Analysis and Structured Design (SASD) techniques have been around for over twenty years, and usage in certain areas of systems and software development, particularly system engineering in large aerospace and defense projects, is still found today. The first generation of UML has had uptake for analysis and high-level design and some degree of use for partial software generation, but has not been seen as sufficiently complete to replace SASD in all circumstances. For current practioners of Structured Analysis and Structured Design, who have not been satisfied with the first generation of UML (1.x) due to its lack of support for hierarchical architecture modeling, but who want to be able to adopt the latest visual systems and software development tool support, UML 2.0 provides the answer." Did you find that UML 1.x had shortcomings and do you consider that UML 2.0 is satisfactory ?
Reply by Clifford Heath October 28, 20042004-10-28
Ed Beroset wrote:
> I haven't used a gnu toolchain for an embedded project yet, but I would > expect that there are still going to be dead code possibilities that the > machine is going to have a hard time eliminating. E.g:
If bar() in your example was declared static, and if you didn't say i==0 in the for() loop initialisation (which makes the whole program undefined), then gcc optimises it to a single call to printf. If you meant to say "i < limit" as the for() termination condition as I suspect, gcc turns foo() into a return statement. This is with -O6. Try it yourself using -S and look at the asm. This level of global-optimization was becoming standard about 8 years ago. There are much better optimisers now, including link-time ones that do this over the whole program. There are even optimisers that generate instrumented code, link it, get you to run it over some typical input, then re-optimise using the information gained. To my knowledge this was implemented first in a production compiler also about 6-8 years ago, but definitely wasn't standard then. Clifford Heath.
Reply by Doug Haseltine October 27, 20042004-10-27
On Tue, 26 Oct 2004 16:27:41 +0200, Ton Janssen wrote:
> Reading your reaction below you obviously did NOT use Rose Realtime 2003. > Another observation is that hierarchical packages ARE allowed. We always use > hierarchical packages in our design. CM integration must be prepared by an > expert. Once this has been done Rose-RT integrates seamlesly with your Cm > tool. Check in, check out, refresh, all no problem. Refreshing a large model > takes about a minute (at least on my PC, a Pentium 4 1.6GHz) and is done in > the background. Rose-RT 2003 gives you the possibility to refresh from CM in > the background afer opening the model. We use CMSynergy. I agree only on the > crappy editor used to fill in your transition code etc. Each freeware > product has a better source code editor with syntax highlighting. Your > collegae in France probably means Telelogic Tau-G2, which is also a UML 2.0 > tool with code generation. I like ROOM state diagram more (above UML 2.0) > because they correspond better to the program flow. > <snip>
A couple notes from another Realtime user. First, you can have Rose automatically use any favorite editor you choose (Xemacs, etc.) to fill in the code and documentation windows when you're filling in a use case specification or transition snippet. Regarding the CM refresh time, we've hooked it up to RCS, ClearCase, and Razor and the only slow experience is on our older Solaris machines. On a newer Linux based machine it's pretty fast, especially if you replace the rtperl program supplied by Rational with your own scripting front end. There's not a whole lot of speed optimization behind the Perl scripts supplied out-of-the-box by Rational.
Reply by Ton Janssen October 26, 20042004-10-26
Hi Wim Ton,

Reading your reaction below you obviously did NOT use Rose Realtime 2003.
Another observation is that hierarchical packages ARE allowed. We always use
hierarchical packages in our design. CM integration must be prepared by an
expert. Once this has been done Rose-RT integrates seamlesly with your Cm
tool. Check in, check out, refresh, all no problem. Refreshing a large model
takes about a minute (at least on my PC, a Pentium 4 1.6GHz) and is done in
the background. Rose-RT 2003 gives you the possibility to refresh from CM in
the background afer opening the model. We use CMSynergy. I agree only on the
crappy editor used to fill in your transition code etc. Each freeware
product has a better source code editor with syntax highlighting. Your
collegae in France probably means Telelogic Tau-G2, which is also a UML 2.0
tool with code generation. I like ROOM state diagram more (above UML 2.0)
because they correspond better to the program flow.

Cheers,
 -- 
############################################################
# Oce Technologies B.V.        name: Ton Janssen (3A05)    #
# P.O. Box 101                email: djan@oce.nl           #
# 5900 MA Venlo             Private: djan@home.nl          #
#                               Tel: +31 (0)77-359 40 97   #
# The Netherlands               Fax: +31 (0)77-359 54 50   #
############################################################
  This note does not necessarily represent the position of
  Oce Technoligies B.V. Therefore no liability or
  responsibility for whatever will be accepted.

"Wim Ton" <wimton@blueyonder.co.uk> wrote in message
news:5iUdd.131486$BI5.119403@fe2.news.blueyonder.co.uk...
> > "Ton Janssen" <djan@oce.nl> wrote in message > news:1098167368.621217@news-ext.oce.nl... > > Hi, > > > > In my opinion, UML is very wel suited for embedded systems
specification,
> > design AND implementation. Sequence diagrams are a good help in
specifying
> > specific behaviour, although you need more diagrams (structure and > > behaviour) to completely specify the system. IMO the big advantage only > > starts if your systems's model is used to generate the actual code, > > otherwise you end up with a documentation tool. > > > > We have been using Rose Realtime C++ and C with complete codegeneration > for > > several years sucessfully to implement complex embedded applications.
C++
> > with active classes and an underlying RTOS for the 32 bit platforms, C > with > > passive classes only and NoRTOS for the 16 bit platforms. > > > > Cheers, > > -- > The company I work for uses Rose for smartcard operating systems (a few > hunderd K ROM, a few K RAM). Not being the system architect, I am not very > convinced by Rose. I see it as a 'glorified' interface to the source
control
> combined with a crappy editor. The best way to use it seems to be:
generate
> code and use IDE's to capture the syntax errors. Correct errors, test and > port back to Rose (copy/paste for Java code) . Configuration management in > awkward as Rose does not support hierachical packages and we are
maintaining
> about a dozen slightly different configurations. Syncing with source > control takes 40 minutes, giving me enough time to drink my coffy and read > my email and several newspapers when I come in the office in the morning. > The use of UML for our purpose is not obvious. Usecases are very boring
as
> a smartcard is single proces/single treaded and the only usecase is: send > command, get response. We are not using state diagrams to generate code (a > smartcard does not have much state anyway and translating Open Platform
and
> Javacard into statediagrams is possibly not worth the trouble) I only > experienced quite a drop in productivity when switching from VSS + IDE to > Rose. It may be useful for systems with lots of state or complicated > usecases, but IMHO not for OSes or VMs > > My collegue in France is raving about a UML product from Telelogic or so. > > Wim > > >
Reply by Ed Beroset October 25, 20042004-10-25
Ulf Samuelsson wrote:
>>>>I haven't used a gnu toolchain for an embedded project yet, but I would >>>>expect that there are still going to be dead code possibilities that the >>>>machine is going to have a hard time eliminating. E.g: >>>> >>>>int foo() { >>>>int dummy = 0; >>>>return bar(dummy); >>>>} >>>> >>>>int bar(int limit) { >>>>int i; >>>>for (i==0; i <= limit; i++) >>>>printf("iteration %d\n", i); >>>>return limit; >>>>} >>>> >>>>If the only call to bar() is within foo() as shown, then there is >>>>definitely code that can be eliminated. Can gcc eliminate it? > > > Nope, an ANSI C compiler cannot eliminate this, unless it can > do a cross-module optimization over all modules.
I think that's why Grant Edwards referred to gcc/binutils. For this to be removed we'd require something which knew at least as much as the linker does.
> The problem is that you define your subroutines as "int", instead of "static > int". > I did a similar exercise with the IAR AVR compiler and that changed my > three subroutine + main program to a single line. > > return 0; > > or > > LDI R16,0 > RET
Good point. In my case, (gcc 3.2.2 generating x86 code under Linux) it resolved to no code at all when I declared them both static. If we can reliably give such hints to the compiler, it can do all sorts of magic. Ed
Reply by Ulf Samuelsson October 25, 20042004-10-25
> >>I haven't used a gnu toolchain for an embedded project yet, but I would > >>expect that there are still going to be dead code possibilities that the > >>machine is going to have a hard time eliminating. E.g: > >> > >>int foo() { > >> int dummy = 0; > >> return bar(dummy); > >>} > >> > >>int bar(int limit) { > >> int i; > >> for (i==0; i <= limit; i++) > >> printf("iteration %d\n", i); > >> return limit; > >>} > >> > >>If the only call to bar() is within foo() as shown, then there is > >>definitely code that can be eliminated. Can gcc eliminate it?
Nope, an ANSI C compiler cannot eliminate this, unless it can do a cross-module optimization over all modules. The problem is that you define your subroutines as "int", instead of "static int". I did a similar exercise with the IAR AVR compiler and that changed my three subroutine + main program to a single line. return 0; or LDI R16,0 RET -- Best Regard Ulf Samuelsson
Reply by R Adsett October 25, 20042004-10-25
In article <417d16e0$0$531$a1866201@newsreader.visi.com>, grante@visi.com 
says...
> On 2004-10-25, Ed Beroset <beroset@mindspring.com> wrote: > > > > With most of the tools I use (and have used) an unreferenced > > variable is caught and flagged by the compiler. > > I don't see how that's even theoretically possible in the C > language. The compiler can only see 1 file at time. If you > declare a global variable and don't use it within that file, > the C compiler can't know it's an error because it might be > used by another file. That's bad style, I'll admit, but > perfectly legal C.
That's what lint (well Gimpel's version at least, maybe lc-lint too?) is for ;)
> > > I seem to recall a study that was published in the > > Communications of the ACM some years ago that found that > > unreferenced variables had a very high correlation with > > defective code, so whenever I get such a warning from my > > compiler, I look *very* carefully at the offending routine. > > For local and static variables, I agree. For global variables, > I don't really see how such a warning can be generated by a C > compiler.
Lint again ;) And using another tool like that means you get a second POV on the code and you don't have to rely of the quality of diagnostics from the compiler (which range from excellent to pointless depending on the compiler). Robert
Reply by Grant Edwards October 25, 20042004-10-25
On 2004-10-25, Ed Beroset <beroset@mindspring.com> wrote:

>>>With most of the tools I use (and have used) an unreferenced >>>variable is caught and flagged by the compiler. >> >> I don't see how that's even theoretically possible in the C >> language. The compiler can only see 1 file at time. If you >> declare a global variable and don't use it within that file, >> the C compiler can't know it's an error because it might be >> used by another file. That's bad style, I'll admit, but >> perfectly legal C. > > Ah, I should have been specific that I meant local and static v'bles > only and not globals.
Ah. I use -Werror, so files with unreferenced local/static variables don't even compile.
> I tend to use very very few globals so checking them by hand > is usually fairly simple. There, tools like splint and > Doxygen can help.
I really do need to get lint going again...
>> For local and static variables, I agree. For global >> variables, I don't really see how such a warning can be >> generated by a C compiler. > > It would have to be generated by a linker or a global source code > analyzer.
That would be a useful addition to the Gnu ld. You can tell it to discard unreferenced objects, but I don't think you can generate a report on what got discarded.
> Our computers can definitely help us spot silly errors, if we > use the right tools.
And we pay attention to what they tell us. :) -- Grant Edwards grante Yow! Yow! Am I in at Milwaukee? visi.com
Reply by Ed Beroset October 25, 20042004-10-25
Grant Edwards wrote:
> On 2004-10-25, Ed Beroset <beroset@mindspring.com> wrote: > > >>>>>If that's true, then you're using a rather primitive toolchain. >>>>>Gnu gcc/binutils can remove unused functions and variables >>>>>regardless of what files they're in. >>>> >>>>Are you very sure about that? And that it won't break the program >>>>completely, in the presence of function pointer usage? Of function >>>>pointer arithmetic (--> jump tables)? >>> >>>Yes, I'm sure. I've been using it for years. It works even with function >>>pointers and jump tables. Why wouldn't it? A reference to a fucntion is a >>>reference to a function: it doesn't make any difference whether it's part of >>>JSR instruction, a LDI instruction, or a .LONG directive. >> >>I haven't used a gnu toolchain for an embedded project yet, but I would >>expect that there are still going to be dead code possibilities that the >>machine is going to have a hard time eliminating. E.g: >> >>int foo() { >> int dummy = 0; >> return bar(dummy); >>} >> >>int bar(int limit) { >> int i; >> for (i==0; i <= limit; i++) >> printf("iteration %d\n", i); >> return limit; >>} >> >>If the only call to bar() is within foo() as shown, then there is >>definitely code that can be eliminated. Can gcc eliminate it? > > > I don't know if it's that sophisticated or not.
On my Linux box, I can't make it eliminate that code, but that could just mean I don't know all of the optimization command line options sufficiently. I just used -O3. However, it did promptly notice that it should be "for (i=0..." Oops!
>>With most of the tools I use (and have used) an unreferenced >>variable is caught and flagged by the compiler. > > I don't see how that's even theoretically possible in the C > language. The compiler can only see 1 file at time. If you > declare a global variable and don't use it within that file, > the C compiler can't know it's an error because it might be > used by another file. That's bad style, I'll admit, but > perfectly legal C.
Ah, I should have been specific that I meant local and static v'bles only and not globals. I tend to use very very few globals so checking them by hand is usually fairly simple. There, tools like splint and Doxygen can help.
>>I seem to recall a study that was published in the >>Communications of the ACM some years ago that found that >>unreferenced variables had a very high correlation with >>defective code, so whenever I get such a warning from my >>compiler, I look *very* carefully at the offending routine. > > For local and static variables, I agree. For global variables, > I don't really see how such a warning can be generated by a C > compiler.
It would have to be generated by a linker or a global source code analyzer. Many years ago, I wrote one in Perl which checked for various things like that in a very large assembly language projects. One of the more interesting things it discovered was something that had lived in the code for a very long time, overlooked by many programmers. It was a piece of code which had conditional assembly. The conditional part was test code which was never put into the actual product, but it wasn't put in quite the right location. The result was something like this: test TestModeFlag jz BeyondTest #ifdef INCLUDE_TEST_CODE TestMode: ; many lines of code... #endif BeyondTest: ; blah, blah, blah... Obviously, if the #ifdef code is not included, both the test and the jump are useless, but because they were separated by a couple hundred lines of test code, nobody spotted it! Our computers can definitely help us spot silly errors, if we use the right tools. Ed