Set the thread->proc in proc_add_thread()
This commit is contained in:
		
							parent
							
								
									3a4722a83e
								
							
						
					
					
						commit
						7ba810fd4a
					
				| @ -155,6 +155,8 @@ proc_add_thread(struct proc *proc, struct thread *thread) | ||||
| 	HASH_ADD_INT(proc->threads, tid, thread); | ||||
| 	proc->nthreads++; | ||||
| 
 | ||||
| 	thread_set_proc(thread, proc); | ||||
| 
 | ||||
| 	return 0; | ||||
| } | ||||
| 
 | ||||
|  | ||||
| @ -28,7 +28,7 @@ create_thread(struct proc *proc, const char *relpath) | ||||
| 		return NULL; | ||||
| 	} | ||||
| 
 | ||||
| 	if (thread_init_begin(thread, proc, relpath) != 0) { | ||||
| 	if (thread_init_begin(thread, relpath) != 0) { | ||||
| 		err("cannot init thread"); | ||||
| 		return NULL; | ||||
| 	} | ||||
|  | ||||
| @ -61,13 +61,12 @@ thread_relpath_get_tid(const char *relpath, int *tid) | ||||
| } | ||||
| 
 | ||||
| int | ||||
| thread_init_begin(struct thread *thread, struct proc *proc, const char *relpath) | ||||
| thread_init_begin(struct thread *thread, const char *relpath) | ||||
| { | ||||
| 	memset(thread, 0, sizeof(struct thread)); | ||||
| 
 | ||||
| 	thread->state = TH_ST_UNKNOWN; | ||||
| 	thread->gindex = -1; | ||||
| 	thread->proc = proc; | ||||
| 
 | ||||
| 	if (snprintf(thread->id, PATH_MAX, "%s", relpath) >= PATH_MAX) { | ||||
| 		err("relpath too long"); | ||||
| @ -88,6 +87,12 @@ thread_set_gindex(struct thread *th, int64_t gindex) | ||||
| 	th->gindex = gindex; | ||||
| } | ||||
| 
 | ||||
| void | ||||
| thread_set_proc(struct thread *th, struct proc *proc) | ||||
| { | ||||
| 	th->proc = proc; | ||||
| } | ||||
| 
 | ||||
| int | ||||
| thread_init_end(struct thread *th) | ||||
| { | ||||
|  | ||||
| @ -73,7 +73,7 @@ struct thread { | ||||
| }; | ||||
| 
 | ||||
| int thread_relpath_get_tid(const char *relpath, int *tid); | ||||
| int thread_init_begin(struct thread *thread, struct proc *proc, const char *relpath); | ||||
| int thread_init_begin(struct thread *thread, const char *relpath); | ||||
| int thread_init_end(struct thread *thread); | ||||
| int thread_set_state(struct thread *th, enum thread_state state); | ||||
| int thread_set_cpu(struct thread *th, struct cpu *cpu); | ||||
| @ -81,6 +81,7 @@ int thread_unset_cpu(struct thread *th); | ||||
| int thread_migrate_cpu(struct thread *th, struct cpu *cpu); | ||||
| int thread_get_tid(struct thread *thread); | ||||
| void thread_set_gindex(struct thread *th, int64_t gindex); | ||||
| void thread_set_proc(struct thread *th, struct proc *proc); | ||||
| int thread_connect(struct thread *th, struct bay *bay, struct recorder *rec); | ||||
| 
 | ||||
| int thread_select_active(struct mux *mux, struct value value, struct mux_input **input); | ||||
|  | ||||
| @ -24,12 +24,9 @@ test_oversubscription(void) | ||||
| 	 * affinity rules */ | ||||
| 	proc.metadata_loaded = 1; | ||||
| 
 | ||||
| 	if (proc_init_end(&proc) != 0) | ||||
| 		die("proc_init_end failed"); | ||||
| 
 | ||||
| 	struct thread th0, th1; | ||||
| 
 | ||||
| 	if (thread_init_begin(&th0, &proc, "loom.0/proc.0/thread.0.obs") != 0) | ||||
| 	if (thread_init_begin(&th0, "loom.0/proc.0/thread.0.obs") != 0) | ||||
| 		die("thread_init_begin failed"); | ||||
| 
 | ||||
| 	thread_set_gindex(&th0, 0); | ||||
| @ -37,7 +34,7 @@ test_oversubscription(void) | ||||
| 	if (thread_init_end(&th0) != 0) | ||||
| 		die("thread_init_end failed"); | ||||
| 
 | ||||
| 	if (thread_init_begin(&th1, &proc, "loom.1/proc.1/thread.1.obs") != 0) | ||||
| 	if (thread_init_begin(&th1, "loom.1/proc.1/thread.1.obs") != 0) | ||||
| 		die("thread_init_begin failed"); | ||||
| 
 | ||||
| 	thread_set_gindex(&th1, 1); | ||||
| @ -45,6 +42,15 @@ test_oversubscription(void) | ||||
| 	if (thread_init_end(&th1) != 0) | ||||
| 		die("thread_init_end failed"); | ||||
| 
 | ||||
| 	if (proc_add_thread(&proc, &th0) != 0) | ||||
| 		die("proc_add_thread failed"); | ||||
| 
 | ||||
| 	if (proc_add_thread(&proc, &th1) != 0) | ||||
| 		die("proc_add_thread failed"); | ||||
| 
 | ||||
| 	if (proc_init_end(&proc) != 0) | ||||
| 		die("proc_init_end failed"); | ||||
| 
 | ||||
| 	if (thread_set_cpu(&th0, &cpu) != 0) | ||||
| 		die("thread_set_cpu failed"); | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user