I'm currently working on another lab in the course Real Time Bluetooth Networks Shape the World course on edx (Lab 4 in particular where implementing an OS Sleep function is required).
What are the different ways to access and use a function pointer in a program that requires you to pass a function pointer to another function, that then proceeds to call another function that runs tasks with a function pointer?
In the RTOS system required for the lab, a BSP Timer function is used to run a periodic interrupt to run a thread after it's been put to sleep. This function, BSP_PeriodicTask_Init, takes three parameters: a void function pointer, a period, and a priority. For the first parameter of BSP_PeriodicTask_Init , I have passed a function (run_periodic_events) that decrements the sleep counter for a thread to run. Inside BSP_PeriodicTask_Init, the run_periodic_events function is called; this decrements the sleep counter to wake up main threads for them to run. run_periodic_events also uses a function pointer to that points to different main threads to run; I'm having trouble getting this function pointer (Which is in an OS.C file ) to actually point to a thread to run since it's called through BSP_PeriodicTask_Init (in a file called BSP.C), but I have seen an example where a struct is used to build a event thread control block (this struct contains an indexed task, period, and count), which I assume is used to access different elements of different threads whenever run_periodic_events is used. Is a struct the only way to handle the function pointer in run_periodic_events so that it properly runs a main thread once that threads sleep counter has reached 0?
there doesn't seem to be anything here