| Author |
Message |
John Larkin
Guest
|
Posted:
Wed Dec 22, 2004 7:58 am Post subject:
Re: what's a callback? |
|
|
On Wed, 22 Dec 2004 05:00:37 -0000, "Steve at fivetrees"
<steve@NOSPAMTAfivetrees.com> wrote:
| Quote: |
Which returns me to the deliberate brevity of my first post. What *is* going
on here? This thread has redefined not only callbacks, but "static",
re-entrancy, and the value of Pi [1]. The guys here in comp.arch.embedded
usually really know their stuff... ("bunch of arrogant, boring wannabees as
they are" ;).) Are we being cross-contaminated by sci.electronics.design? Is
it all their fault? [2]
[1] I lied about Pi.
[2] Our newsgroup is better than yours. Rrrrrasp!!
|
No, it's my fault. I should have remembered that embedded programmers
and electrical engineers never talk.
John |
|
| Back to top |
|
 |
Scott Stephens
Guest
|
Posted:
Wed Dec 22, 2004 7:58 am Post subject:
Re: what's a callback? |
|
|
Active8 wrote:
| Quote: | To rephrase Rene's statement: a callback is what you use if a function
'foo' needs to be written now, which has to call another function
'bar' that may not exist yet.
http://gethelp.devx.com/techtips/cpp_pro/10min/10min0300.asp
quote
A callback function is one that is not invoked explicitly by the
programmer; rather the responsibility for its invocation is
delegated to another function that receives the callback function's
address.
/quote
Period.
Even an empty function is an *implementation* of a function.
But an empty function is not part of this design --- there's just the
prototype, and a *pointer* to such a function.
|
Isn't that called an interface? Aren't MS COM objects (such as dhtml
Active-X objects) an example of such? The COM object interface are
pointers to an object-specific array of pointers. |
|
| Back to top |
|
 |
John Larkin
Guest
|
Posted:
Wed Dec 22, 2004 7:58 am Post subject:
Re: what's a callback? |
|
|
On Wed, 22 Dec 2004 00:07:45 -0500, Mike Monett <no@spam.com> wrote:
| Quote: | John Larkin wrote:
Here's a good explanation of callbacks:
http://www.tutok.sk/fastgl/callback.html
Best,
Mike Monett
Good grief, but that's hairy stuff. No wonder Windows is such a flakey
pos. Makes me glad I program in assembly, where everything's in plain
sight.
[...]
John
Yes, assembly rocks. High level languages don't let you see what is
actually happening in the registers, so you miss good ways to optimize
the code. Although I prefer to let a good HLL to handle most of the
interface stuff, and focus my attention on the places where assembly can
really pay off in performance.
Another thing - it's amazing what can be accomplished in a few hundred
bytes of assembly. So how on earth can Windows consume hundreds of
megabytes to do basically the same thing? I mean, when a printer driver
requires 600 megabytes, something is seriously broken. There's no way a
cpu could be executing all that code all the time - in fact, there is
nothing that could possibly be that complex. So what is the reason for
the bloat???
Best,
Mike Monett
|
Yeah, this is snipped from the "tutok" web page you referenced...
MemberTranslator1(Callee &c,const MemFunc &m):
Functor1<P1>(thunk,&c,&m,sizeof(MemFunc)){}
static void thunk(const FunctorBase &ftor,P1 p1)
{
Callee *callee = (Callee *)ftor.callee;
MemFunc &memFunc(*(MemFunc*)(void *)(ftor.memFunc));
(callee->*memFunc)(p1);
}
};
OK, imagine trying to understand and maintain 100 millions lines of
code like this. If you passed it through triple-DES encryption, it
couldn't look much worse.
John |
|
| Back to top |
|
 |
