Search code examples
c++timernachos

NachOS timer.cc constructor


I am trying to create a new class in NachOS called alarmclock. In it, I need to create a timer object to use to trigger interrupts. In timer.cc, the constructor is

Timer::Timer(VoidFunctionPtr timerHandler, int callArg, bool doRandom)

Can someone please explain to me what inputs this constructor will take, and what VoidFunctionPtr timerHandler is and how it works? I have absolutely no idea what arguments to pass to this function so I'm just stuck here unable to do anything so far. Any help would be greatly appreciated.

I know it is a pointer to a function, but I do not understand how it works.


Solution

  • timeHandler is basically a pointer to the function we want to execute using the timer. callArg is the input to that function and doRandom is a Boolean for a random Time splicer that generates random interval alarms. It is used when we do not have or need a fixed interval timer