Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 277 Vote(s) - 3.67 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Are function callback and interprocess communication are same?

#1
Few days back, in an interview one question was asked to me as,

Are function callback in C and interprocess communication are same?
I was bit neutral in that question.Because I was in a dilemma. In IPC we communicate between process to process at the end if we shall see process is nothing but a function. Here one function calls other function. In function callback we use `function pointer` again that is one function calls other function with address.
So just wanted to know though they are not completely same, so what the difference?
Reply

#2
A function callback means caller and callee are in the same thread. IPC is in different processes. a process is comprised of one or more threads. Ergo, callbacks are not IPC.
Reply

#3
No, not really.

Function callback is passing the address (or some other identifier) of a function to another function so that it can call back for some reason.

The classic example is the C standard library `qsort` function. You pass in a pointer to the array (and its sizes), along with a comparison function. The `qsort` function then uses that comparison function (the callback) to decide which of any two elements in the list is greater so that it can arrange them in order.

IPC, on the other hand, is a means for processes to communicate with each other, such as shared memory, pipes, semaphores and so on.

Some IPC mechanisms may _use_ callbacks but it's by no means necessary. For example, sockets don't use callbacks, they simply allow a user to call `read` and `write`.

Similarly with shared memory, you attach to the memory blocks and simply access them much the same as "regular" memory, it's just that the effects are felt across all processes attached to that memory.

One that _does_ sort of use callbacks is ONC RPC (or Sun RPC). It runs a server which awaits client calls over the network and passes them to a pre-configured client function. More detail can be found [here][1].

But, even then, I'd be hesitant to call it a callback since it's really configured at compile-time. "Proper" callbacks tend to be done at run-time.

[1]:

[To see links please register here]

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through