CBFalconer
Guest
|
Posted:
Wed Dec 22, 2004 1:59 pm Post subject:
Re: what's a callback? |
|
|
Mike Monett wrote:
| Quote: |
.... snip ...
Another thing - it's amazing what can be accomplished in a few hundred
bytes of assembly. So how on earth can Windows consume hundreds of
megabytes to do basically the same thing? I mean, when a printer driver
requires 600 megabytes, something is seriously broken. There's no way a
cpu could be executing all that code all the time - in fact, there is
nothing that could possibly be that complex. So what is the reason for
the bloat???
|
Largely C++ and templates. Also linkage generally simply grabs
monster blobs, regardless of whether called or not.
--
Chuck F (cbfalconer@yahoo.com) (cbfalconer@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address! |
|
| Back to top |
|
 |
Frank Bemelman
Guest
|
Posted:
Wed Dec 22, 2004 1:59 pm Post subject:
Re: what's a callback? |
|
|
"John Larkin" <john@spamless.usa> schreef in bericht
news:cl1is0558091ki5r5k24093gtdqrcf5fls@4ax.com...
| Quote: |
OK, imagine trying to understand and maintain 100 millions lines of
code like this. If you passed it through triple-DES encryption, it
couldn't look much worse.
|
Well, you write, test, approve and forget ;) Most of the code is
pretty harmless and straight forward anyway.
There's a lot of things behind the scenes. Nobody is amazed when
he/she hits the print button and a printer dialog pops up. And I
have no idea how *your* printer dialog looks like. And neither
has a windows application, when it happens. And the printer driver
has no idea where your printer is, at lpt1, com2, usb or somewhere
on your ethernet network. And of course you expect a gentle warning
that it might be turned off, or has run out of paper or ink.
And you want to run it from 7 applications at the same time, each
using different papersizes, while your secretary wants the same
printer to print a sheet of labels that she has put in the manual
feed tray...
That is just one example. It is a lot easier to write robust code
for a full featured pinball machine.
--
Thanks, Frank.
(remove 'q' and 'invalid' when replying by email) |
|
| Back to top |
|
 |
Frank Bemelman
Guest
|
Posted:
Wed Dec 22, 2004 2:21 pm Post subject:
Re: what's a callback? |
|
|
Steve at fivetrees" <steve@NOSPAMTAfivetrees.com> schreef in bericht
news:HvOdnW5OZoLPYlXcRVn-2g@nildram.net...
| Quote: | "Frank Bemelman" <f.bemelmanq@xs4all.invalid.nl> wrote in message
news:41c8572c$0$1146$e4fe514c@news.xs4all.nl...
OTH, what's in a name. All too often we see old wine in new bags.
I'm with you. I've re-read my own definition, don't like it much, and am
regretting getting involved ;).
Which returns me to the deliberate brevity of my first post. What *is*
going
on here? This thread has redefined not only callbacks, but "static",
re-entrancy, and the value of Pi [1]. The guys here in comp.arch.embedded
usually really know their stuff... ("bunch of arrogant, boring wannabees
as
they are" ;).) Are we being cross-contaminated by sci.electronics.design?
Is
it all their fault? [2]
[1] I lied about Pi.
[2] Our newsgroup is better than yours. Rrrrrasp!!
|
SED is a mess, and a jolly one at that, so a bit of cross-contamination
won't hurt. I got a bit pissed by CBfalconer plonking Genome, SED's
mascotte. The folks at CAE could loosen up a bit, increasing their
value at the same time. Speff even dropped CAE in his follow-ups from
a few subthreads in this one, never seen him do that on SED. The atmosphere
at CAE is of the arrogant, boring wannabees etc.
;)
--
Thanks, Frank.
(remove 'q' and 'invalid' when replying by email) |
|
| Back to top |
|
 |
