what's a callback?
CASTalk.com Forum Index CASTalk.com
Discussion of DSP, FPGA, storage and embedded system.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web castalk.com
what's a callback?
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8, 9, 10  Next
 
Post new topic   Reply to topic    CASTalk.com Forum Index -> Embedded System
Author Message
Martin Riddle
Guest





Posted: Mon Dec 20, 2004 3:00 am    Post subject: Re: what's a callback? Reply with quote

Its funny how many answers it takes. ;D

"Frank Bemelman" <f.bemelmanq@xs4all.invalid.nl> wrote in message news:41c5efcb$0$90756$e4fe514c@news.xs4all.nl...
Quote:
"John Larkin" <john@spamless.usa> schreef in bericht
news:2onbs01b2vcbsmls7bd7qqdlo8kvafuolk@4ax.com...
A few programmers I've known have used the term "callback", which
somehow related to executing a deferred subroutine or something. Does
anybody know anything about this term or its conventions? If I google
it, I just get a lot of telephone-type references.

It's when you pass the address of a function to the operating
system. Often used to change the standard behaviour of gadgets
supplied by the OS, and where only your program 'knows' how
it should be done. Such an example is the open-file-box that
windows presents, which can have many different 'faces' depending
on the application that calls it. Some common options can be
changed by simple parameters, but if you want some really odd
behaviour, you write the tricky part of the code yourself and use a
callback. Also called a hook.

I'm doing a thing now where, in an interrupt service routine, if I
think I'm out of time I set a flag to remind me to finish some chores
next time or so. I'm not sure if that qualifies as a "callback."

Like you say, it's a flag. An alternative to a single flag
could be a stack or queue of 'things that need to be done'.
Or un-done ;)

--
Thanks, Frank.
(remove 'q' and 'invalid' when replying by email)

Back to top
John Larkin
Guest





Posted: Mon Dec 20, 2004 3:04 am    Post subject: Re: what's a callback? Reply with quote

On Sun, 19 Dec 2004 21:54:34 GMT, Fred Bloggs <nospam@nospam.com>
wrote:

Quote:


John Larkin wrote:
On Sun, 19 Dec 2004 21:32:42 GMT, Fred Bloggs <nospam@nospam.com
wrote:



John Larkin wrote:

A few programmers I've known have used the term "callback", which
somehow related to executing a deferred subroutine or something. Does
anybody know anything about this term or its conventions? If I google
it, I just get a lot of telephone-type references.

I'm doing a thing now where, in an interrupt service routine, if I
think I'm out of time I set a flag to remind me to finish some chores
next time or so. I'm not sure if that qualifies as a "callback."

John

No- that is called "setting a flag to remind you to finish some chores"
and is an example of *re-entrant code*:-)


The isr is not re-entrant.

Yes it is:
"Used to describe code which can have multiple simultaneous,
interleaved, or nested invocations which will not interfere with each
other. This is important for parallel processing, recursive functions or
subroutines, and interrupt handling."

It just runs periodically to completion (in
about 12 usec) and takes various paths each run, depending on what
needs to be done. The flag makes sure I get all the necessary stuff
done, sooner or later.

Right- so that would be interleaved calls.

That's all nice, but my isr isn't reentrant and is simply executed
periodically and runs to completion every time. There's no os, no
multitasking, no nested interrupts, the variables are static, so it
can't be re-entered. No interleaving, either, just a couple of
conditional branches within the routine.

I've written reentrant code (and reentrant isr's and three
multitasking RTOSs) and this ain't.

This is in a 68332 with 8-bit eprom. At startup time, the "prototype"
routine is copied from eprom into the CPU internal ram, where it's
executed. That's a lot faster.

John
Back to top
John Larkin
Guest





Posted: Mon Dec 20, 2004 3:04 am    Post subject: Re: what's a callback? Reply with quote

On Sun, 19 Dec 2004 21:50:21 GMT, "Anthony Fremont"
<spam@anywhere.com> wrote:

Quote:

"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.


AKA "pure" code.

John
Back to top
John Larkin
Guest





Posted: Mon Dec 20, 2004 3:07 am    Post subject: Re: what's a callback? Reply with quote

On Sun, 19 Dec 2004 22:00:05 GMT, Fred Bloggs <nospam@nospam.com>
wrote:

Quote:


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"?

John
Back to top
Anthony Fremont
Guest





Posted: Mon Dec 20, 2004 3:15 am    Post subject: Re: what's a callback? Reply with quote

Fred Bloggs wrote:
Quote:
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.

I thought you were referring to the act of him using a flag as being an
example of re-entrancy. I didn't know you were refering to the ISR in
general.

At any rate, an ISR is not necessarily re-entrant. I would say that
most interrupt handlers in the 8/16 bit micro world are not.
Back to top
Fred Bloggs
Guest





Posted: Mon Dec 20, 2004 3:17 am    Post subject: Re: what's a callback? Reply with quote

John Larkin wrote:
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"?

John


