Use of Function Pointer in Embedded Systems

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
Hi All,
         I am Ravi Kumar.N, I have an issue regarding function pointer.

1) What is the advantage of using function pointers in embedded
systems.

2) What is the difference between an ordinary function call and calling
a function through function pointer.

3)Where all, function pointers can be used.


With Regards,
      Ravi Kumar.N


Re: Use of Function Pointer in Embedded Systems
Hi All,
         I am Ravi Kumar.N, I have an issue regarding function pointer.

1) What is the advantage of using function pointers in embedded
systems.

2) What is the difference between an ordinary function call and calling
a function through function pointer.

3)Where all, function pointers can be used.


With Regards,
      Ravi Kumar.N


Re: Use of Function Pointer in Embedded Systems
Quoted text here. Click to load it

IMO, the same as using them in non-embedded systems.

Quoted text here. Click to load it

One level more of indirection.

Quoted text here. Click to load it

I use explicit function pointers only in function tables --to implement
state-mechines (sometimes) or call-backs (some-times)--, and in some
special situations I cannot remember now (Friday afternoon, one beer
more than needed)

Quoted text here. Click to load it

Re: Use of Function Pointer in Embedded Systems

Quoted text here. Click to load it

No particular advantage, embedded systems are nothing special from this
point of view.


Quoted text here. Click to load it

Click here: <http://www.google.co.uk/search?q=%22function+pointer%22+call
, then click the first result.

HTH,

   Vadim

Re: Use of Function Pointer in Embedded Systems


Quoted text here. Click to load it

There is at least one disadvantage, by making it
point to a wrong address either voluntarily or not
you can create interesting situations.

you must use them with great care. One safe solution
is to initialize them at compile time and not at
run time.

You should also avoid explicit casts, and use a
typedef.

Quoted text here. Click to load it


Re: Use of Function Pointer in Embedded Systems

Quoted text here. Click to load it

Sometimes it is just not possible, like ARM ADS compiler generating
position-independent code.  The only option is run-time initialisation.

And, *anything* should be used with great care :)


   Vadim

Re: Use of Function Pointer in Embedded Systems
I use function pointer a lot when writing library code where some action
or event might be of interest to the end programmer.

I'll give you one use of a function pointer.
Our system  (Netburner) has a facility for updating the code over the network.

Before the code is updated one might want to shut down critical  processes.
The update code is part our our library, the shut down code is most likely our
customers own code.  So we provide a shutdown function pointer.
It gets initialized to NULL, if the customer wants to have his code do something
for shutdown,
he points the global function pointer at the his shutdown code.

Our library checks to see if the pointer is null, if not it calls the function
at the aproprriate place.


Paul








On 15 Jul 2005 07:05:58 -0700, ravikumar.n@sunlux-india.com wrote:

Quoted text here. Click to load it


Re: Use of Function Pointer in Embedded Systems
Quoted text here. Click to load it

This troll has multi-posted this same query in at least three
newsgroups.  Ignore it.

--
"If you want to post a followup via groups.google.com, don't use
 the broken "Reply" link at the bottom of the article.  Click on
We've slightly trimmed the long signature. Click to see the full one.
Re: Use of Function Pointer in Embedded Systems
Quoted text here. Click to load it

Homework?

--

Tauno Voipio
tauno voipio (at) iki fi


Re: Use of Function Pointer in Embedded Systems
ravikumar.n@sunlux-india.com writes:

Quoted text here. Click to load it

It is possible to hide the called function from the calling
function. This means that third-party software on the embedded system
does not know where it is being called from, and so cannot present an
inappropriate user interface for the country the system is deployed in.

Also, it increases the metric "information hiding" in the programmer
analysis package, thus resulting in increased payments for higher
quality code to the programmer.

Quoted text here. Click to load it

As far as we have been able to tell in this newsgroup, calling a
function through a function pointer will call a library subroutine on
the commercial compilers. On sdcc, it will generate inline code - this
is much less efficient for many calls, but if you were worrying about
efficiency you wouldn't be using function pointers.

Quoted text here. Click to load it

In England, we prefer not to use them in a room where mixed-gender
groups are gathered. Mostly, this is because in these situations we have
more direct access to the member parts of friend functions, and so can
call them directly. However, in other countries, excess drapery is
required in mixed-gender groups - in these areas, the passing around of
function pointers is the only way to excite these member functions.

cheers, Rich.

Quoted text here. Click to load it

[following the comp.arch tradition in these things]

--
rich walker         |  Shadow Robot Company | snipped-for-privacy@shadow.org.uk
technical director     251 Liverpool Road   |
We've slightly trimmed the long signature. Click to see the full one.

Site Timeline