I have this function:
void boot(uint ncores, uint nterm, Task boot_task, int argl, void* args)
{
for(int i=0; i<MAX_PROC;i++) {
PT[i].ppid = NOPROC;
}
nextproc = 0;
curproc = NOPROC;
Exec(boot_task, argl, args);
}
and and I want instead of using Exec()
to use pthread
, so I have to call the cpu_boot:
void cpu_boot(uint cores, interrupt_handler bootfunc, uint serialno)
{
//I cannot change this function
}
These are the types of the arguments
typedef void interrupt_handler();
typedef int (* Task)(int, void*);
I've tried:
void boot(uint ncores, uint nterm, Task boot_task, int argl, void* args)
{
void my_wrapper()
{
int y;
y= boot_task(argl, args);
}
cpu_boot(ncores, my_wrapper , nterm);
}
But this is wrong. How can I implement this?
You'll want something like this:
void some_interrupt_handler(){
/* code here */
return;
}
interrupt_handler* my_wrapper(Task boot_task, int argl, void* args)
{
/*
this is where you run boot task
*/
boot_task(argl, args);
/* then pick an interrupt_handler to return... */
void (*function_ptr)() = some_interrupt_handler;
return function_ptr;
}
Then you can use your wrapper like this:
void boot(uint ncores, uint nterm, Task boot_task, int argl, void* args)
{
cpu_boot(ncores, my_wrapper(boot_task, argl, args) , nterm);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With