I am thinking of real-time assembler- you are doing something else. If
these tasks to be done have some global status variable indicating the
what service tasks have been done and are yet to be done, then a
re-entrant ISR which reads this status does what you want.
Back to top
Frank Bemelman
Guest





Posted: Mon Dec 20, 2004 3:18 am    Post subject: Re: what's a callback? Reply with quote

"Fred Bloggs" <nospam@nospam.com> schreef in bericht
news:41C5F208.9060707@nospam.com...
Quote:


Frank Bemelman wrote:

It's when you pass the address of a function to the operating
system. Often used to change the standard behaviour of gadgets
supplied by the OS, and where only your program 'knows' how
it should be done. Such an example is the open-file-box that
windows presents, which can have many different 'faces' depending
on the application that calls it. Some common options can be
changed by simple parameters, but if you want some really odd
behaviour, you write the tricky part of the code yourself and use a
callback. Also called a hook.

Sounds simple enough- think I used something similar long before there
ever was such a word.

It is a simple concept. I think the word 'hook was more common with
hardware interrupts or hardware related bios calls. Later, with
graphical user interfaces, Apple Mac and GEM, these mechanisms were
named callbacks. I guess, under that name they must be around for
20-25 years...

--
Thanks, Frank.
(remove 'q' and 'invalid' when replying by email)
Back to top
steven
Guest





Posted: Mon Dec 20, 2004 3:48 am    Post subject: Re: what's a callback? Reply with quote

"John Larkin" <john@spamless.usa> wrote in message
news:2onbs01b2vcbsmls7bd7qqdlo8kvafuolk@4ax.com...
Quote:
A few programmers I've known have used the term "callback", which
somehow related to executing a deferred subroutine or something. Does
anybody know anything about this term or its conventions? If I google
it, I just get a lot of telephone-type references.

I'm doing a thing now where, in an interrupt service routine, if I
think I'm out of time I set a flag to remind me to finish some chores
next time or so. I'm not sure if that qualifies as a "callback."

John


Example.
Take the Windows GDI LineDDA function. It takes 2 points as input and
calculates all points that make a line between them. Now LineDDA calculates
the first point, but it can't just return to the caller because the other
points have to be calculated too. OTOH, it doesn't know what to do with the
point (should it be drawn on a canvas, or added to a list?)
That's why the calling routine has to supply a pointer to a callback
function. Each time LineDDA has calculated a point it passes it to the
callback function. The callback function may draw the point on a canvas,
that's part of the application, and after it's done it returns control back
to the LineDDA function, which then goes on to calculate the next point.
So the application calls LineDDA, and during the LineDDA algorithm it calls
back an application function.
In the LineDDA case the callback will called several times, but it could
also be just once.

Another example.
Hans-Bernhard already mentioned sorting.
Sorting can only be done within ordered set. Numerical lists are ordered
differently from numerical lists, so you'll have different compare
functions. Apart from the comparison itself however, the sorting algorithm
can be the same for any type of set.
So you write a sort routine requiring a callback function. The sorting
routine knows when which item should be compared to which other. That's
defined in the algorithm. But it doesn't know how thsi comparison is to be
done. So it calls the callback, saying "hey, I've got an item A and an item
B here which require comparison. Which should go first?". The callback
function decides and returns the result to the sorting routine, which may
e.g. decide that A and B should be swapped.

HTH

--
Steven
Back to top
Richard Henry
Guest





Posted: Mon Dec 20, 2004 4:46 am    Post subject: Re: what's a callback? Reply with quote

"John Larkin" <john@spamless.usa> wrote in message
news:2onbs01b2vcbsmls7bd7qqdlo8kvafuolk@4ax.com...
Quote:
A few programmers I've known have used the term "callback", which
somehow related to executing a deferred subroutine or something. Does
anybody know anything about this term or its conventions? If I google
it, I just get a lot of telephone-type references.

I'm doing a thing now where, in an interrupt service routine, if I
think I'm out of time I set a flag to remind me to finish some chores
next time or so. I'm not sure if that qualifies as a "callback."

My experience with them is that when a piece of system software loads, such
as a device driver, that any application might want to call without knowing
where it is located, the driver will load an address in a system table (tied
to hardware or software interrupts, perhaps) so the application can find the
function when needed.
Back to top
Genome
Guest





Posted: Mon Dec 20, 2004 6:07 am    Post subject: Re: what's a callback? Reply with quote

"Hans-Bernhard Broeker" <broeker@physik.rwth-aachen.de> wrote in message
news:32m65bF3mf4mgU1@news.dfncis.de...
Quote:
--
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.......

Go on prove me wrong.

DNA
Back to top
nospam
Guest





Posted: Mon Dec 20, 2004 6:11 am    Post subject: Re: what's a callback? Reply with quote

John Larkin <john@spamless.usa> wrote:

Quote:
A few programmers I've known have used the term "callback", which
somehow related to executing a deferred subroutine or something. Does
anybody know anything about this term or its conventions?

