static const sigset_t * thr_remove_thr_signals(const sigset_t *set, sigset_t *newset) { *newset = *set; remove_thr_signals(newset); return (newset); }
/* Returns -1 if failed 0 if ok >0 if threads where left on KILLING state because of page fault (i.e swap read pending) */ int thr_destroy_thread(UINT16 thread_id) { struct pm_thread * thr = thr_get(thread_id); int ret = 0; /* NOTE: Don't think about resting VMM info on this function. It will be used if we already have a pending read/write of a page for this thread, and thread must stay KILLED. */ if(thr == NULL) { return -1; } else { if(thr->state != THR_KILLED && destroy_thread(thread_id) != SUCCESS) { return -1; } else { struct pm_task *task = tsk_get(thr->task_id); if(task == NULL) return -1; if(thr->state != THR_KILLED) { task->num_threads--; /* Fix Task List */ if(task->first_thread == thr) { task->first_thread = thr->next_thread; } else { // add a prev thread !!! this is awful struct pm_thread *currTrhead = task->first_thread; while(currTrhead != NULL && currTrhead->next_thread != thr) { currTrhead = currTrhead->next_thread; } currTrhead->next_thread = thr->next_thread; } } // remove the thread signals remove_thr_signals(thr); if(thr->state != THR_KILLED && (thr->flags & (THR_FLAG_PAGEFAULT | THR_FLAG_PAGEFAULT_TBL))) { /* Thread is waiting for a page fault (either swap or PF) */ thr->state = THR_KILLED; ret = 1; } else { thread_info[thr->id] = NULL; kfree(thr); thr = NULL; } if(thr != NULL) { if(thr->state == THR_KILLED) task->killed_threads--; if(thr->interrupt != 0) int_dettach(thr); /* Remove thread from scheduler */ sch_remove(thr); } return ret; } } }