See code below. Due to # of parameter passing limitations, I would like to pass a structure holding a set of parameters to a function as a single parameter and then the function would know how to appropriately make use of the structure. I'm new to this so I don't know if I'm implementing the typecasting correctly for this scenario. I get the following errors on compile time:
Code:
fork.c:93: request for member `param1' in something not a structure or union
fork.c:94: request for member `param2' in something not a structure or union
fork.c: In function `main':
fork.c:115: aggregate value used where an integer was expected
Please advise me on what I need to modify to get this to work as intended.
Code:
typedef struct myargs{
int param1;
int param2;
}MYARGS;
void
eventual_function(int id)
{
//this is the forked function
Wait((MYARGS) id.param1);
Signal((MYARGS) id.param1);
Signal((MYARGS) id.param2);
...
}
int
main()
{
//note fork & semaphore functions custom defined (Nachos OS)
//establish user semaphores
int usrmutex = CreateSemapore(1);
int usrprocsema4 = CreateSemapore(5);
//parse semaphore handles for passing to forked children
MYARGS fncargs;
fncargs.param1 = usrmutex;
fncargs.param2 = usrprocsema4;
Fork(MyThreadA,(int) fncargs);
Wait(usrprocsema4);