When you pass the address of a subroutine (usually in your code) to
something so that something can call the passed subroutine the subroutine
would often be called a callback.

Typically used for things like a list iterating routine where the callback
would be called for each item in the list.
Back to top
john jardine
Guest





Posted: Mon Dec 20, 2004 6:15 am    Post subject: Re: what's a callback? Reply with quote

"John Larkin" <john@spamless.usa> wrote in message
news:2onbs01b2vcbsmls7bd7qqdlo8kvafuolk@4ax.com...
Quote:
A few programmers I've known have used the term "callback", which
somehow related to executing a deferred subroutine or something. Does
anybody know anything about this term or its conventions? If I google
it, I just get a lot of telephone-type references.

I'm doing a thing now where, in an interrupt service routine, if I
think I'm out of time I set a flag to remind me to finish some chores
next time or so. I'm not sure if that qualifies as a "callback."

John



It's just windows hyperbola. Click a (say) button somewhere and the ID

number you gave the button is stored on the "message" stack. At some point
in your prog' you may wish to rummage through the messages to see if that
particular number has turned up.
If you've a PowerBasic for windows, the help file makes a (bad!) effort to
describe it.
regards
john
Back to top
Genome
Guest





Posted: Mon Dec 20, 2004 6:26 am    Post subject: Re: what's a callback? Reply with quote

"john jardine" <john@jjdesigns.fsnet.co.uk> wrote in message
news:cq58nu$v5j$1@newsg2.svr.pol.co.uk...
Quote:

describe it.
regards
john




Cunt... what is the recipe for haggis?
Aye?
Aye?
Aye?

DNA
Back to top
Spehro Pefhany
Guest





Posted: Mon Dec 20, 2004 6:36 am    Post subject: Re: what's a callback? Reply with quote

On Mon, 20 Dec 2004 01:26:41 GMT, the renowned "Genome"
<ilike_spam@yahoo.co.uk> wrote:

Quote:

"john jardine" <john@jjdesigns.fsnet.co.uk> wrote in message
news:cq58nu$v5j$1@newsg2.svr.pol.co.uk...

describe it.
regards
john




Cunt... what is the recipe for haggis?
Aye?
Aye?
Aye?

DNA

Don't forget to prick your haggis.

Traditional Haggis (from Evelyn Hlabse, esh2@po.CWRU.Edu)

1 sheep's pluck (stomach bag)
2 lb.. dry oatmeal
1 lb. suet
1 lb. lamb's liver
2 1/2 cups stock
1 large chopped onion
1/2 tsp. cayenne pepper, Jamaica pepper and salt

Boil liver and parboil the onion, then mince them together. Lightly
brown the oatmeal. Mix all ingredients together. Fill the sheep's
pluck with the mixture pressing it down to remove all the air, and sew
up securely. Prick the haggis in several places so that it does not
burst. Place haggis in boiling water and boil slowly for 4-5 hours.
Serves approximately 12.

http://www.tulsascots.com/photos/haggis.jpg
http://haradakun.cool.ne.jp/shashin/haggis.jpg


Best regards,
Spehro Pefhany
--
"it's the network..." "The Journey is the reward"
speff@interlog.com Info for manufacturers: http://www.trexon.com
Embedded software/hardware/analog Info for designers: http://www.speff.com
Back to top
John Larkin
Guest





Posted: Mon Dec 20, 2004 7:42 am    Post subject: Re: what's a callback? Reply with quote

On Sun, 19 Dec 2004 20:36:53 -0500, Spehro Pefhany
<speffSNIP@interlogDOTyou.knowwhat> wrote:

Quote:
On Mon, 20 Dec 2004 01:26:41 GMT, the renowned "Genome"
ilike_spam@yahoo.co.uk> wrote:


"john jardine" <john@jjdesigns.fsnet.co.uk> wrote in message
news:cq58nu$v5j$1@newsg2.svr.pol.co.uk...

describe it.
regards
john




Cunt... what is the recipe for haggis?
Aye?
Aye?
Aye?

DNA

Don't forget to prick your haggis.

Traditional Haggis (from Evelyn Hlabse, esh2@po.CWRU.Edu)

1 sheep's pluck (stomach bag)
2 lb.. dry oatmeal
1 lb. suet
1 lb. lamb's liver
2 1/2 cups stock
1 large chopped onion
1/2 tsp. cayenne pepper, Jamaica pepper and salt

Boil liver and parboil the onion, then mince them together. Lightly
brown the oatmeal. Mix all ingredients together. Fill the sheep's
pluck with the mixture pressing it down to remove all the air, and sew
up securely. Prick the haggis in several places so that it does not
burst. Place haggis in boiling water and boil slowly for 4-5 hours.
Serves approximately 12.


Serves approximately 11, if you invite me.

John
Back to top
 
Post new topic   Reply to topic    CASTalk.com Forum Index -> Embedded System All times are GMT
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8, 9, 10  Next
Page 2 of 10

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




VoIP Electronics Powered by phpBB