Round Robin Scheduling via UCONTEXT.H

Hi
I am implementing Round Robin Scheduling using ucontext.h functions.
Well i am using my own logic for round robin but i am stuck at one point.

I am using swapcontext for shifting from one process to another. Now how do i get to know that after 4 sec(Round Robin Time) where the process has stopped. Means

If Fun1 requires 6 seconds...swapcontext can be used but if the function requires only 3 sec...how do i get to know that the function is finished??

Please help me...m onlione here for next 9 hrs...

Like this guy? Laboratory Exercise: Execution Context