Logo blue background.png

Bruce Powel Douglass, Ph.D.

  • Content

    • Resources
    • Embedded World
    • Papers
    • Presentations
    • Models
    • Harmony aMBSE Overview
    • Harmony aMBSE Functional Analysis
    • Harmony Embedded Software Overview
    • Harmony ESW Nanocycle
    • Safety Analysis and Design
    • Books
    • On the Web
    • Links
  • Services

  • Public Interest

  • Blog

  • What's New

  • Forum

  • About

  • Comments

  • Site Map

  • Geekosphere

  • Members

    • Members Only
  • More

    Use tab to navigate through the menu items.
    To see this working, head to your live site.
    • Categories
    • All Posts
    • My Posts
    Avraham Makeler
    Apr 12, 2020

    Function pointers in activity diagrams

    in UML / SysML

    Hi,


    In a UML activity diagram, what is the correct way of modeling passing a function pointer from one action to another "action"? The "destination action" is of course pretty empty, and all it does is to receive the function pointer (from the source action) and run the function.


    TIA


    Avraham


    8 answers2 replies
    0
    1
    Bruce Douglass
    Apr 13, 2020

    A couple of comments:


    First, this is really below the level of UML per se and is in the realm of the underlying "action language".


    Second, I can see why you might actually want to do this anyway. Here's an approach to address this kind of question. Write out the code you want to replicate and then reverse engineer it into Rhapsody and take a look.


    I took the following code:


    int foo(int i){ return i + 1;}

    typedef int (*g)(int); // Declare typedef

    g func = &foo; // Define function-pointer variable, and initialize

    int hvar = func(3); // Call function through pointer


    and used Tools > Reverse Engineer to bring it into a Rhapsody model. This is what I got. (Figure 1).




    g, the typedef, was brought in as a type (kind: Language) using the following definition (Figure 2).



    The assignment of the variable func is shown in Figure 3.



    Hope this helps.

    1
    Avraham Makeler
    Apr 13, 2020

    >> First, this is really below the level of UML per se and is in the realm of the underlying "action language".


    You mean this (usually) is the low/detail level inside the actions?

    1
    Avraham Makeler
    Apr 13, 2020

    >> First, this is really below the level of UML per se and is in the realm of the underlying "action language".


    I am reverse engineering a system and modeling it in SysML/UML.


    Background if it is of any significance:


    The system is an enormous complex real-time embedded system and mission critical. My area of interest is the System TLD (top-level design) of the operational system. It is the top-most stuff. There is a large number of software engines running on multiple cores on a single board. I call it a SW Engine grid (my made-up term). And some of the engines are defined as being invoked via a function pointers. I don't yet know why they are invoked via function pointers and have not had time to ask.


    So ... in my company, function pointers are used to invoke entire modules.

    1
    Avraham Makeler
    Apr 13, 2020

    >> Here's an approach to address this kind of question. Write out the code you want to replicate and then reverse engineer it into Rhapsody and take a look. Thanks. It would be a good idea. But I have been doing my so called modeling just by drawing SysML/UML diagrams using Visio. That's what I have. No actual MSBE platform (yet). So I am wondering what difference it should make in the SysML/UML diagram: (i) Action A passes control to action B

    as opposed to (ii) Action A sends a function pointer to action B, which uses it to invoke some action C. That was me thinking out loud ...

    1
    Avraham Makeler
    Apr 13, 2020

    i need to get more info on "who" supplies the function pointer to action A, and why does this have to be an indirect function call. I.e., why does the identifying of the address of the function have to be delayed until run-time? Will share it with you when I know more.