Roger Hamlett
Guest
|
Posted:
Wed Dec 22, 2004 3:26 pm Post subject:
Re: what's a callback? |
|
|
The silly thing is that the thread has 'run off' into a whole variety of
code areas not associated with a callback at all...
A 'callback', is exactly what it says, and comes from the useage on the
telephone, where you ring somebody, and they say they will 'call back'.
There are a number of reasons. The first would be the obvious one (I'll
call back, when I have the answer). The advantage here is it removes the
need for an 'interrupt' signal to give a fast response, or a polling
process to monitor the response of the subroutine. It can also be used for
a security application (just as on the phone, where your bank 'calls
back', to verify that they are talking to the person expected). This is
rare in PC applications, but is quite common in some other OS's, but can
be used on the PC, so that the 'callback', is operating at a different
security level to the calling code. There is also the 'billing' reason (as
in the phone call, where you call somebody, and they say they will 'call
back', so that the charges go onto their account). In the computer
version, this allows the 'callback', to be using time from the subroutine
process, rather than from the main code. Again this could be at a
different priority to the calling routine.
Best Wishes |
|
| Back to top |
|
 |
Everett M. Greene
Guest
|
Posted:
Wed Dec 22, 2004 5:44 pm Post subject:
Re: what's a callback? |
|
|
"Frank Bemelman" <f.bemelmanq@xs4all.invalid.nl> writes:
| Quote: | "Mike Monett" <no@spam.com> schreef
I think part of the reason for code bloat is programmers have no
restrictions on their code size or performance requirements. They
should be given 200MHz Pentium computers with an 8 gig hard drive
and 64 megs of ram. That would fix slow, bloated code real fast.
Windows isn't bloated at all. There's just a lot of things to be dealt
with, but that happens so incredibly transparent to the casual observer,
that we take it all for granted and assume the code is bloated or something.
|
There's a difference between doing something because it can
be done and doing something because it's needed. Microsoft
can throw the problem of hardware resources over the wall
to the users at no cost to themselves.
| Quote: | For example, my editor uses Borland SPRINT, which was last released
in 1988 and was designed to run on an 8080 with 640k of ram. It
handles 11 different types of files, including html, plain ascii,
pascal, c, assembly, email, newsgroup postings, google groups, etc.
[snip]
Of course, this style of thinking would probably put a lot of
programmers and maybe some companies out of business. For some
strange reason, making things overly complex is good for business.
This style of thinking would probably kept us all back in 1988, the
release date of your editor ;)
|
This is precisely the thinking that's needed and necessary
for /embedded/ computing. Reliability and hardware resources
are directly impacted by keeping things as simple as possible. |
|
| Back to top |
|
 |
Mike Monett
Guest
|
Posted:
Wed Dec 22, 2004 6:04 pm Post subject:
Re: what's a callback? |
|
|
John Larkin wrote:
[...]
| Quote: | Yeah, this is snipped from the "tutok" web page you referenced...
MemberTranslator1(Callee &c,const MemFunc &m):
Functor1<P1>(thunk,&c,&m,sizeof(MemFunc)){}
static void thunk(const FunctorBase &ftor,P1 p1)
{
Callee *callee = (Callee *)ftor.callee;
MemFunc &memFunc(*(MemFunc*)(void *)(ftor.memFunc));
(callee->*memFunc)(p1);
}
};
OK, imagine trying to understand and maintain 100 millions lines
of code like this. If you passed it through triple-DES encryption,
it couldn't look much worse.
John
|
100 million lines? Sad, but Windows is probably getting close.
I think part of the reason for code bloat is programmers have no
restrictions on their code size or performance requirements. They
should be given 200MHz Pentium computers with an 8 gig hard drive
and 64 megs of ram. That would fix slow, bloated code real fast.
For example, my editor uses Borland SPRINT, which was last released
in 1988 and was designed to run on an 8080 with 640k of ram. It
handles 11 different types of files, including html, plain ascii,
pascal, c, assembly, email, newsgroup postings, google groups, etc.
It can load up to 27 files simultaneously and automatically detects
the file type when switching from one window to the next. It
switches the command functions as appropriate for the type of file,
so I don't have to memorize different commands and keystrokes
depending on the file type in the current window.
The editor is very compact and and loads instantly. It rarely
crashes, except when Windows crashes on a bad pointer and messes up
memory. It is blazingly fast on a 200MHz Pentium, so there is
little need for a 2GHz machine (except to read those #$%@&* Adobe
pdf files:)
Of course, this style of thinking would probably put a lot of
programmers and maybe some companies out of business. For some
strange reason, making things overly complex is good for business.
Best,
Mike Monett |
|
| Back to top |
|
 |
