I am creating a user defined thread library. I use Round-Robin
scheduling algorithm and use the context switching
method. But, I am unable to know what to do when a thread finishes its execution before the allotted time slot
. The program is getting terminated. I actually want to reschedule all the threads, by calling the schedule
function when the current thread gets terminated.
I found two ways to overcome this problem.
- By calling explicitly
thread_exit
function at the end of the function that is being executed by the current thread. - By changing the
stack contents
such that thethread_exit
function gets executed after the current function gets terminated.
But I am unable to find how to apply these solutions.... Anybody out there... plz help me...