void Kill(TCB* thread) { Unblock_waiting_for_me(thread); TCB_list_remove(all_threads, thread); // Removes thread from list of current threads thread_counter--; free(thread->waiting_for_me); // Frees list of threads blocked by the thread that exited free(thread); // Frees pointer to thread that exited }
int TCB_unblock(TCB* waiting_thread, TCB* blocking_thread) { if(blocking_thread == NULL) { return ERROR; } else if(waiting_thread == NULL) { return ERROR; } else { TCB_list_remove(blocking_thread->waiting_for_me, waiting_thread); waiting_thread->state = READY; return NO_ERROR; } }