I am testing for multitasking. I am facing with a problem. I create 2 tasks for 2 functions below
When i printed the address of variable i in 2 functions (run in 2 threads), it is pointed to same address when the os run into loops. If function "count" run first, the address of i in function "count" is also use for the address of i in function "ask".The same situation if the function "ask" run first. I also checked that rsp and other registers are saved and loaded correctly.int TaskTest::count(int argc, char** argv)
{
int i, j, k;
uint64 rsp;
READ_CPU(RSP, rsp);
printf(" count %d %s %p %p", argc, argv[0], &i, rsp);
for (i = 0; i < 6; i++)
{
for (j = 0; j < 3000; j++)
for (k = 0; k < 5000; k++)
{}
READ_CPU(RSP, rsp);
printf("[count %d %p %p]", i, &i, rsp);
}
printf("\n[End count]\n");
return 0;
}
int TaskTest::ask(int argc, char** argv)
{
int i, j, k;
uint64 rsp;
READ_CPU(RSP, rsp);
printf(" ask %d %s %p %p", argc, argv[0], &i, rsp);
for (i = 0; i < 6; i++)
{
for (j = 0; j < 3000; j++)
for (k = 0; k < 5000; k++)
{}
READ_CPU(RSP, rsp);
printf(" [ask %d %p %p] ", i, &i, rsp);
}
printf("\n [End ask] \n");
return 1;
}
Does anyone know about that? Thanks