Function Pointer Question

Malte Vesper malte.vesper at postgrad.manchester.ac.uk
Thu Apr 2 07:00:35 EDT 2015


Since I am not sure what you are refering to exactly it is hard to 
answer. Refer to an example maybe? Also take a look at i.e. std::sort / 
the compare type (you seem to be a c++ guy). Why do we need a pointer 
there (actually function object, slight generalization of a funciton 
pointer)?

Why would it be helpful to define your on method to be called on wakeup 
(one of the places where I know fp's are used)?

On 02/04/15 11:54, Nicholas Krause wrote:
>
> On April 2, 2015 6:15:19 AM EDT, Malte Vesper <malte.vesper at postgrad.manchester.ac.uk> wrote:
>> Virtual functions are implemented on on the base of vtables, which in
>> turn are implemented using function pointers.
>> So it would be good to get a grasp on functionpointers (they exist in
>> C++ as well), also I believe this is not a C mailing list, take a look
>> at stackoverflow or a c/c++ site or book of your choice.
>> If you know how a pointer works, you will find it easy to understand
>> how
>> a functionpointer works.
>>
>> On 02/04/15 05:16, Nicholas Krause wrote:
>>> Greetings All,
>>> I'm a little rough with how function pointers work in C. I assumed
>> there similar to way C++ stores virtual functions internally in  the
>> vtable for virtual functions  by the compiler and checks the table at
>> runtime. Please let me know if I'm wrong in my understanding.
>>> Thanks,
>>> Nick
>>>
> I looked in to it and the kernel seems to be one of the few places where this is done along with in line functions.  Why do we need function pointers in the kernel, outside of device drivers is my real question and is there any way to do the code using them without function pointers at all, I am assuming no.
> Thanks,
> Nick




More information about the Kernelnewbies mailing list