CBFalconer
Guest
|
Posted:
Wed Dec 22, 2004 6:09 pm Post subject:
Re: what's a callback? |
|
|
Frank Bemelman wrote:
| Quote: |
.... snip ...
... I got a bit pissed by CBfalconer plonking Genome, SED's mascotte.
The folks at CAE could loosen up a bit, increasing their value at
the same time. Speff even dropped CAE in his follow-ups from a few
subthreads in this one, never seen him do that on SED. The atmosphere
at CAE is of the arrogant, boring wannabees etc.
|
Here is the complete message when I PLONKED him. To me, a crude
reply without content to the only worthwhile (to that date) reply
indicates a pure troublemaker. The message ID is:
<_Apxd.607$uM6.87@newsfe5-gui.ntli.net>. I challenge you to show
any glimmering of intelligence in that.
Genome wrote:
| Quote: | "Hans-Bernhard Broeker" <broeker@physik.rwth-aachen.de> wrote in message
--
Hans-Bernhard Broeker (broeker@physik.rwth-aachen.de)
Even if all the snow were burnt, ashes would remain.
You haven't got a fucking clue.......
|
Interesting that you provide this brilliant reply to the only
response to the original that actually was intelligent. PLONK.
--
Chuck F (cbfalconer@yahoo.com) (cbfalconer@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address! |
|
| Back to top |
|
 |
Frank Bemelman
Guest
|
Posted:
Wed Dec 22, 2004 7:10 pm Post subject:
Re: what's a callback? |
|
|
"Mike Monett" <no@spam.com> schreef in bericht
news:41C970D9.663A@spam.com...
| Quote: |
I think part of the reason for code bloat is programmers have no
restrictions on their code size or performance requirements. They
should be given 200MHz Pentium computers with an 8 gig hard drive
and 64 megs of ram. That would fix slow, bloated code real fast.
|
Windows isn't bloated at all. There's just a lot of things to be dealt
with, but that happens so incredibly transparent to the casual observer,
that we take it all for granted and assume the code is bloated or something.
| Quote: | For example, my editor uses Borland SPRINT, which was last released
in 1988 and was designed to run on an 8080 with 640k of ram. It
handles 11 different types of files, including html, plain ascii,
pascal, c, assembly, email, newsgroup postings, google groups, etc.
|
[snip]
| Quote: | Of course, this style of thinking would probably put a lot of
programmers and maybe some companies out of business. For some
strange reason, making things overly complex is good for business.
|
This style of thinking would probably kept us all back in 1988, the release
date of your editor ;)
--
Thanks, Frank.
(remove 'q' and 'invalid' when replying by email) |
|
| Back to top |
|
 |
Frank Bemelman
Guest
|
Posted:
Wed Dec 22, 2004 7:21 pm Post subject:
Re: what's a callback? |
|
|
"CBFalconer" <cbfalconer@yahoo.com> schreef in bericht
news:41C968B7.CBDDB27F@yahoo.com...
| Quote: | Frank Bemelman wrote:
... snip ...
... I got a bit pissed by CBfalconer plonking Genome, SED's mascotte.
The folks at CAE could loosen up a bit, increasing their value at
the same time. Speff even dropped CAE in his follow-ups from a few
subthreads in this one, never seen him do that on SED. The atmosphere
at CAE is of the arrogant, boring wannabees etc.
Here is the complete message when I PLONKED him. To me, a crude
reply without content to the only worthwhile (to that date) reply
indicates a pure troublemaker. The message ID is:
|
That might be understandable if you didn't also managed to indirectly
insult other contributors, who posted well before the 20th when
you posted this:
| Quote: | Interesting that you provide this brilliant reply to the only
response to the original that actually was intelligent. PLONK.
|
*only*
No netlag excuse here.
--
Thanks, Frank.
(remove 'q' and 'invalid' when replying by email) |
|
| Back to top |
|
 |
Rufus V. Smith
Guest
|
Posted:
Wed Dec 22, 2004 8:39 pm Post subject:
Re: what's a callback? |
|
|
"John Larkin" <john@spamless.usa> wrote in message
news:5qubs0lte0k6n2978mhu0uq423kl6j42d7@4ax.com...
| Quote: | On Sun, 19 Dec 2004 22:00:05 GMT, Fred Bloggs <nospam@nospam.com
wrote:
Anthony Fremont wrote:
"Fred Bloggs" <nospam@nospam.com> wrote in message
No- that is called "setting a flag to remind you to finish some
chores"
and is an example of *re-entrant code*:-) Why in the world would that
be
called "callback" unless you collect useless jargon?
That's certainly the most unique definition of re-entrancy that I've
seen.
When I think of re-entrant code, I think of code that has no local
variable storage associated to it. I also think of code that can call
itself recursively or be executed in several threads across multiple
processors concurrently with only one copy in memory.
I am not going to quibble with your high level semantics- if the code
can be re-entered to perform its processing to completion then it is
re-entrant, period. I am not interested into any universal
all-encompassing definitions. It is a *simple* ISR.
So any code that's ever run more than once is "re-entrant"?
No, that's just code. |
Re-entrant code can be run from multiple threads, and are not
dependent upon one thread running the code to completion
before the other thread can run the same code.
Typically re-entrant code has no side-effects, and no
static variables. Everything modified typically is in registers
or on the stack, (or perhaps passed as a parameter by
the caller).
All ISRs should be re-entrant, though they needn't be,
if you control your interrupt sources.
Re-entrant code isn't simply an ISR. When threads
are swapped preemptively, any routine that could
be interrupted and called by another thread needs
to be re-entrant.
I guess that's the same thing I said in the first
paragraph.
Rufus |
|
| Back to top |
|
 |
