Exemple #1
0
static inline struct thread *get_free_thread(void)
{
	struct thread *t;
	struct cpu_info *ci;
	struct cpu_info *new_ci;

	if (thread_list_empty(&free_threads))
		return NULL;

	t = pop_thread(&free_threads);

	ci = cpu_info();

	/* Initialize the cpu_info structure on the new stack. */
	new_ci = thread_cpu_info(t);
	*new_ci = *ci;
	new_ci->thread = t;

	/* Reset the current stack value to the original. */
	t->stack_current = t->stack_orig;

	return t;
}
Exemple #2
0
bool UDTPPeer::remove_thread()
{
    if(get_thread_count()  <= 0) return false;

    UDTPThreadFlow *removeFlowThread = front_flow_thread();
    UDTPThreadProcess *removeProcessThread = front_process_thread();

    removeFlowThread->kill();

    removeProcessThread->kill();
    sem_post(&_semProcessChunkThread); /*Have to post one!*/

    close(removeFlowThread->flow_socket()); /****FIND A WAY TO CLOSE BUT KEEP WHATEVER IS REMAINING INSIDE!*/

    removeFlowThread = NULL;
    removeProcessThread = NULL;


    std::cout << "PEER " << get_unique_id() << " has removed a flow and process thread!"  << std::endl;
    decrement_thread_count();
    pop_thread();
    return true;
}
Exemple #3
0
static inline struct thread *pop_runnable(void)
{
	return pop_thread(&runnable_threads);
}