Hi, i have a little problem in my code .
Code:
void thread_exit() {
thread_t running_thread = list->element;
thread_t next_thread = list->next->element;
remove_list(&list, running_thread);
thread_switch(running_thread->context, next_thread->context);
}
This function terminate a thread that is running, removing her from the list, and
after removing her, switch the execution context of the thread with the next thread on the list. The problem is that i have to free the structure(running_thread) and her context, but i cant do it before the thread_switch(), neither immediately after, so how can i resolve this problem.