Hans-Bernhard Broeker
Guest
|
Posted:
Wed Dec 22, 2004 8:56 pm Post subject:
Re: what's a callback? |
|
|
[F'up2 cut down, _again_]
In comp.arch.embedded Frank Bemelman <f.bemelmanq@xs4all.invalid.nl> wrote:
| Quote: | "CBFalconer" <cbfalconer@yahoo.com> schreef in bericht
news:41C968B7.CBDDB27F@yahoo.com...
Here is the complete message when I PLONKED him. To me, a crude
reply without content to the only worthwhile (to that date) reply
indicates a pure troublemaker. The message ID is:
That might be understandable if you didn't also managed to indirectly
insult other contributors, who posted well before the 20th when
you posted this:
|
Your newsreader is distorting your view of the world, I think. In a
properly threaded view of this thread, this message by Mr. Falconer
| Quote: | Interesting that you provide this brilliant reply to the only
response to the original that actually was intelligent. PLONK.
|
which has you so upset is about the *6th* in the entire thread (and 4
levels deep) not the 20th. If it's 20th in yours, that means you're
using inappropriate tools, and should be very careful using their
results as arguments.
| Quote: | No netlag excuse here.
|
Terminally sick newsreaders are even less of one. Just because
Web-based "forums" that so many newbies prefer over USENET generally
don't manage to get this anywhere nearly right, doesn't mean we should
degrade USENET in a similar way.
--
Hans-Bernhard Broeker (broeker@physik.rwth-aachen.de)
Even if all the snow were burnt, ashes would remain. |
|
| Back to top |
|
 |
Frank Bemelman
Guest
|
Posted:
Wed Dec 22, 2004 9:17 pm Post subject:
Re: what's a callback? |
|
|
"Hans-Bernhard Broeker" <broeker@physik.rwth-aachen.de> schreef in bericht
news:32tjp5F3qs4rrU1@news.dfncis.de...
| Quote: | [F'up2 cut down, _again_]
In comp.arch.embedded Frank Bemelman <f.bemelmanq@xs4all.invalid.nl
wrote:
"CBFalconer" <cbfalconer@yahoo.com> schreef in bericht
news:41C968B7.CBDDB27F@yahoo.com...
Here is the complete message when I PLONKED him. To me, a crude
reply without content to the only worthwhile (to that date) reply
indicates a pure troublemaker. The message ID is:
That might be understandable if you didn't also managed to indirectly
insult other contributors, who posted well before the 20th when
you posted this:
Your newsreader is distorting your view of the world, I think. In a
properly threaded view of this thread, this message by Mr. Falconer
Interesting that you provide this brilliant reply to the only
response to the original that actually was intelligent. PLONK.
which has you so upset is about the *6th* in the entire thread (and 4
levels deep) not the 20th. If it's 20th in yours, that means you're
using inappropriate tools, and should be very careful using their
results as arguments.
|
I was referring to the date, 20th December, not the place or
level in the thread. Other contributions were posted on the 19th.
| Quote: | No netlag excuse here.
Terminally sick newsreaders are even less of one. Just because
Web-based "forums" that so many newbies prefer over USENET generally
don't manage to get this anywhere nearly right, doesn't mean we should
degrade USENET in a similar way.
|
I don't like those web forums too, for exactly the same reasons.
--
Thanks, Frank.
(remove 'q' and 'invalid' when replying by email) |
|
| Back to top |
|
 |
|
|
|
|