简体   繁体   中英

Why is makecontext not calling my function?

My program contains the line:

 makecontext( &threadList[ numThreads ].context, (void (*)(void)) &threadStart, 1, 5);

Where threadStart() is defined as:

      static void threadStart(int x){
      printf("Yes! Yes! %d\n", x);
 }

I thought this should result in the display of "Yes! Yes! 5", but this does not happen. I'm not sure what is happening. I know the line is running, since I have a print statement just below it. Any help is appreciated.

The function is only called when the context gets activated by setcontext() or swapcontext()

makecontext(3)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM